Jump to content

How to #Include a document and close its GUI


Recommended Posts

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

func 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

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...