lokuxd Posted July 25, 2011 Share Posted July 25, 2011 Hi. I have a problem maybe someone knows why it does not work on the arrows do not;/ -keyup (0x0101) works GUICreate("", 230, 300) GUIRegisterMsg(0x0100, 'keydown') GUISetState(@SW_SHOW) Do Until GUIGetMsg() = -3 Func keydown($q, $w, $e, $r) ConsoleWrite((Dec(Hex($e)))) EndFunc ;==>keypress Link to comment Share on other sites More sharing options...
dragan Posted July 25, 2011 Share Posted July 25, 2011 Did you check help files for function _WinAPI_SetWindowsHookEx()some example (most code taken from help files):expandcollapse popup#include <WindowsConstants.au3> #include <WinAPI.au3> $Form1 = GUICreate("", 230, 300) GUISetState(@SW_SHOW) OnAutoItExitRegister("_Cleanup") $hStub_KeyProc = DllCallbackRegister("_KeyProc", "long", "int;wparam;lparam") $hmod = _WinAPI_GetModuleHandle(0) $hHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($hStub_KeyProc), $hmod) Do Until GUIGetMsg() = -3 Func _KeyProc($nCode, $wParam, $lParam) Local $tKEYHOOKS, $keyCode $tKEYHOOKS = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam) If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) EndIf If WinActive($Form1) then If $wParam = $WM_KEYDOWN then Local $keyCode = DllStructGetData($tKEYHOOKS, "vkCode") Switch $keyCode Case 37 ConsoleWrite('+ Arrow LEFT - pressed' & @CRLF) Case 38 ConsoleWrite('+ Arrow UP - pressed' & @CRLF) Case 39 ConsoleWrite('+ Arrow RIGHT - pressed' & @CRLF) Case 40 ConsoleWrite('+ Arrow DOWN - pressed' & @CRLF) EndSwitch ElseIf $wParam = $WM_KEYUP then Local $keyCode = DllStructGetData($tKEYHOOKS, "vkCode") Switch $keyCode Case 37 ConsoleWrite('! Arrow LEFT - released' & @CRLF) Case 38 ConsoleWrite('! Arrow UP - released' & @CRLF) Case 39 ConsoleWrite('! Arrow RIGHT - released' & @CRLF) Case 40 ConsoleWrite('! Arrow DOWN - released' & @CRLF) EndSwitch EndIf EndIf Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) EndFunc Func _Cleanup() _WinAPI_UnhookWindowsHookEx($hHook) DllCallbackFree($hStub_KeyProc) EndFunc tarretarretarre and genius257 2 Link to comment Share on other sites More sharing options...
Yashied Posted July 25, 2011 Share Posted July 25, 2011 (edited) @lokuxdSome controls consume internally specific Windows Message ID, so registrating them will have no effect, e.g; WM_CHAR, WM_KEYDOWN, WM_KEYUP are consumed by an edit control. Edited July 25, 2011 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
lokuxd Posted July 25, 2011 Author Share Posted July 25, 2011 (edited) but it works on other keyboards just not the arrows ;/ @2up thanks it works but why my code not work??? Edited July 25, 2011 by lokuxd 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