HezzelQuartz Posted March 18 Posted March 18 I try to learn from predicttext.udf example. when I try use GuiCtrlCreateEdit like shown below, it works #include-once #include <GUIConstants.au3> #include 'PredictText.au3' $hGUI = GUICreate('Predict Text + GUI Learn', 220, 60) $Input_Payment_Method = GUICtrlCreateEdit("",10, 10, 200, 50) ;GUICtrlSetData($Input_Payment_Method, "Wood|Metal|Plastic", "") GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND') GUISetState() Local $iGUIGetMsg While 1 $iGUIGetMsg = GUIGetMsg() Switch $iGUIGetMsg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) If _WinAPI_HiWord($wParam) = $EN_SETFOCUS Then Local $_Words1[3] = ['Wood', 'Metal', 'Plastic'] Switch $lParam Case GUICtrlGetHandle($Input_Payment_Method) _RegisterPrediction($lParam, $_Words1) EndSwitch EndIf Return $GUI_RUNDEFMSG EndFunc But, if I change it to GuiCtrlCreateCombo like shown below, it doesn't work #include-once #include <GUIConstants.au3> #include 'PredictText.au3' $hGUI = GUICreate('Predict Text + GUI Learn', 220, 60) $Input_Payment_Method = GUICtrlCreateCombo("",10, 10, 200, 50) GUICtrlSetData($Input_Payment_Method, "Wood|Metal|Plastic", "") GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND') GUISetState() Local $iGUIGetMsg While 1 $iGUIGetMsg = GUIGetMsg() Switch $iGUIGetMsg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) If _WinAPI_HiWord($wParam) = $EN_SETFOCUS Then Local $_Words1[3] = ['Wood', 'Metal', 'Plastic'] Switch $lParam Case GUICtrlGetHandle($Input_Payment_Method) _RegisterPrediction($lParam, $_Words1) EndSwitch EndIf Return $GUI_RUNDEFMSG EndFunc How to make it works? Thank You
MattyD Posted March 18 Posted March 18 Hey HezzelQuartz Just had a quick look, and it looks like the UDF is specific to edit controls unfortunately. The UDF works by subclassing. So in a nutshell, all messages sent to a "registered" control are intercepted by _New_WndProc, and that is where the magic happens . _New_WndProc contains a bunch of code that is specific to edit controls. So yeah, it's probably possible to get comboboxes working, but it involves modifying the guts of the UDF. PS. Just a quick hint if you're still having a play - EN_SETFOCUS is a notification specific to edit controls, so this block of code won't fire for a combobox! On 3/18/2025 at 4:54 AM, HezzelQuartz said: Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) If _WinAPI_HiWord($wParam) = $EN_SETFOCUS Then Local $_Words1[3] = ['Wood', 'Metal', 'Plastic'] Switch $lParam Case GUICtrlGetHandle($Input_Payment_Method) _RegisterPrediction($lParam, $_Words1) EndSwitch EndIf Return $GUI_RUNDEFMSG EndFunc Expand
Nine Posted March 18 Posted March 18 _GUICtrlComboAutoComplete ? MattyD 1 โThey did not know it was impossible, so they did itโ โ Mark Twain Reveal hidden contents Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy
MattyD Posted March 19 Posted March 19 Yep, good call Nine, That mechanism should be a bit simpler to modify too if you ever had the need. Just because I got caught out... The example in the helpfile references <Extras\WM_NOTIFY.au3>. If you click "open this script" from the helpfile it'll work, otherwise the library lives here: "C:\Program Files (x86)\AutoIt3\Examples\Helpfile\Extras\WM_NOTIFY.au3"
SOLVE-SMART Posted March 19 Posted March 19 ๐ก Just as further information: Related post, regarding <Extras\WM_NOTIFY.au3>: @water mentioned the issue (and ticket) with the missing Extras\WM_NOTIFY.au3 file. Best regards Sven ==> AutoIt related: ๐ GitHub, ๐ Discord Server Reveal hidden contents ๐ Au3Forums ๐ฒ AutoIt (en) Cheat Sheet ๐ AutoIt limits/defaults ๐ Code Katas: [...] (comming soon) ๐ญ Collection of GitHub users with AutoIt projects ๐ False-Positives ๐ฎ Me on GitHub ๐ฌ Opinion about new forum sub category ๐ UDF wiki list โ VSCode-AutoItSnippets ๐ WebDriver FAQs ๐จโ๐ซ WebDriver Tutorial (coming soon)
Nine Posted March 19 Posted March 19 In fact WM_NOTIFY.au3 is not needed for _GUICtrlComboAutoComplete. Only WM_COMMAND is required and only $CBN_EDITCHANGE is to be intercepted. The example is way too complicated for absolutely no reason. You could simplify the winproc as this : Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) If _WinAPI_GetClassName($lParam) = "ComboBox" And _WinAPI_HiWord($wParam) = $CBN_EDITCHANGE Then _GUICtrlComboBox_AutoComplete($lParam) Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND SOLVE-SMART 1 โThey did not know it was impossible, so they did itโ โ Mark Twain Reveal hidden contents Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy
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