Sign in to follow this  
Followers 0
nsonln

Script will not close on Exit

7 posts in this topic

Here is what I have:

Opt("WinWaitDelay",100)

Opt("WinTitleMatchMode",1)

Opt("WinDetectHiddenText",1)

Opt("MouseCoordMode",0)

$n = 13

$r = 0

Do

MsgBox(0, "Test","$n = " & $n & " &r = " & $r,3)

GETSCSDATA($n,$r)

Sleep(3000)

Until $r = 1

MyCloseFunction()

Func MyCloseFunction()

Exit

EndFunc

Func GETSCSDATA($num,$rep)

Run('C:\WINDOWS\system32\mmc.exe /s "C:\Program Files\Symantec\Symantec System Center\Symantec System Center.msc"')

WinWait("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents]","Console Root\Symante")

If Not WinActive("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents]","Console Root\Symante") Then WinActivate("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents]","Console Root\Symante")

WinWaitActive("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents]","Console Root\Symante")

Send("{APPSKEY}u")

WinWait("Unlock Server Group","Remember this user n")

If Not WinActive("Unlock Server Group","Remember this user n") Then WinActivate("Unlock Server Group","Remember this user n")

WinWaitActive("Unlock Server Group","Remember this user n")

Send("{ENTER}")

WinWait("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents]","Console Root\Symante")

If Not WinActive("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents]","Console Root\Symante") Then WinActivate("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents]","Console Root\Symante")

WinWaitActive("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents]","Console Root\Symante")

Send("{DOWN}")

WinWait("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents\Groups]","Console Root\Symante")

If Not WinActive("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents\Groups]","Console Root\Symante") Then WinActivate("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents\Groups]","Console Root\Symante")

WinWaitActive("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents\Groups]","Console Root\Symante")

Send("+{DOWN " & $n & "}")

Sleep(1000)

IF WinActive("Symantec System Center - [Console Root\Reporting]","Console Root\Reporti") Then

Send("{ALTDOWN}{F4}{ALTUP}")

WinWait("Microsoft Management Console","Save console setting")

If Not WinActive("Microsoft Management Console","Save console setting") Then WinActivate("Microsoft Management Console","Save console setting")

WinWaitActive("Microsoft Management Console","Save console setting")

Send("n")

$r = 1

EndIf

WinWait("Program Manager","FolderView")

If Not WinActive("Program Manager","FolderView") Then WinActivate("Program Manager","FolderView")

WinWaitActive("Program Manager","FolderView")

Sleep(1000)

WinWait("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante")

If Not WinActive("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante") Then WinActivate("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante")

WinWaitActive("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante")

Sleep(1000)

Send("{ALTDOWN}{ALTUP}al")

WinWait("Export List","Save &Only Selected ")

If Not WinActive("Export List","Save &Only Selected ") Then WinActivate("Export List","Save &Only Selected ")

WinWaitActive("Export List","Save &Only Selected ")

Send("{SHIFTDOWN}dv{SHIFTUP}" & $n & "{ENTER}")

WinWait("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante")

If Not WinActive("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante") Then WinActivate("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante")

WinWaitActive("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante")

Send("v{ALTDOWN}{ALTUP}v{DOWN}{UP}{UP}{ESC}{ALTDOWN}{ALTUP}vs{ENTER}")

Sleep(1000)

Send("{ALTDOWN}{ALTUP}al")

WinWait("Export List","Save &Only Selected ")

If Not WinActive("Export List","Save &Only Selected ") Then WinActivate("Export List","Save &Only Selected ")

WinWaitActive("Export List","Save &Only Selected ")

Send("{SHIFTDOWN}av{SHIFTUP}" & $n & "{ENTER}")

WinWait("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante")

If Not WinActive("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante") Then WinActivate("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante")

WinWaitActive("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante")

Send("{ALTDOWN}{ALTUP}vss{ENTER}{ALTDOWN}{ALTUP}al")

WinWait("Export List","Save &Only Selected ")

If Not WinActive("Export List","Save &Only Selected ") Then WinActivate("Export List","Save &Only Selected ")

WinWaitActive("Export List","Save &Only Selected ")

Send("{SHIFTDOWN}fw{SHIFTUP}" & $n & "{ENTER}")

WinWait("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante")

If Not WinActive("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante") Then WinActivate("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante")

WinWaitActive("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante")

Send("{ALTDOWN}{F4}{ALTUP}")

WinWait("Microsoft Management Console","Save console setting")

If Not WinActive("Microsoft Management Console","Save console setting") Then WinActivate("Microsoft Management Console","Save console setting")

WinWaitActive("Microsoft Management Console","Save console setting")

Send("n")

$n = $n + 1

EndFunc

When $r = 1 the script stops running but stays in the tasktray. I want it to completely close... Any ideas please?

Share this post


Link to post
Share on other sites

#2 ·  Posted (edited)

Hi, could you format your code?

Use the blue A button in the web editor to get the autoit coloring tags. Also indenting code would be helpful. Make sure to use Global or Local to declare your variables. My guess is that you never reach the until part of the loop.

EDIT: PS, Welcome to the forum..:shocked:

Edited by Uten

Share this post


Link to post
Share on other sites

Hi should use some code or autoit tags when posting this much, but try this-

Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",1)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)

$n = 13
$r = 0
Do
    MsgBox(0, "Test","$n = " & $n & " &r = " & $r,3)
    GETSCSDATA($n,$r)
    Sleep(3000)
Until $r = 1

MyCloseFunction()

Func MyCloseFunction()
    Exit
EndFunc


Func GETSCSDATA($num,$rep)
    Run('C:\WINDOWS\system32\mmc.exe /s "C:\Program Files\Symantec\Symantec System Center\Symantec System Center.msc"')
    WinWait("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents]","Console Root\Symante")
    If Not WinActive("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents]","Console Root\Symante") Then WinActivate("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents]","Console Root\Symante")
    WinWaitActive("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents]","Console Root\Symante")
    Send("{APPSKEY}u")
    WinWait("Unlock Server Group","Remember this user n")
    If Not WinActive("Unlock Server Group","Remember this user n") Then WinActivate("Unlock Server Group","Remember this user n")
    WinWaitActive("Unlock Server Group","Remember this user n")
    Send("{ENTER}")
    WinWait("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents]","Console Root\Symante")
    If Not WinActive("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents]","Console Root\Symante") Then WinActivate("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents]","Console Root\Symante")
    WinWaitActive("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents]","Console Root\Symante")
    Send("{DOWN}")
    WinWait("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents\Groups]","Console Root\Symante")
    If Not WinActive("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents\Groups]","Console Root\Symante") Then WinActivate("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents\Groups]","Console Root\Symante")
    WinWaitActive("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents\Groups]","Console Root\Symante")
    Send("+{DOWN " & $n & "}")
    Sleep(1000)
    IF WinActive("Symantec System Center - [Console Root\Reporting]","Console Root\Reporti") Then
    Send("{ALTDOWN}{F4}{ALTUP}")
    WinWait("Microsoft Management Console","Save console setting")
    If Not WinActive("Microsoft Management Console","Save console setting") Then 
        WinActivate("Microsoft Management Console","Save console setting")
        WinWaitActive("Microsoft Management Console","Save console setting")
        Send("n")
    EndIf
    $r = 1
    WinWait("Program Manager","FolderView")
    If Not WinActive("Program Manager","FolderView") Then WinActivate("Program Manager","FolderView")
    WinWaitActive("Program Manager","FolderView")
    Sleep(1000)
    WinWait("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante")
    If Not WinActive("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante") Then WinActivate("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante")
    WinWaitActive("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante")
    Sleep(1000)
    Send("{ALTDOWN}{ALTUP}al")
    WinWait("Export List","Save &Only Selected ")
    If Not WinActive("Export List","Save &Only Selected ") Then WinActivate("Export List","Save &Only Selected ")
    WinWaitActive("Export List","Save &Only Selected ")
    Send("{SHIFTDOWN}dv{SHIFTUP}" & $n & "{ENTER}")
    WinWait("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante")
    If Not WinActive("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante") Then WinActivate("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante")
    WinWaitActive("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante")
    Send("v{ALTDOWN}{ALTUP}v{DOWN}{UP}{UP}{ESC}{ALTDOWN}{ALTUP}vs{ENTER}")
    Sleep(1000)
    Send("{ALTDOWN}{ALTUP}al")
    WinWait("Export List","Save &Only Selected ")
    If Not WinActive("Export List","Save &Only Selected ") Then WinActivate("Export List","Save &Only Selected ")
    WinWaitActive("Export List","Save &Only Selected ")
    Send("{SHIFTDOWN}av{SHIFTUP}" & $n & "{ENTER}")
    WinWait("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante")
    If Not WinActive("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante") Then WinActivate("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante")
    WinWaitActive("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante")
    Send("{ALTDOWN}{ALTUP}vss{ENTER}{ALTDOWN}{ALTUP}al")
    WinWait("Export List","Save &Only Selected ")
    If Not WinActive("Export List","Save &Only Selected ") Then WinActivate("Export List","Save &Only Selected ")
    WinWaitActive("Export List","Save &Only Selected ")
    Send("{SHIFTDOWN}fw{SHIFTUP}" & $n & "{ENTER}")
    WinWait("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante")
    If Not WinActive("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante") Then WinActivate("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante")
    WinWaitActive("Symantec System Center - [Console Root\Symantec System Center\System Hierarchy\TVM-SCS3-WorkstationParents","Console Root\Symante")
    Send("{ALTDOWN}{F4}{ALTUP}")
    WinWait("Microsoft Management Console","Save console setting")
    If Not WinActive("Microsoft Management Console","Save console setting") Then WinActivate("Microsoft Management Console","Save console setting")
    WinWaitActive("Microsoft Management Console","Save console setting")
    Send("n")
    $n = $n + 1
EndFunc

You had a $r=1 assignment inside an If-Then-Endif Case that may never execute.

Share this post


Link to post
Share on other sites

i have this same problem :shocked:

Share this post


Link to post
Share on other sites

Running a function with a single line of code is useless. Just use Exit alone.

Also, you say the script stops, but stays in the tray; Does it still respond to being clicked on or does it disappear?

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Add

AutoItSetOption ("TrayIconDebug", 1)  ;0-off
to the top of your script and mouse over the AutoIt icon after $r=1. That should tell you what line the script is on.

Edit: Too slow

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


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
Sign in to follow this  
Followers 0