Hallo,
also ich wollte das ControlSend für einfache Fälle durch nen user32.dll call ersetzen, da grad das shift, alt, control handling etwas speziell ist (und ichs auch nicht brauch).
EDIT: ok knapp vorbei ist halt auch daneben, hab jetzt im AutoIt source gespickt und dabei noch gelernt, dass es naben Vk noch scancode gibt und das ist nicht immer der gleiche Wert...
So klappt es jetzt für einfache Anwendungen...
mfg
also ich wollte das ControlSend für einfache Fälle durch nen user32.dll call ersetzen, da grad das shift, alt, control handling etwas speziell ist (und ichs auch nicht brauch).
EDIT: ok knapp vorbei ist halt auch daneben, hab jetzt im AutoIt source gespickt und dabei noch gelernt, dass es naben Vk noch scancode gibt und das ist nicht immer der gleiche Wert...
Code:
Func KeySend($inkey, $evt ="pressed")
$user32 = DllOpen("user32.dll")
if $user32 = -1 Then
ConsoleWrite("KeySend: cannot open user32.dll")
Exit
EndIf
$WM_KEYDOWN = 0x100
$WM_KEYUP = 0x101
If StringUpper($inkey) = "RETURN" Then
$skey = 0x0D
ElseIf StringUpper($inkey) = "SPACE" Then
$skey = 0x20
Else
$key = DllCall($user32, "int", "VkKeyScan", "int", Asc(StringLower($inkey)))
$skey = $key[0]
EndIf
$ret = DllCall($user32, "int", "MapVirtualKey", "int", $skey, "int", 0)
$lparam = BitShift($ret[0], -16)
$lparam = BitOr($lparam, 1)
Select
Case $evt = "pressed"
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYDOWN, "int", $skey, "int", $lparam)
Sleep(15)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYUP, "int", $skey, "int", BitOR($lparam, 0xC0000000))
Case $evt = "down"
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYDOWN, "int", $skey, "int", $lparam)
Case $evt = "up"
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYUP, "int", $skey, "int", BitOR($lparam, 0xC0000000))
EndSelect
DllClose($user32)
EndFunc
mfg