Jump to content

my GUI window exit not working..


chiners_68
 Share

Recommended Posts

can somonehelp fix this so it exits the script when the red X is clicked to close the window.

ive created this automatic script for defragmenting which has a skip button to cancel if not required. the button & script works a treat just not the close window button.

Opt("GUIOnEventMode", 1) ; Change to OnEvent mode

$started = 1

$mainwindow = GUICreate("Defragmentation", 200, 100)

GUICtrlCreateLabel("Automating defrag in 6 seconds", 30, 10)

$btnExit = GUICtrlCreateButton("Skip", 70, 50, 60)

;GUISetOnEvent($GUI_EVENT_CLOSE, "_Terminate")

GUICtrlSetOnEvent($btnExit, "_Terminate")

GUISetState(@SW_SHOW)

While 1

Sleep(6000)

If $started Then

Run("defrag.exe c: -f", "", @SW_HIDE)

EndIf

Exit

Wend

Func _Terminate()

$started = 0

Exit

EndFunc

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...