d0n Posted November 2, 2009 Share Posted November 2, 2009 I copied this out and changed it to work for $input2, but i want it to work with both $Input2, and $Input3 Chaning the text in either edit control will run the same function, how would i modify that? Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $hWndEdit If Not IsHWnd($Input2) Then $hWndEdit = GUICtrlGetHandle($Input2) $hWndFrom = $ilParam $iIDFrom = _WinAPI_LoWord ($iwParam) $iCode = _WinAPI_HiWord ($iwParam) Switch $hWndFrom Case $hWndEdit Switch $iCode Case $EN_CHANGE ; Sent when the user has taken an action that may have altered text in an edit control MsgBox("","","") ; no return value EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 2, 2009 Moderators Share Posted November 2, 2009 d0n ,Just add the handle to the Switch Case. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <GuiEdit.au3> $fFlag = False $hGUI = GUICreate("Test", 500, 500) $Input2 = GUICtrlCreateInput("", 10, 10, 400, 30) $HandleInput2 = GUICtrlGetHandle($Input2) $Input3 = GUICtrlCreateInput("", 10, 50, 400, 30) $HandleInput3 = GUICtrlGetHandle($Input3) GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch If $fFlag = True Then $fFlag = False MsgBox(0, "", "Edit Changed") EndIf WEnd Func MY_WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $hWndEdit $hWndFrom = $ilParam $iIDFrom = _WinAPI_LoWord ($iwParam) $iCode = _WinAPI_HiWord ($iwParam) Switch $hWndFrom Case $HandleInput2, $HandleInput3 Switch $iCode Case $EN_CHANGE ; Sent when the user has taken an action that may have altered text in an edit control $fFlag = True ; no return value EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMANDA couple of other changes - because the Help file says:Warning: blocking of running user functions which executes window messages with commands such as "Msgbox()" can lead to unexpected behavior, the return to the system should be as fast as possible !!!So,1. Get the handles when you create the Inputs - why make your message function do it each time?2. Use a flag to signal that the function has fired and then run the MsgBox from your main code.Please ask if anything is unclear.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 2, 2009 Moderators Share Posted November 2, 2009 (edited) logic would dictate: Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $hWndEdit1, $hWndEdit2 If Not IsHWnd($Input2) Then $hWndEdit1 = GUICtrlGetHandle($Input2) If Not IsHWnd($Input3) Then $hWndEdit2 = GUICtrlGetHandle($Input3) $hWndFrom = $ilParam $iIDFrom = _WinAPI_LoWord ($iwParam) $iCode = _WinAPI_HiWord ($iwParam) Switch $hWndFrom Case $hWndEdit1, $hWndEdit2 Switch $iCode Case $EN_CHANGE ; Sent when the user has taken an action that may have altered text in an edit control MsgBox("","","") ; no return value EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMANDNo? Edit: Code outside codebox? Melba provided a different method with same cause and effect. Edited November 2, 2009 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 2, 2009 Share Posted November 2, 2009 (edited) Have it test $hWndFrom against the handles for those controls also. Currently it only tests against the handle of $Input2. edit: All those great minds, thinking alike... Edited November 2, 2009 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
d0n Posted November 2, 2009 Author Share Posted November 2, 2009 i see, got it working now thank you Link to comment Share on other sites More sharing options...
Valuater Posted November 2, 2009 Share Posted November 2, 2009 Well.... here is mine and I did not see any of the others first... Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $hWndEdit, $cActive If Not IsHWnd($Input2) Then $hWndEdit = GUICtrlGetHandle($Input2) If Not IsHWnd($Input3) Then $hWndEdit2 = GUICtrlGetHandle($Input3) $hWndFrom = $ilParam $iIDFrom = _WinAPI_LoWord($iwParam) $iCode = _WinAPI_HiWord($iwParam) Switch $hWndFrom Case $hWndEdit, $hWndEdit2 $cActive = $hWndEdit If GUICtrlGetState($Input3) = $GUI_FOCUS Then $cActive = $hWndEdit2 Switch $iCode Case $EN_CHANGE ; Sent when the user has taken an action that may have altered text in an edit control MsgBox("", "", "") ; no return value EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND 8 8) ... over an hour ago i was posting... damn interruptions Link to comment Share on other sites More sharing options...
d0n Posted November 4, 2009 Author Share Posted November 4, 2009 (edited) HI, i ran into another question regarding WM_COMMAND Right now my GUI when entered something into an input will reset a listview accordingly But because sometimes, i type in 10 (2 digits), it will reset it twice, then screwing with the listview (sometimes it will lose the groups) it works if i only type in a single digit I was wondering if it is possible to only run after the user is done typing or something similar? The problem doesn't happen if i type really slow, or is a single digit I should also mention that i am using SQLlite for data, not sure if that would be a problem EDIT: I think i know why, could be because before the function is finished, another one is ran again, therefore messing it up how would i go about fixing this? Edited November 4, 2009 by d0n Link to comment Share on other sites More sharing options...
martin Posted November 4, 2009 Share Posted November 4, 2009 HI, i ran into another question regarding WM_COMMANDRight now my GUI when entered something into an input will reset a listview accordinglyBut because sometimes, i type in 10 (2 digits), it will reset it twice, then screwing with the listview (sometimes it will lose the groups)it works if i only type in a single digitI was wondering if it is possible to only run after the user is done typing or something similar?The problem doesn't happen if i type really slow, or is a single digitI should also mention that i am using SQLlite for data, not sure if that would be a problemEDIT: I think i know why, could be because before the function is finished, another one is ran again, therefore messing it uphow would i go about fixing this?You really need to show us your WM_COMMAND function, but I assume that you have code in your WM_COMMAND handler which alters the listview. If so then you should do what Melba23 showed and only set a flag, then act on that flag in your main idle loop not in the message handler. In your main idle loop reset the flag and call a function to deal with the update. That way should not give the problem you describe. The examples shown where there is a MsgBox statement in the WM_COMMAND function are a bit naughty because that could cause problems IMO.Alternatively you could use EN_KILLFOCUS so that the list view is only updated when you leave the edit, or you could simply have a button "Apply". Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. 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