Andreik Posted July 26, 2013 Share Posted July 26, 2013 (edited) Can I use WM_COMMAND to handle EN_CHANGE message but not BN_CLICKED? As long WM_COMMAND process the message BN_CLICKED I am not able to catch the button click in loop using GUIGetMsg(). #include <WindowsConstants.au3> #include <EditConstants.au3> #include <ButtonConstants.au3> #include <WinAPI.au3> $hMain = GUICreate("Test",400,400) $hButton = GUICtrlCreateButton("Click Me",100,100,100,30) $hInput = GUICtrlCreateInput("",100,200,100,30) GUIRegisterMsg($WM_COMMAND,'WM_COMMAND') GUISetState(@SW_SHOW,$hMain) While True Switch GUIGetMsg() Case $hButton MsgBox(0,"Message","You just clicked me.") Case -3 ; GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Switch _WinAPI_HiWord($wParam) Case $EN_CHANGE TrayTip("Read",GUICtrlRead(_WinAPI_LoWord($wParam)),1) Return 0 EndSwitch Return _WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam) EndFunc EDIT: I got this working in this way but I'm looking for something more elegant #include <WindowsConstants.au3> #include <EditConstants.au3> #include <ButtonConstants.au3> #include <WinAPI.au3> $hMain = GUICreate("Test",400,400) $hButton = GUICtrlCreateButton("Click Me",100,100,100,30) $hInput = GUICtrlCreateInput("",100,200,100,30) $hDummy = GUICtrlCreateDummy() GUIRegisterMsg($WM_COMMAND,'WM_COMMAND') GUISetState(@SW_SHOW,$hMain) While True Switch GUIGetMsg() Case $hDummy Switch GUICtrlRead($hDummy) Case $hButton MsgBox(0,"Message","You just clicked me.") EndSwitch Case -3 ; GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Switch _WinAPI_HiWord($wParam) Case $EN_CHANGE TrayTip("Read",GUICtrlRead(_WinAPI_LoWord($wParam)),1) Return 0 Case $BN_CLICKED GUICtrlSendToDummy($hDummy,_WinAPI_LoWord($wParam)) EndSwitch Return _WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam) EndFunc Edited July 26, 2013 by Andreik Link to comment Share on other sites More sharing options...
guinness Posted July 26, 2013 Share Posted July 26, 2013 That's how I would do it, as stated in the reply PM I sent to you. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
JohnOne Posted July 26, 2013 Share Posted July 26, 2013 (edited) Could you not do this. #include <GUIConstantsEx.au3> Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Switch _WinAPI_HiWord($wParam) Case $EN_CHANGE TrayTip("Read",GUICtrlRead(_WinAPI_LoWord($wParam)),1) Return 0 Case $BN_CLICKED Return $GUI_RUNDEFMSG ;If you want AutoIt to run its internal handler for a message, return the variable $GUI_RUNDEFMSG EndSwitch Return _WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam) EndFunc Edited July 26, 2013 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
guinness Posted July 26, 2013 Share Posted July 26, 2013 Hmm...does that work? If it does then I have learnt something new today. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Andreik Posted July 26, 2013 Author Share Posted July 26, 2013 (edited) Nope, it doesn't work. I already tried that. Edited July 26, 2013 by Andreik Link to comment Share on other sites More sharing options...
JohnOne Posted July 26, 2013 Share Posted July 26, 2013 Boooooooooo! AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
KaFu Posted July 26, 2013 Share Posted July 26, 2013 (edited) Do a switch on the control id first? #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <ButtonConstants.au3> #include <WinAPI.au3> $hMain = GUICreate("Test", 400, 400) $cButton = GUICtrlCreateButton("Click Me", 100, 100, 100, 30) $cInput = GUICtrlCreateInput("", 100, 200, 100, 30) GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND') GUISetState(@SW_SHOW, $hMain) While True Switch GUIGetMsg() Case $cButton MsgBox(0, "Message", "You just clicked me.") Case -3 ; GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Switch _WinAPI_LoWord($wParam) ; iIDFrom Case $cInput Switch _WinAPI_HiWord($wParam) ; iCode Case $EN_CHANGE TrayTip("Read", GUICtrlRead(_WinAPI_LoWord($wParam)), 1) ;Return 0 EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMANDEdit:Also you used$hButton = GUICtrlCreateButton("Click Me", 100, 100, 100, 30)from the "h" I would think the variable contains a handle. I recommend to use something more like this:$cButton = GUICtrlCreateButton("Click Me", 100, 100, 100, 30)$hButton = GUICtrlGetHandle($cButton) Edited July 26, 2013 by KaFu JoeBar 1 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Andreik Posted July 26, 2013 Author Share Posted July 26, 2013 I was wondering why all this short examples work so good and when I work on my project nothing works as I expect. The answer is simple and I have to apologize JohnOne and I should listen guiness >long time ago. I don't know why but I knew that $GUI_RUNDEFMSG='' and of course I used magic numbers and magic texts so it's obviously that script not behaved as I expected. Thanks guys! PS: Now I like the old comment of guinness. 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