sandin Posted March 5, 2009 Share Posted March 5, 2009 Hi, The following example has been taken from help files, and modded a bit, it can detect left Alt down and up (as well as left Ctrl, Shift, Enter...), but it can't detect right Alt UP (as well as Ctrl, Shift, Numeric Enter....), and my question is: Why? And is there a way to make it detect right controls UP like it's doing with the left ones? #include <WinAPI.au3> #include <WindowsConstants.au3> #include <StructureConstants.au3> Global $hHook, $hStub_KeyProc, $buffer = "" _Main() Func _Main() Local $hmod $hStub_KeyProc = DllCallbackRegister("_KeyProc", "long", "int;wparam;lparam") $hmod = _WinAPI_GetModuleHandle(0) $hHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($hStub_KeyProc), $hmod) While 1 Sleep(10) WEnd EndFunc ;==>_Main Func _KeyProc($nCode, $wParam, $lParam) Local $tKEYHOOKS $tKEYHOOKS = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam) If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) EndIf Local $flags = DllStructGetData($tKEYHOOKS, "flags") Switch $flags Case $LLKHF_ALTDOWN ConsoleWrite("$LLKHF_ALTDOWN" & @LF) Case $LLKHF_UP ConsoleWrite("$LLKHF_UP: scanCode - " & DllStructGetData($tKEYHOOKS, "scanCode") & @TAB & "vkCode - " & DllStructGetData($tKEYHOOKS, "vkCode") & @LF) EndSwitch Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) EndFunc ;==>_KeyProc Func OnAutoItExit() _WinAPI_UnhookWindowsHookEx($hHook) DllCallbackFree($hStub_KeyProc) EndFunc ;==>OnAutoItExit Note that my main concern is right ALT, I don't really care about right Ctrl, Shift... (Case $LLKHF_EXTENDED can detect right Ctrl or Shift DOWN but it can't detect right ALT Down), but I noticed that those keys aren't working either so I thought they might be connected somehow, that's why I mentioned them. Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
Madza91 Posted March 5, 2009 Share Posted March 5, 2009 Hehe Here is answer: expandcollapse popup#include <WinAPI.au3> #include <WindowsConstants.au3> #include <StructureConstants.au3> Global $hHook, $hStub_KeyProc, $buffer = "" _Main() Func _Main() Local $hmod $hStub_KeyProc = DllCallbackRegister("_KeyProc", "long", "int;wparam;lparam") $hmod = _WinAPI_GetModuleHandle(0) $hHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($hStub_KeyProc), $hmod) While 1 Sleep(10) WEnd EndFunc ;==>_Main Func _KeyProc($nCode, $wParam, $lParam) Local $tKEYHOOKS $tKEYHOOKS = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam) If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) EndIf Local $flags = DllStructGetData($tKEYHOOKS, "flags") Switch $flags Case $LLKHF_ALTDOWN ConsoleWrite("$LLKHF_ALTDOWN" & @LF) Case $LLKHF_UP ConsoleWrite("$LLKHF_UP: scanCode - " & DllStructGetData($tKEYHOOKS, "scanCode") & @TAB & "vkCode - " & DllStructGetData($tKEYHOOKS, "vkCode") & @LF) Case 33 ConsoleWrite("RIGHT ALT DOWN" & @LF) Case 129 ConsoleWrite("RIGHT ALT UP" & @LF) EndSwitch Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) EndFunc ;==>_KeyProc Func OnAutoItExit() _WinAPI_UnhookWindowsHookEx($hHook) DllCallbackFree($hStub_KeyProc) EndFunc ;==>OnAutoItExit [quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :) Link to comment Share on other sites More sharing options...
sandin Posted March 5, 2009 Author Share Posted March 5, 2009 tnx for reply, but that detects any right key (ctrl, alt, shift...) not only alt. Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
Madza91 Posted March 5, 2009 Share Posted March 5, 2009 Hmm... I see... But you can do this (it's little ugly, but hey, it works ) Global $raltdown = False ... Case 33 $raltdown = True ConsoleWrite("RIGHT ALT DOWN " & $flags & @LF) Case 129 If $raltdown Then $raltdown = False ConsoleWrite("RIGHT ALT UP " & $flags & @LF) MsgBox(0,"Hmm...", "Ugly but it works :D") EndIf ... [quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :) Link to comment Share on other sites More sharing options...
sandin Posted March 5, 2009 Author Share Posted March 5, 2009 tnx for reply, but sometimes in combination with other keys, it doesn't get detected. Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
Madza91 Posted March 6, 2009 Share Posted March 6, 2009 I see... Here is my finally try Just add this in your script from first post (add after "Case $LLKHF_UP" - line 27): ... Case 129 If DllStructGetData($tKEYHOOKS, "scanCode") = 56 And DllStructGetData($tKEYHOOKS, "vkCode") = 165 Then ConsoleWrite("RIGHT ALT UP" & @LF) EndIf ... [quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now