Aktonius Posted March 15, 2012 Share Posted March 15, 2012 Normally by following example inputbox change can be detected expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> ; used for Lo/Hi word #region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 623, 442, 192, 124) $Input1 = GUICtrlCreateInput("Input1", 224, 168, 121, 21) $Input2 = GUICtrlCreateInput("Input2", 224, 208, 121, 21) $hInput1 = GUICtrlGetHandle($Input1) $hInput2 = GUICtrlGetHandle($Input2) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode $hWndFrom = $ilParam $iIDFrom = _WinAPI_LoWord($iwParam) $iCode = _WinAPI_HiWord($iwParam) Switch $hWndFrom Case $hInput2, $hInput1 Switch $iCode Case $EN_CHANGE ; Sent when the user has taken an action that may have altered text in an edit control $Input1txt = GUICtrlRead($Input1) $Input2txt = GUICtrlRead($Input2) If $Input1txt = $Input2txt Then GUICtrlSetBkColor($Input2, 0x00ff00) Else GUICtrlSetBkColor($Input2, 0xFF0000) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND The problem comes for me when i create inputbox in another gui for which i use following loop Switch $nMsg[1] Case $gui1 Switch $nMsg[0] Case $GUI_EVENT_CLOSE EndSwitch Case $gui2 Switch $nMsg[0] Case $GUI_EVENT_CLOSE GUIDelete($logform) EndSwitch EndSwitch Should something else be in wm_command in this case? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 16, 2012 Moderators Share Posted March 16, 2012 Aktonius,I woudl just change the order of the Switch structures in the handler like this:expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> ; used for Lo/Hi word $Form1 = GUICreate("Form1", 300, 100, 100, 100) $Input1 = GUICtrlCreateInput("Input1", 10, 10, 200, 20) $Input2 = GUICtrlCreateInput("Input2", 10, 50, 200, 20) $hInput1 = GUICtrlGetHandle($Input1) $hInput2 = GUICtrlGetHandle($Input2) GUISetState(@SW_SHOW) $Form2 = GUICreate("Form1", 300, 100, 100, 300) $Input3 = GUICtrlCreateInput("Input3", 10, 10, 200, 20) $hInput3 = GUICtrlGetHandle($Input3) $cLabel = GUICtrlCreateLabel("", 10, 50, 200, 20) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $aMsg = GUIGetMsg(1) Switch $aMsg[1] Case $Form1 Switch $aMsg[0] Case $GUI_EVENT_CLOSE Exit EndSwitch Case $Form2 Switch $aMsg[0] Case $GUI_EVENT_CLOSE GUIDelete($Form2) EndSwitch EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode $hWndFrom = $ilParam $iIDFrom = _WinAPI_LoWord($iwParam) $iCode = _WinAPI_HiWord($iwParam) Switch $iCode Case $EN_CHANGE ; Sent when the user has taken an action that may have altered text in an edit control Switch $hWndFrom Case $hInput2, $hInput1 $Input1txt = GUICtrlRead($Input1) $Input2txt = GUICtrlRead($Input2) If $Input1txt = $Input2txt Then GUICtrlSetBkColor($Input2, 0x00ff00) Else GUICtrlSetBkColor($Input2, 0xFF0000) EndIf Case $hInput3 If GUICtrlRead($Input3) = "" Then GUICtrlSetData($cLabel, "Empty") Else GUICtrlSetData($cLabel, "Content exists") EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMANDAll clear? 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...
acidman Posted March 16, 2012 Share Posted March 16, 2012 I found it's much more simple to use Guioneventmode, when it comes to functions like the ones you have... [u]My dream is to have a dream...[/u] Link to comment Share on other sites More sharing options...
acidman Posted March 16, 2012 Share Posted March 16, 2012 in lots of cases when it comes to if statements a newbie coder would practise if statements a lot to understand the execution flow better of the if statement and others, with loop mode there's a lot of code that slows down one's script like Guigetmsg(); Like when having Multiple Gui's you could simply hide the child Gui and show it later with guioneventmode in most cases makes the script easier to code, it's easier and faster and you do not necessarily have to figure out all sorts of statements, in loop mode you have to spend a considerable amount of time figuring out how to close or hide Child Gui's and most examples on the forums only caters for 2 Guis, go ahead try it... [u]My dream is to have a dream...[/u] Link to comment Share on other sites More sharing options...
acidman Posted March 16, 2012 Share Posted March 16, 2012 here's a script you can try#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Parent", 197, 35, 192, 124) GUISetOnEvent($GUI_EVENT_CLOSE, "_1Close") $Input1 = GUICtrlCreateInput("Input1", 16, 8, 121, 21) GUISetState(@SW_SHOW) $Form2 = GUICreate("Child", 197, 35, 192, 124) GUISetOnEvent($GUI_EVENT_CLOSE, "_2Close") $Input2 = GUICtrlCreateInput("Input1", 16, 8, 121, 21) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $s1 Func _1Close() Exit ; exit the script if close button on parent dialog has ; been clicked EndFunc Func _2Close() GUISetState(@sw_hide, $Form2) ; hide child gui if the close button on the child gui has been clicked EndFunc While 1 do $s1 = GUICtrlRead($input1, 0) ; Read input 1 until the text has been set in input 2; because it's in a while loop the process will be executed until the script has exited until GUICtrlSetData($input2, $s1) WEnd [u]My dream is to have a dream...[/u] 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