wfish Posted July 13, 2010 Posted July 13, 2010 Let me start by letting you know I am brand new and this is my first script. In my page I have a button that opens another window the problem is that the controls in the child window do not work(set of their corresponding functions. Below is a simplified version of the code, thanks for your time. expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_outfile=..\..\..\Documents and Settings\wayne.salmond\Desktop\buggedCases.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <Array.au3> #include <GUIConstantsEx.au3> #include <UpDownConstants.au3> Local $mailWindow; Local $mainWindow; makeMainWindow(); Func makeMainWindow() Opt("GUIOnEventMode", 1) $mainWindow = GUICreate("Bugged Tickets"); GUISetOnEvent($GUI_EVENT_CLOSE, "cancelButton") $cancelButton = GUICtrlCreateButton("Cancel",100,150) GUICtrlSetOnEvent($cancelButton,"cancelButton"); $emailWindowButton = GUICtrlCreateButton("emailWindow",200,150) GUICtrlSetOnEvent($emailWindowButton,"openEmailWindow"); GUISetState(@SW_SHOW); While 1 Sleep(500) ; Idle around WEnd EndFunc Func cancelButton() Exit EndFunc Func openEmailWindow() Opt("GUIOnEventMode", 1) $mailWindow = GUICreate("Email Bugged Tickets"); GUICtrlCreateLabel("Sorry there are no result sets",10,10); GUICtrlCreateLabel("Please Run Get Cases on first page",10,40); $returnButton =GUICtrlCreateButton("Return",10,80); GUICtrlSetOnEvent($returnButton,"returntoMain"); GUISetState(@SW_SHOW); While 1 Sleep(500) ; Idle around WEnd EndFunc Func returntoMain() MsgBox(0,"return","button has been clicked"); GUIDelete($mailWindow); Return EndFunc
enaiman Posted July 13, 2010 Posted July 13, 2010 Your problem is: you have a While/Wend statement in each function. That's bad because your script will be stuck in that loop forever. Advice: do not put such "endless loops" inside functions unless - it is really needed and - you have any mean to quit the loop when needed Here is the working code: expandcollapse popup#include <Array.au3> #include <GUIConstantsEx.au3> #include <UpDownConstants.au3> Local $mailWindow; Local $mainWindow; makeMainWindow(); While 1 Sleep(500) ; Idle around WEnd Func makeMainWindow() Opt("GUIOnEventMode", 1) $mainWindow = GUICreate("Bugged Tickets"); GUISetOnEvent($GUI_EVENT_CLOSE, "cancelButton") $cancelButton = GUICtrlCreateButton("Cancel",100,150) GUICtrlSetOnEvent($cancelButton,"cancelButton"); $emailWindowButton = GUICtrlCreateButton("emailWindow",200,150) GUICtrlSetOnEvent($emailWindowButton,"openEmailWindow"); GUISetState(@SW_SHOW); EndFunc Func cancelButton() Exit EndFunc Func openEmailWindow() Opt("GUIOnEventMode", 1) $mailWindow = GUICreate("Email Bugged Tickets"); GUICtrlCreateLabel("Sorry there are no result sets",10,10); GUICtrlCreateLabel("Please Run Get Cases on first page",10,40); $returnButton =GUICtrlCreateButton("Return",10,80); GUICtrlSetOnEvent($returnButton,"returntoMain"); GUISetState(@SW_SHOW); EndFunc Func returntoMain() MsgBox(0,"return","button has been clicked"); GUIDelete($mailWindow); Return EndFunc SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :)
wfish Posted July 13, 2010 Author Posted July 13, 2010 (edited) Thanks so much, amazed at the speed of response. Edited July 13, 2010 by wfish
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