Jump to content

Newbie needs help with script exit.


Recommended Posts

When running a script compiled with AutoIt, I can't get the AutoIt icon to exit. It appears as though the script pauses and waits for something but I can't find what.

Here is the script:

If WinExists("CFI defrag") Then Exit

AutoItWinSetTitle("CFI defrag")

Opt ('WinTitleMatchMode', 4)

Opt ('MustDeclareVars', 1)

Opt ('TrayIconDebug', 1)

Dim $FINISH, $C, $N_DRIVES = 0, $DRIVE

$FINISH = "Defragmentation complete";

For $C = 67 To 90

If DriveGetType(Chr($C) & ":\") == "RAMDisk" Or DriveGetType(Chr($C) & ":\") == "Fixed" Then

$N_DRIVES = $N_DRIVES + 1

EndIf

Next

For $DRIVE = 1 To $N_DRIVES

RunAsSet("cfiservice", "CFI.int", "Main+@in")

Run(@WindowsDir & '\system32\mmc.exe "' & @SystemDir & '\dfrg.msc"', '')

WinWait("classname=MMCMainFrame", "DEFRAG_LISTVIEW")

ControlSend("classname=MMCMainFrame", "DEFRAG_LISTVIEW", "SysListView321", "{home}")

For $C = 1 To $DRIVE - 1

ControlSend("classname=MMCMainFrame", "DEFRAG_LISTVIEW", "SysListView321", "{down}")

Next

ControlClick("classname=MMCMainFrame", "DEFRAG_LISTVIEW", "Button2")

WinWait("classname=#32770", $FINISH)

ControlClick("classname=#32770", $FINISH, "Button2")

WinClose("classname=MMCMainFrame", "DEFRAG_LISTVIEW")

Next

Link to post
Share on other sites

You might try the script replacing the loop for drives with DriveGetDrive("FIXED") and DriveGetDrive("RAMDISK") then loop through the returned array. Also, does the tray icon not show a menu when you right click?

Who else would I be?
Link to post
Share on other sites

You might try the script replacing the loop for drives with DriveGetDrive("FIXED") and DriveGetDrive("RAMDISK") then loop through the returned array. Also, does the tray icon not show a menu when you right click?

<{POST_SNAPBACK}>

Right clicking on the Icon in the tray gives me two choices. The first is to Exit. The second is the words Script paused with a checkmark beside it. I can exit it by choosing exit but I want it to be as transparent as possible and exit on its own

Thanks for the feedback.

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

    No registered users viewing this page.

×
×
  • Create New...