Jump to content

Recommended Posts

Posted

MHZ,

you have hit the nail on the head... ive just checked & it runs the GUI but as you said moves on to the next task. asfter the two GUI'for my Defrag run quicky it then moves onto the reboot while the defrag is in progress. rebooting odviously stops the defrag.

how can i modify this then to run wait but still have the GUI disapear after my 6 seconds timeout. ive added a winclose but it dosent cles the window.

#include <GUIConstants.au3>

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

winclose("defragmentation")

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

EndIf

Exit

Wend

Func _Terminate()

$started = 0

Exit

EndFunc

Posted

Just delete the Gui as the script will continue in the background.

#include <GUIConstants.au3>

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
        GUIDelete($mainwindow)
        RunWait("defrag.exe c: -f", "", @SW_HIDE)
    EndIf
    Exit
WEnd

Func _Terminate()
    $started = 0
    Exit
EndFunc

:)

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
  • Recently Browsing   0 members

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