Annonyreeder Posted May 6, 2013 Share Posted May 6, 2013 Hello, I don't even know if this has been setup correctly, Basically ive got script that i use at work ive attached to it a timer from another script, i can call the function from the second script fine however the GUI window will not close?, It will close when i just run the script on its own but when calling it in from another script it will not. Any help apreciated as always thanks Code from Script 1# #Include <BreakTimertest.au3> HotKeySet("{ESC}","Quit") // func yesbreak() GUIDelete($YESNO) start() endfunc BreakTimertest.au3 script expandcollapse popupfunc start() ControlClick("CIM Agent","","[CLASS:ToolbarWindow32; INSTANCE:4]","Left",1,177, 15) Opt('MustDeclareVars', 1) Global $msg, $label Global $hGUI2 = GUICreate("Timer", 150, 150,-1,-1,-1,$WS_EX_TOPMOST) ; will create a dialog box that when displayed is centered Global $button = GUICtrlCreateButton("YES", 10, 250, 50) $label = GUICtrlCreateLabel("", 20, 50, 100, 30) GUISetBkColor(0xCC9900) GUICtrlSetFont($label, 20, 400) GUISetState() ; will display an empty dialog box Global $countdown = 14.99 ;45 minutes Global $seconds = $countdown * 60 Countdown() AdlibRegister("Countdown", 1000) Global $dummy = GUICtrlCreateDummy() Do $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $button, $dummy exitloop EndSwitch Until False AdlibUnRegister("Countdown") GUIDelete($hGUI2) Exit endfunc Func Countdown() Local $sec, $min, $hr $sec = Mod($seconds, 60) $min = Mod($seconds / 60, 60) $hr = Floor($seconds / 60 ^ 2) GUICtrlSetData($label, StringFormat("%02i:%02i:%02i", $hr, $min, $sec)) $seconds -= 1 If $seconds < 0 Then GUICtrlSendToDummy($dummy) AdlibUnRegister("Countdown") msgbox("", "Break over", "Break is over go Available NOW!") ControlClick("CIM Agent","","[CLASS:ToolbarWindow32; INSTANCE:4]","Left",1,177, 15) controlsend("CIM Agent","","[CLASS:ToolbarWindow32; INSTANCE:4]","a") EndIf EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 6, 2013 Moderators Share Posted May 6, 2013 Annonyreeder, I would do something like this: ; In func start() Countdown() AdlibRegister("Countdown", 1000) Global $dummy = GUICtrlCreateDummy() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $button, $dummy GUIDelete($hGUI2) MsgBox("", "Break over", "Break is over go Available NOW!") ExitLoop EndSwitch WEnd AdlibUnRegister("Countdown") Exit ; In func Countdown If $seconds < 0 Then GUICtrlSendToDummy($dummy) AdlibUnRegister("Countdown") ControlClick("CIM Agent", "", "[CLASS:ToolbarWindow32; INSTANCE:4]", "Left", 1, 177, 15) ControlSend("CIM Agent", "", "[CLASS:ToolbarWindow32; INSTANCE:4]", "a") EndIf That seems to work when I test it. 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...
Annonyreeder Posted May 6, 2013 Author Share Posted May 6, 2013 Thats great thanks 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