HezzelQuartz Posted yesterday at 04:54 AM Posted yesterday at 04:54 AM 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 yesterday at 10:05 AM Posted yesterday at 10:05 AM 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! 4 hours ago, 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
Nine Posted yesterday at 12:30 PM Posted yesterday at 12:30 PM _GUICtrlComboAutoComplete ? MattyD 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler 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 6 hours ago Posted 6 hours ago 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 4 hours ago Posted 4 hours ago 💡 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 Spoiler 🌍 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 2 hours ago Posted 2 hours ago 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 Spoiler 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