kizsdet Posted June 9, 2010 Share Posted June 9, 2010 expandcollapse popupgui1() func gui1() $gui1 = guicreate("Gui 1",200,200,-1,-1) $button1 = GUICtrlCreateButton("Show Gui 1",20,20,40,20) $button2= GUICtrlCreateButton("Msgbox",20,40,40,20) GUISetState() while 1 $msg = GUIGetMsg() if $msg = -3 Then ExitLoop ElseIf $msg = $button1 Then gui2() ElseIf $msg = $button2 Then msgbox("","msgbox","test") EndIf WEnd EndFunc func gui2() $gui2= guicreate("Gui 2",200,200,-1,-1) $button3 = GUICtrlCreateButton("Button1",20,20,40,20) GUISetState() while 1 $msg2 = GUIGetMsg() if $msg2 = -3 Then GUIDelete("$gui1") Return EndIf WEnd EndFunc hello, im new to autoit and have a simple problem with multiple gui's.. the problem here is when i press show gui button from gui1,gui2 will be visible and while gui 2 is still visible button2 from gui1 which opens a messagebox will not work until i close gui2.. can you correct this code that even if gui2 is visible, the buttons from gui1 will still work.. thanks in advance.. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 9, 2010 Moderators Share Posted June 9, 2010 kizsdet,You need to use GUIGetMsg with the advanced parameter so you can detect which GUI is sending the messages. Look at this:expandcollapse popup#include <GUIConstantsEx.au3> Global $gui2 = 9999, $button3 = 9999 gui1() Func gui1() $gui1 = GUICreate("Gui 1", 200, 200, -1, -1) $button1 = GUICtrlCreateButton("Show Gui 1", 20, 20, 40, 20) $button2 = GUICtrlCreateButton("Msgbox", 20, 40, 40, 20) GUISetState() While 1 $aMsg = GUIGetMsg(1) ; Use advanced parameter to get array Switch $aMsg[1] ; check which GUI sent the message Case $gui1 Switch $aMsg[0] ; Now check for the messages for $gui1 Case $GUI_EVENT_CLOSE ExitLoop Case $button1 GUICtrlSetState($button1, $GUI_DISABLE) gui2() Case $button2 MsgBox("", "msgbox", "test from gui1") EndSwitch Case $gui2 Switch $aMsg[0] ; Now check for the messages for $gui2 Case $GUI_EVENT_CLOSE GUIDelete($gui2) GUICtrlSetState($button1, $GUI_ENABLE) Case $button3 MsgBox("", "msgbox", "test from gui2") EndSwitch EndSwitch WEnd EndFunc ;==>gui1 Func gui2() $gui2 = GUICreate("Gui 2", 200, 200, -1, -1) $button3 = GUICtrlCreateButton("Button1", 20, 20, 40, 20) GUISetState() EndFunc ;==>gui2I have added a few lines:- The button is disabled once $gui2 is created and reenabled once it is deleted.- I used the GUIConstantsEx include file to do the above, so I changed -3 to $GUI_EVENT_CLOSE.- I made the button on $gui2 do something so you can see how it works.I hope this helps - 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...
kizsdet Posted June 9, 2010 Author Share Posted June 9, 2010 Thanks Melba23..it works fine for me now..maybe example like this which uses advance parameter of guigetmsg should be included in the help file. may i ask why gui2 and button3 was declared with a value of 9999? can i assign any value with it?? hmm, another question here is should it always be array [1] when checking for the gui which sents the message and array[0] for controls?? thanks again.. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 9, 2010 Moderators Share Posted June 9, 2010 kizsdet, why gui2 and button3 was declared with a value of 9999?You need these variables to be Global in scope (that means available to all functions in the script). You only create the controls themselves within the $gui2 function, so they would be Local (only available within that function) unless we declare them earlier. We need to check the value of the variables on every pass of the loop. If we do not give a dummy value to these variables, they will fire each time - not what we want at all. You can use any number - as long as it has not been used by any other GUI/control. I tend to use 9999 all the time - I have yet to create a GUI with 10000 controls. should it always be array [1] when checking for the gui which sents the message and array[0] for controls??That is what it says in the Help file! All 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...
kizsdet Posted June 9, 2010 Author Share Posted June 9, 2010 (edited) thanks for immediate reply. i think im gonna love autoit scripting and the people around here. thanks buddy. things are now clear. Edited June 9, 2010 by kizsdet Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 9, 2010 Moderators Share Posted June 9, 2010 kizsdet,The command in question is GUIGetMsg, so I would look on that page if I were you! GUIGetMsg Help pageM23 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...
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