Zwischenablage einfügen

tschitscho

Mitglied
Ich möchte ein Script, das unter NT, aber sicher auf XP läuft.
Das Ziel ist es, in einer Applikation mittels Tastenkombination einen bestimmten Text + Timestamp einfügt. Wie mach ich das am besten? mit VBS?
 
Code:
Option Explicit

Dim strText ' String
strText = "(Datum Zeit"

' ------------------------------------------------------------------------------------
' check if a space at the end of text
If Not (Right(strText, 1) = " ") Then strText = strText & " " End If

' add Time to text
strText = strText & Date()&" "&Time() & ")+++"

' create IE instance - used for clipboard access
Dim oIE ' Global Object IE
Set oIE = WScript.CreateObject("InternetExplorer.Application")
oIE.navigate "about:blank"   ' empty document
oIE.visible = False          ' hidden

Do While (oIE.Busy)          ' wait till IE ready
 WScript.Sleep 50
Loop

' copy text to clipboard
 oIE.Document.parentWindow.clipboardData.setData "Text", strText

' close IE
oIE.Quit

' show result
WScript.Echo "string: " & strText

Eigentlich ist das, was ich brauche, nur es läuft halt nicht unter NT...
 
Nun,
das ganze läuft prima unter XP.
Jetzt habe ich das Script um folgende Zeilen erweitert
Code:
set objWS = CreateObject("WScript.Shell") 
objWS.SendKeys ("+^v")
Dies sollte bewirken, dass die Zwischenablage direkt eingefügt wird. (Sendkeys "ctrl+v")
Funktioniert auch eigentilch überall ausser im Internet Explorer (wos gebraucht wird)
Warum?
Gibt es eine andere möglichkeit etwas aus der Zwischenablage einzufügen
Hier nochmals das ganze Script
Code:
Option Explicit 

Dim objWS 
Dim strText ' String 
strText = "+++(TEXT" 

' ------------------------------------------------------------------------------------------------- 
' check if a space at the end of text 
If Not (Right(strText, 1) = " ") Then strText = strText & " " End If 

' add Time to text 
strText = strText & Date()&" " &Time() &")+++" 

' create IE instance - used for clipboard access 
Dim oIE ' Global Object IE 
Set oIE = WScript.CreateObject("InternetExplorer.Application") 

set objWS = CreateObject("WScript.Shell") 

oIE.navigate "about:blank"   ' empty document 
oIE.visible = False          ' hidden 

Do While (oIE.Busy)          ' wait till IE ready 
 WScript.Sleep 100 
Loop 

' copy text to clipboard 
 oIE.Document.parentWindow.clipboardData.setData "Text", strText 

' close IE 
oIE.Quit 

' show result 
'WScript.Echo "string: " & strText & " copied to clipboard..." 
objWS.SendKeys ("+^v")
 

Neue Beiträge

Zurück