JosephE 0 Posted April 8, 2011 Ok, so i have this code: #include <WindowsConstants.au3> #include <GUIConstants.au3> #include <GUIConstantsEx.au3> ; Test Global $myGui = GUICreate("Hello", 500, 400) GUIRegisterMsg($WM_CHAR, "HandleChar") GUISetState(@SW_SHOW, $myGui) While True $msg = GuiGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop EndIf WEnd Func HandleChar($hWnd, $msgID, $wParam, $lParam) MsgBox(0, "Handled!", "It was handled. Character code: " & $wParam) EndFunc There's no edit control, so the WM_CHAR message should cause the HandleChar() function to be called, but it's not. I need to be able to handle that message, as I need a way of handling key presses for my custom text widget I'm rendering in GDI+. Any help would be very much appreciated! Share this post Link to post Share on other sites
Yashied 241 Posted April 11, 2011 Some 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. 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 HelperAnimated 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 LibraryAppropriate 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 alignmentMore... Share this post Link to post Share on other sites
JosephE 0 Posted April 11, 2011 I'm well aware of that, but i do not have an edit control present in my window. Obviously. Share this post Link to post Share on other sites
eukalyptus 40 Posted August 5, 2011 Same problem here! WM_Char is not working but WM_KEYDOWN does: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $hGui = GUICreate("Test", 500, 400) GUIRegisterMsg($WM_KEYDOWN, "WM_KEYDOWN") GUISetState(@SW_SHOW, $hGui) While True $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop EndIf WEnd Func WM_KEYDOWN($hWnd, $msg, $wParam, $lParam) Local $uScancode = BitAND(BitShift($lParam, 16), 0xFF) Local $tData = DllStructCreate("byte[256];") Local $pData = DllStructGetPtr($tData) Local $aResult = DllCall("user32.dll", "int", "GetKeyboardState", "ptr", $pData) Local $tChar = DllStructCreate("char[2];") Local $pChar = DllStructGetPtr($tChar) $aResult = DllCall("user32.dll", "int", "ToAscii", "uint", $wParam, "uint", $uScancode, "ptr", $pData, "ptr", $pChar, "uint", 0) If @error Then Return 'GUI_RUNDEFMSG' If $aResult[0] > 0 Then ConsoleWrite("! <" & DllStructGetData($tChar, 1) & ">" & @CRLF) Return 'GUI_RUNDEFMSG' EndFunc ;==>WM_KEYDOWN DirectSound UDFDirect2D UDFAutoIt ScreenSaver CollectionBASS UDF v10 download Share this post Link to post Share on other sites
Yashied 241 Posted August 5, 2011 WM_KEYDOWN is used by some native AutoIt functions. In some cases, it may not work properly. 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 HelperAnimated 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 LibraryAppropriate 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 alignmentMore... Share this post Link to post Share on other sites
monoscout999 10 Posted August 5, 2011 but WM_KEYUP works with all cases. Share this post Link to post Share on other sites