fb:porticula NoPaste
Tastatureingaben simulieren
Uploader: | Sebastian |
Datum/Zeit: | 21.10.2011 23:47:01 |
'Tastatureingaben simulieren
'Getestet mit FreeBASIC 0.23.0 fuer Windows
'21.10.2011
'Code basiert auf:
' http://www.freebasic-portal.de/porticula/com-tastatur-842.html
#include "windows.bi"
DECLARE SUB Tastendruck(ByVal KeyCode As UByte)
DIM SHARED KeyState(0 to 255) As Byte
DIM AS STRING Puffer = "hidden test"
DIM AS UBYTE B, KeyCode, Extras
DIM AS INTEGER i = 0, Wartezeit = 5
DIM AS SHORT res
Print "In "; Str(Wartezeit); " Sekunden wird in das aktive Fenster Folgendes eingegeben: "
Print " "; chr(34); Puffer; chr(34)
Print
Print "Notepad wird schon mal gestartet... ";
Shell "start notepad.exe"
Print "Fertig."
Print
Print "Jetzt warten!"
Print
Sleep 1000*WarteZeit
For i = 0 TO LEN(Puffer)-1
B = Puffer[i]
res = VkKeyScan(B)
KeyCode = *(CAST(UBYTE PTR,@res))
Tastendruck (KeyCode)
sleep 25, 1
Next i
Print "OK, das war's."
Sleep
End
SUB Tastendruck(ByVal KeyCode As UByte)
GetKeyboardState (@keyState(0))
if (NOT (keyState(KeyCode))) THEN
keybd_event ( KeyCode, &H45, KEYEVENTF_EXTENDEDKEY, 0 )
keybd_event ( KeyCode, &H45, KEYEVENTF_EXTENDEDKEY OR KEYEVENTF_KEYUP, 0)
END IF
END SUB