fb:porticula NoPaste
Senkeys sample
Uploader: | marpon |
Datum/Zeit: | 15.02.2013 17:53:55 |
#include once "windows.bi"
'usage : SendKeys("abcEefl")
'
' to test compile to console
' and run it , you will have 10 seconds to open
' notepad of other txt editor to see the keystrokes
' It seems to work with all international keyboards,
'function caps_state()as integer
' Dim as short lret
' lret=LoByte(GetKeyState(VK_CAPITAL))
' if lret THEN
' messagebox 0,"Caps state : " & lret,"info",0
' else
' messagebox 0,"Caps Off","info",0
' END IF
' return cast(integer,lret)
'END function
sub lanceT(ccode as integer)
dim as integer ishift, ialt , ictrl
Dim as integer icod, kcod,lcod,hcod
icod= VkKeyScan(ccode)
if icod =-1 THEN
Keybd_Event(0, ccode, KEYEVENTF_UNICODE, 0)
''sleep 1
Keybd_Event(0, ccode, KEYEVENTF_UNICODE or KEYEVENTF_KEYUP, 0)
'sleep 1
exit sub
END IF
'print str(ccode) & " " & icod & " "
lcod= LoByte( icod)
hcod= HiByte(icod)
kcod= MapVirtualKey(lcod, 0)
if hcod =7 THEN
ishift=1 : ialt =1 : ictrl=1
elseif hcod =6 THEN
ishift=0 : ialt =1 : ictrl=1
elseif hcod =5 THEN
ishift=1 : ialt =1 : ictrl=0
elseif hcod =4 THEN
ishift=0 : ialt =1 : ictrl=0
elseif hcod =3 THEN
ishift=1 : ialt =0 : ictrl=1
elseif hcod =2 THEN
ishift=0 : ialt =0 : ictrl=1
elseif hcod =1 THEN
ishift=1 : ialt =0 : ictrl=0
elseif hcod =0 THEN
ishift=0 : ialt =0 : ictrl=0
END IF
if ialt>0 THEN Keybd_Event(VK_MENU, 0, 0, 0)
'sleep 1
if ictrl>0 THEN Keybd_Event(VK_CONTROL, 0, 0, 0)
'sleep 1
if ishift>0 THEN Keybd_Event(VK_SHIFT, 0, 0, 0)
'sleep 1
Keybd_Event(lcod, kcod, 0, 0)
'sleep 1
Keybd_Event(lcod, kcod, KEYEVENTF_KEYUP, 0)
'sleep 1
if ishift>0 THEN Keybd_Event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0)
'sleep 1
if ictrl>0 THEN Keybd_Event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0)
'sleep 1
if ialt>0 THEN Keybd_Event(VK_MENU, 0, KEYEVENTF_KEYUP, 0)
'sleep 1
END SUB
Sub SendKeys(ByVal sText As String)
Dim VK As WCHAR
Dim As Integer VK_BAK = &H8
Dim As Integer VK_WIN = &H5B
Dim sChar As String
Dim i As Integer
Dim as short mlret
mlret=LoByte(GetKeyState(VK_CAPITAL))
if mlret= 1 THEN
Keybd_Event(VK_CAPITAL, 0, 0, 0)
Keybd_Event(VK_CAPITAL, 0, KEYEVENTF_KEYUP, 0)
END IF
For i = 1 To Len(sText)
sChar = Mid$(sText, i, 1)
If sChar = "{" Then
If UCase$(Mid$(sText, i + 1, 10)) = "BACKSPACE}" Then
VK = VK_BAK
i = i + 10
ElseIf UCase$(Mid$(sText, i + 1, 3)) = "BS}" Then
VK = VK_BAK
i = i + 3
ElseIf UCase$(Mid$(sText, i + 1, 5)) = "BKSP}" Then
VK = VK_BAK
i = i + 5
ElseIf UCase$(Mid$(sText, i + 1, 6)) = "BREAK}" Then
VK = VK_PAUSE
i = i + 6
ElseIf UCase$(Mid$(sText, i + 1, 9)) = "CAPSLOCK}" Then
VK = VK_CAPITAL
i = i + 9
ElseIf UCase$(Mid$(sText, i + 1, 7)) = "DELETE}" Then
VK = VK_DELETE
i = i + 7
ElseIf UCase$(Mid$(sText, i + 1, 4)) = "DEL}" Then
VK = VK_DELETE
i = i + 4
ElseIf UCase$(Mid$(sText, i + 1, 5)) = "DOWN}" Then
VK = VK_DOWN
i = i + 5
ElseIf UCase$(Mid$(sText, i + 1, 3)) = "UP}" Then
VK = VK_UP
i = i + 3
ElseIf UCase$(Mid$(sText, i + 1, 5)) = "LEFT}" Then
VK = VK_LEFT
i = i + 5
ElseIf UCase$(Mid$(sText, i + 1, 6)) = "RIGHT}" Then
VK = VK_RIGHT
i = i + 6
ElseIf UCase$(Mid$(sText, i + 1, 4)) = "END}" Then
VK = VK_END
i = i + 4
ElseIf UCase$(Mid$(sText, i + 1, 6)) = "ENTER}" Then
VK = VK_RETURN
i = i + 6
ElseIf UCase$(Mid$(sText, i + 1, 5)) = "HOME}" Then
VK = VK_HOME
i = i + 5
ElseIf UCase$(Mid$(sText, i + 1, 4)) = "ESC}" Then
VK = VK_ESCAPE
i = i + 4
ElseIf UCase$(Mid$(sText, i + 1, 5)) = "HELP}" Then
VK = VK_HELP
i = i + 5
ElseIf UCase$(Mid$(sText, i + 1, 7)) = "INSERT}" Then
VK = VK_INSERT
i = i + 7
ElseIf UCase$(Mid$(sText, i + 1, 4)) = "INS}" Then
VK = VK_INSERT
i = i + 4
ElseIf UCase$(Mid$(sText, i + 1, 8)) = "NUMLOCK}" Then
VK = VK_NUMLOCK
i = i + 8
ElseIf UCase$(Mid$(sText, i + 1, 5)) = "PGUP}" Then
VK = VK_PRIOR
i = i + 5
ElseIf UCase$(Mid$(sText, i + 1, 5)) = "PGDN}" Then
VK = VK_NEXT
i = i + 5
ElseIf UCase$(Mid$(sText, i + 1, 11)) = "SCROLLLOCK}" Then
VK = VK_SCROLL
i = i + 11
ElseIf UCase$(Mid$(sText, i + 1, 4)) = "TAB}" Then
VK = VK_TAB
i = i + 4
ElseIf UCase$(Mid$(sText, i + 1, 3)) = "F1}" Then
VK = VK_F1
i = i + 3
ElseIf UCase$(Mid$(sText, i + 1, 3)) = "F2}" Then
VK = VK_F2
i = i + 3
ElseIf UCase$(Mid$(sText, i + 1, 3)) = "F3}" Then
VK = VK_F3
i = i + 3
ElseIf UCase$(Mid$(sText, i + 1, 3)) = "F4}" Then
VK = VK_F4
i = i + 3
ElseIf UCase$(Mid$(sText, i + 1, 3)) = "F5}" Then
VK = VK_F5
i = i + 3
ElseIf UCase$(Mid$(sText, i + 1, 3)) = "F6}" Then
VK = VK_F6
i = i + 3
ElseIf UCase$(Mid$(sText, i + 1, 3)) = "F7}" Then
VK = VK_F7
i = i + 3
ElseIf UCase$(Mid$(sText, i + 1, 3)) = "F8}" Then
VK = VK_F8
i = i + 3
ElseIf UCase$(Mid$(sText, i + 1, 3)) = "F9}" Then
VK = VK_F9
i = i + 3
ElseIf UCase$(Mid$(sText, i + 1, 4)) = "F10}" Then
VK = VK_F10
i = i + 4
ElseIf UCase$(Mid$(sText, i + 1, 4)) = "F11}" Then
VK = VK_F11
i = i + 4
ElseIf UCase$(Mid$(sText, i + 1, 4)) = "F12}" Then
VK = VK_F12
i = i + 4
ElseIf UCase$(Mid$(sText, i + 1, 4)) = "F13}" Then
VK = VK_F13
i = i + 4
ElseIf UCase$(Mid$(sText, i + 1, 4)) = "F14}" Then
VK = VK_F14
i = i + 4
ElseIf UCase$(Mid$(sText, i + 1, 4)) = "F15}" Then
VK = VK_F15
i = i + 4
ElseIf UCase$(Mid$(sText, i + 1, 4)) = "F16}" Then
VK = VK_F16
i = i + 4
' NEU! Windows-Taste
ElseIf UCase$(Mid$(sText, i + 1, 4)) = "WIN}" Then
VK = VK_WIN
i = i + 4
' NEU! Kontextmenü
ElseIf UCase$(Mid$(sText, i + 1, 5)) = "APPS}" Then
VK = VK_APPS
i = i + 5
' NEU! PrintScreen-Taste (DRUCK)
ElseIf UCase$(Mid$(sText, i + 1, 6)) = "PRTSC}" Then
VK = VK_SNAPSHOT
i = i + 6
ElseIf UCase$(Mid$(sText, i + 1, 6)) = "ALT_D}" Then
Keybd_event VK_MENU, 0, 0, 0
'sleep 1
i = i + 6
Continue For
ElseIf UCase$(Mid$(sText, i + 1, 6)) = "ALT_U}" Then
Keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0
'sleep 1
i = i + 6
Continue For
ElseIf UCase$(Mid$(sText, i + 1, 7)) = "CTRL_D}" Then
Keybd_event VK_CONTROL, 0, 0, 0
'sleep 1
i = i + 7
Continue For
ElseIf UCase$(Mid$(sText, i + 1, 7)) = "CTRL_U}" Then
Keybd_event VK_CONTROL, 0, KEYEVENTF_KEYUP, 0
'sleep 1
i = i + 7
Continue For
ElseIf UCase$(Mid$(sText, i + 1, 8)) = "SHIFT_D}" Then
Keybd_event VK_SHIFT, 0, 0, 0
'sleep 1
i = i + 8
Continue For
ElseIf UCase$(Mid$(sText, i + 1, 8)) = "SHIFT_U}" Then
Keybd_event VK_SHIFT, 0, KEYEVENTF_KEYUP, 0
'sleep 1
i = i + 8
Continue For
ElseIf UCase$(Mid$(sText, i + 1, 2)) = "}}" Then
VK = -1
lanceT( asc("}") )
i = i + 2
Continue For
ElseIf UCase$(Mid$(sText, i + 1, 2)) = "{}" Then
VK = -1
lanceT( asc("{") )
i = i + 2
Continue For
ElseIf UCase$(Mid$(sText, i + 1, 2)) = "+}" Then
VK = -1
lanceT( asc("+") )
i = i + 2
Continue For
ElseIf UCase$(Mid$(sText, i + 1, 2)) = "%}" Then
VK = -1
lanceT( asc("%") )
i = i + 2
Continue For
ElseIf UCase$(Mid$(sText, i + 1, 2)) = "^}" Then
VK = -1
lanceT( asc("^"))
lanceT( asc(" "))
i = i + 2
Continue For
ElseIf UCase$(Mid$(sText, i + 1, 2)) = "~}" Then
VK = -1
lanceT( asc("~") )
lanceT( asc(" "))
i = i + 2
Continue For
End If
ElseIf sChar = "+" Then ' SHIFT
Keybd_event VK_SHIFT, 0, 0, 0
'sleep 1
Keybd_event VK_SHIFT, 0, KEYEVENTF_KEYUP, 0
'sleep 1
Continue For
ElseIf sChar = "%" Then ' ALT
Keybd_event VK_MENU, 0, 0, 0
'sleep 1
Keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0
'sleep 1
Continue For
ElseIf sChar = "^" Then ' CONTROL
Keybd_event VK_CONTROL, 0, 0, 0
'sleep 1
Keybd_event VK_CONTROL, 0, KEYEVENTF_KEYUP, 0
'sleep 1
Continue For
ElseIf sChar = "~" Then ' ENTER
Keybd_event VK_RETURN, 0, 0, 0
'sleep 1
Keybd_event VK_RETURN, 0, KEYEVENTF_KEYUP, 0
'sleep 1
Continue For
ElseIf sChar = "¨" Then
VK = -1
lanceT( asc("¨"))
lanceT( asc(" "))
Continue For
ElseIf sChar = "`" Then
VK = -1
lanceT( asc("`"))
lanceT( asc(" "))
Continue For
Else
VK = -1
lanceT(asc(sChar) )
End If
if vk<> -1 THEN
Keybd_event VK, 0, 0, 0
'sleep 1
Keybd_event VK, 0, KEYEVENTF_KEYUP, 0
'sleep 1
vk= -1
END IF
Next i
'lret=LoByte(GetKeyState(VK_CAPITAL))
if mlret=1 THEN
Keybd_Event(VK_CAPITAL, 0, 0, 0)
Keybd_Event(VK_CAPITAL, 0, KEYEVENTF_KEYUP, 0)
END IF
End Sub
'SLEEP 5000
'SendKeys"{CTRL_D}m{CTRL_U}"
' ex SendKeys("abcEefl")
'end
sleep 10000
sendkeys "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzé'-è_çà)(=+°O&\~"
SendKeys("c'est la fin des Haricots découpés en 8/2~")
sendkeys "ABCDEFGHIJKLMNOPQRSTUVWXYZ~"
sendkeys "abcdefghijklmnopqrstuvwxyz~"
sendkeys "01234567890!@#$%^&*()_+{{}{}}][:€¤£""²,?;./§{~}n{+}{%}{^}ëêùûüâäÔ¨a±`‘´·~"
SendKeys("{ALT_D}{F4}{ALT_U}")
sleep