RichardL Posted August 2, 2011 Share Posted August 2, 2011 Hello,I have a problem where a special keyboard for a piece of equipment is unavailable. So I want a GUI to detect all keypresses (then I can convert them to text messages and 'Send' them to a telnet window.) I'm using a GUI prog modified from GaryFrost), but it's not detecting the arrow keys. Thanks,Richard.expandcollapse popup#include <GuiConstants.au3> #include <Date.au3> Global Const $WM_NOTIFY = 0x004E Global Const $WM_NCRBUTTONDOWN = 0x00A4 Global Const $WM_KEYDOWN = 0x0100 Global Const $WM_SYSKEYDOWN = 0x0104 Global Const $WM_SYSCHAR = 0x0106 Global Const $WM_COMMAND = 0x0111 Global Const $WM_IME_KEYDOWN = 0x0290 Func _HiWord($x) Return BitShift($x, 16) EndFunc Func _LoWord($x) Return BitAND($x, 0xFFFF) EndFunc Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam) Local $nNotifyCode = _HiWord($wParam) Local $nID = _LoWord($wParam) Local $hCtrl = $lParam ConsoleWrite(StringFormat("WMC %s %4x %4x %4x %8x\n", _Now(), $msg, $nNotifyCode, $nID, $hCtrl)) Return $GUI_RUNDEFMSG EndFunc GUICreate("MyGUI") GUISetState() GUIRegisterMsg($WM_KEYDOWN, "MY_WM_COMMAND") ; Try others to find arrow keypresses... GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") GUIRegisterMsg($WM_SYSKEYDOWN, "MY_WM_COMMAND") GUIRegisterMsg($WM_SYSCHAR, "MY_WM_COMMAND") GUIRegisterMsg($WM_NOTIFY, "MY_WM_COMMAND") GUIRegisterMsg($WM_NCRBUTTONDOWN, "MY_WM_COMMAND") GUIRegisterMsg($WM_IME_KEYDOWN, "MY_WM_COMMAND") While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd Link to comment Share on other sites More sharing options...
monoscout999 Posted August 2, 2011 Share Posted August 2, 2011 (edited) I read about it in MSDN - WM_KEYDOWN Message As i can see WM_KEYDOWN value is 0x100 in the remarks says something interesting. For enhanced 101- and 102-key keyboards, extended keys are the right ALT and CTRL keys on the main section of the keyboard; the INS, DEL, HOME, END, PAGE UP, PAGE DOWN, and arrow keys in the clusters to the left of the numeric keypad; and the divide (/) and ENTER keys in the numeric keypad. Other keyboards may support the extended-key bit in the lParam parameter.So i do some tests and it works #include <GuiConstants.au3> #include <windowsconstants.au3> GUICreate("MyGUI") GUISetState() GUIRegisterMsg(0x101,"WM_KEYDOWN") While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd Func WM_KEYDOWN($hWnd, $msg, $wParam, $lParam) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $wParam = ' & $wParam & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console EndFunc Edited August 2, 2011 by monoscout999 Link to comment Share on other sites More sharing options...
RichardL Posted August 3, 2011 Author Share Posted August 3, 2011 Oh yes, arrow keys send WM_KEYUP (0x101) but not WM_KEYDOWN. The other keys in that list e.g. home, send both, so the doc does not explain it all. I should have tried both, not blindly assumed. Thanks, Richard. 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