Sign in to follow this  
Followers 0
AlexKirst

Prevent autoit from closing?

10 posts in this topic

The problem I am having is trying to prevent autoit from closing when running a specific script. The script that I wrote runs a program, and at the end of the program it needs to close all processes. The problem is that it also closes the autoit script, not allowing it to finish. This keeps the program stuck, also unable to finish.

Is there anyway to elevate the script so that it is not included in the closed processes? Explorer.exe, for example, obviously doesn't close. How can I set the script to be in the same "category", if you will, as explorer.exe? Or any other solution to prevent the script from closing?

Share this post


Link to post
Share on other sites



Please post your script so we can help you.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Here is my script:

Global $hCtrl = 0, $Waiting = True
 
run("adwcleaner")
 
WinWaitActive("- AdwCleaner - v3.213 - Xplode - Général Changelog Team -")
ControlClick("- AdwCleaner - v3.213 - Xplode - Général Changelog Team -", "", "[CLASS:Button; INSTANCE:3]")
 
Do
sleep(10)
Until ControlCommand("- AdwCleaner - v3.213 - Xplode - Général Changelog Team -", "", "Button4", "IsEnabled")
 
ControlClick("- AdwCleaner - v3.213 - Xplode - Général Changelog Team -", "", "[CLASS:Button; INSTANCE:4]")
WinWaitActive("- AdwCleaner - Closing programs -")
Send("{Enter}")
WinWaitActive("- AdwCleaner - Informations -")
ControlClick("- AdwCleaner - Informations -", "", "[CLASS:Button; INSTANCE:1]")
 
 
This is for the program "AdwCleaner". It is a virus removal program. I am trying to automate the process through autoit. It gets to the first "Send("{Enter}"), but then the programs close and cannot continue past that.
Edited by AlexKirst

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Is your script being closed during "- AdwCleaner - Closing programs -"?

Might need to add you script|exe to a "do not touch"|trusted list of AdwCleaner.

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I don't think that Adwcleaner has a trusted list. I was hoping that there was a way to prevent it within the script, or maybe a permission change for autoit? The program is closing after the  "-AdwCleaner - Closing programs -", where I send the "Enter" command to say okay.

Edited by AlexKirst

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Sounds like a question for the AdwCleaner forum.  Or google.

Does the script actually end?  Probably better to do a ControlClick then the send, to ensure you actually click your expected button.

Your script should not end, since it will wait, indefinitely, for window="- AdwCleaner - Informations -"

If it is ending, then do the google, adwCelaner forum searches...because that's not an autoit issue.

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

Just idea for workaround ...

You can write some progress flag to file on disk and in OnAutoItExit event do checking of that flag.

If it's not finished then do Run(@ScriptFullPath) to itself again immediatelly after closing by other application.

At start do checking of progres flag in the file again and go to desired interrupted part of your script.

Share this post


Link to post
Share on other sites

Good call.  I'd suggest driving off of a parameter, so you don't have to worry about file cleanup.

$bRegister = ($CmdLine[0]=0)
MsgBox(1,1,$CmdLine[0])

If $bRegister Then 
    OnAutoItExitRegister("CallAgain")
    ; your code...including up to where the app closes your autoit process
    
    ; if you determine your code does not need to be called again...OnAutoItExitUNRegister
    
EndIf

; the rest of your code

Func CallAgain()
    If $CmdLine[0]=0 Then
        If StringRight(@ScriptFullPath,3) = "au3" Then
            ConsoleWrite('"' & @ProgramFilesDir & '\AutoIt3\AutoIT3.exe" /AutoIt3ExecuteScript "' & @ScriptFullPath & '" Take2' & @CRLF)
            $i = Run('"' & @ProgramFilesDir & '\AutoIt3\AutoIT3.exe" /AutoIt3ExecuteScript "' & @ScriptFullPath & '" Take2')
        Else
            Run('"' & @ScriptFullPath & '" Take2')
        EndIf
    EndIf
EndFunc

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

$bRegister = ($CmdLine[0]=0)
MsgBox(1,1,$CmdLine[0])

If $bRegister Then
    OnAutoItExitRegister("CallAgain")

run("adwcleaner")

WinWaitActive("- AdwCleaner - v3.213 - Xplode - Général Changelog Team -")
ControlClick("- AdwCleaner - v3.213 - Xplode - Général Changelog Team -", "", "[CLASS:Button; INSTANCE:3]")

Do
    sleep(10)
Until ControlCommand("- AdwCleaner - v3.213 - Xplode - Général Changelog Team -", "", "Button4", "IsEnabled")

ControlClick("- AdwCleaner - v3.213 - Xplode - Général Changelog Team -", "", "[CLASS:Button; INSTANCE:4]")
WinWaitActive("- AdwCleaner - Closing programs -")
Send("{Enter}")

EndIf

WinWaitActive("-")
ControlClick("- AdwCleaner - Informations -", "", "[CLASS:Button; INSTANCE:1]")

Func CallAgain()
    If $CmdLine[0]=0 Then
        If StringRight(@ScriptFullPath,3) = "au3" Then
            ConsoleWrite('"' & @ProgramFilesDir & '\AutoIt3\AutoIT3.exe" /AutoIt3ExecuteScript "' & @ScriptFullPath & '" Take2' & @CRLF)
            $i = Run('"' & @ProgramFilesDir & '\AutoIt3\AutoIT3.exe" /AutoIt3ExecuteScript "' & @ScriptFullPath & '" Take2')
        Else
            Run('"' & @ScriptFullPath & '" Take2')
        EndIf
    EndIf
EndFunc

This is what I have so far then, but it doesn't seem to fix the problem. I am still stuck in the same location, and it looks like the scripts ends when I look in my taskbar in the same place as last time. Did I put my code in wrong?

Share this post


Link to post
Share on other sites

@AlexKirst did you find a solution to your problem ? I'm also interested in making this work and I'd appreciate any help. Thanks ! 

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