unexpectedpanda Posted January 7, 2011 Share Posted January 7, 2011 Hi all, I'm sure the solution is obvious, but after my Helpfile-fu, Google-fu, Forum-fu and FAQ-fu failed me and hours of fiddling, I need a fresh pair of eyes to help. The first GUI in this script loads, and when you press on the first button loads another GUI in the function Autobench. But this second GUI doesn't respond to any button presses. Any pointers to getting the buttons to respond would be greatly appreciated. expandcollapse popup#include <GUIConstants.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) #RequireAdmin $MachineField = 0 $FormMainGUI = GUICreate("Benchmarks", 450, 150, (@Desktopwidth/2)-225, (@DesktopHeight/2)-250) $btnAutomated = GuiCtrlCreateButton("Deploy and run automated benchmarks",75,40,300,41) $btnExitGui = GUICtrlCreateButton("Exit", 186, 100, 75, 25, 0) GUISetState(@SW_SHOW,$FormMainGUI) GUISetOnEvent($GUI_EVENT_CLOSE,"CloseGui",$FormMainGUI) GUICtrlSetOnEvent($btnExitGui,"CloseGui") GUICtrlSetOnEvent($btnAutomated,"AutoBench") WinWaitClose("Benchmarks") ;************************************************** ;Functions Func AutoBench() GUIDelete($FormMainGUI) $MachineNameGUI = GUICreate("Machine name",450,150,(@DesktopWidth/2)-225, (@DesktopHeight/2)-150) $MachineFieldlbl = GUICtrlCreateLabel("Please enter the machine name (brand/model, e.g. Apple MacBook Pro 13",10,10) $MachineField = GUICtrlCreateInput("",10,30) $MachineSaveBtn = GUICtrlCreateButton("Save",10,55,100,20) GuiSetState(@SW_SHOW,$MachineNameGUI) GUISetOnEvent($GUI_EVENT_CLOSE,"CloseGui",$MachineNameGUI) GUICtrlSetOnEvent($MachineSaveBtn,"MachineSaveBtn") WinWaitClose("Machine name") EndFunc Func MachineSaveBtn() GUICtrlRead($MachineField) MsgBox(0,"",$MachineField) EndFunc Func CloseGui() Exit EndFunc Much thanks! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 7, 2011 Moderators Share Posted January 7, 2011 unexpectedpanda,You need to have an idle loop in the main portion of the script where it can wait for you to action the controls. At the moment you are just waiting at the WinWaitClose("Machine name") line and, as you are still in a function, AutoIt just queues any further events - hence no reaction to them.Remove the 2 WinWaitClose lines and substitute this for the WinWaitClose("Benchmarks") line:While 1 Sleep(10) WEndNow the script will return to the main portion of the script after creating the second GUI and be waiting for you to action its controls. 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...
unexpectedpanda Posted January 7, 2011 Author Share Posted January 7, 2011 (edited) Ah, so because it's in a function it's treated differently. Interesting! I look forward to playing around a bit more Thanks so much for your kindness Melba23 -- I'd also like to thank you for all your other responses on this forum, they've saved me and no doubt many others a few times now. Edited January 7, 2011 by unexpectedpanda Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 7, 2011 Moderators Share Posted January 7, 2011 unexpectedpanda,Thanks for the compliments. You may find the Interrupting a running function and Managing Multiple GUIs tutorials in the Wiki of interest if you want to learn a little more about such things. 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...
unexpectedpanda Posted January 7, 2011 Author Share Posted January 7, 2011 Brill! I will do exactly that 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