Tastatur manipulieren

  • Ne, _IsPressed überprüft nur ob sie gedrückt ist, ändert aber nichts daran! Ich weiß ja nicht was dann pasiert, wenn du die taste drückst, aber vieleicht kann man das ja rückgänig machen oder so!

    mfg. Jam00

    • Offizieller Beitrag

    Mit _IsPressed funktionier auch die Abfrage der Windowstasten nicht .

    Spoiler anzeigen
    [autoit]

    #include <Misc.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $dll = DllOpen("user32.dll")

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Sleep(250)
    If _IsPressed("A4", $dll) Then
    MsgBox(0, "_IsPressed", "Linke Windowstaste wurde gedrückt ")
    ExitLoop
    EndIf
    If _IsPressed("A5", $dll) Then
    MsgBox(0, "_IsPressed", "Rechte Windowstaste wurde gedrückt ")
    ExitLoop
    EndIf
    WEnd
    DllClose($dll)

    [/autoit]


    Jedenfall nicht bei WIndows Vista, testet mal ob es bei WinXP funzt .

  • Oh, stimmt, ist mir letztens auch pasiert, hab nur nicht gerafft warum das so ist^^
    Bei uns in der Schule ist es so, wenn man STRG+ALT+ENTF drückt kommt erst so ein auswahlfensert, und ich wollte es so machen, das er den TaskManager sofort startet, und da hat er entf auch n icht gelesen! Warum gibt es das dann eig. wenn es eh nicht geht?

    mfg. Jam00

  • Damit kann man den WinKey blockieren:
    Siehe unten, Fehler korrigiert.

    Einmal editiert, zuletzt von progandy (17. Februar 2009 um 21:17)

  • Naja, ist von MSDN und funktioniert zumindest unter XP ;)
    Hab grad nochmal geschaut... Hab ein paar Variablen geändert und danach vergessen zu testen. Jetzt aber:

    Spoiler anzeigen
    [autoit]

    ; http://msdn.microsoft.com/en-us/library/…a_Keyboard_Hook
    Global Const $VK_LWIN = 0x5B
    Global Const $VK_RWIN = 0x5C
    Global $__WinKey_LowLevelKeybHook=0
    Global Const $Low_Level_Keyb_hook_struct = "DWORD vkCode;" _
    &"DWORD scanCode;" _
    &"DWORD flags;" _
    &"DWORD time;" _
    &"ULONG_PTR dwExtraInfo"

    [/autoit] [autoit][/autoit] [autoit]

    $CallBackProc = _BlockWinKeys()

    [/autoit] [autoit][/autoit] [autoit]

    ToolTip("WinKeys blocked",0,0)
    While 1
    Sleep(100)
    WEnd
    MsgBox(4096, "", "KeyBoard is enabled!")

    [/autoit] [autoit][/autoit] [autoit]

    Exit

    [/autoit] [autoit][/autoit] [autoit]

    Func OnAutoItExit()
    _UnblockWinKeys($CallBackProc)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _UnblockWinKeys(ByRef $hCallProc)
    If $__WinKey_LowLevelKeybHook > 0 Then
    DllCall("user32.dll", "int", "UnhookWindowsHookEx", "hwnd", $hCallProc)
    DllCallbackFree($hCallProc[1])
    $__WinKey_LowLevelKeybHook = 0
    Return 1
    EndIf
    Return 0
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _BlockWinKeys()
    Local Const $WH_KEYBOARD_LL = 13
    Local $hKeyProc = DllCallbackRegister("_KeyProc", "int", "int;ptr;ptr")
    Local $hMod = DllCall("kernel32.dll", "hwnd", "GetModuleHandle", "ptr", 0)
    Local $hWinHook = DllCall("user32.dll", "hwnd", "SetWindowsHookEx", _
    "int", $WH_KEYBOARD_LL, _
    "ptr", DllCallbackGetPtr($hKeyProc), _
    "hwnd", $hMod[0], _
    "dword", 0)
    $__WinKey_LowLevelKeybHook = $hWinHook[0]
    Return $hKeyProc
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _KeyProc($nCode, $wParam, $lParam)
    If $nCode < 0 Then
    Local $iRet = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $__WinKey_LowLevelKeybHook, _
    "int", $nCode, _
    "ptr", $wParam, _
    "ptr", $lParam)
    Return $iRet[0]
    EndIf
    Switch $wParam
    Case 0x100, 0x101 ; WM_KEYDOWN, WM_KEYUP
    Local $dllstruct = DllStructCreate($Low_Level_Keyb_hook_struct,$lParam)
    If DllStructGetData($dllstruct,1) = $VK_LWIN Or DllStructGetData($dllstruct,1) = $VK_RWIN Then Return 1
    EndSwitch
    Local $iRet = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $__WinKey_LowLevelKeybHook, _
    "int", $nCode, _
    "ptr", $wParam, _
    "ptr", $lParam)
    Return $iRet[0]
    EndFunc

    [/autoit]