AlexKirst Posted June 23, 2014 Posted June 23, 2014 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?
water Posted June 23, 2014 Posted June 23, 2014 Please post your script so we can help you. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
AlexKirst Posted June 23, 2014 Author Posted June 23, 2014 (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 June 23, 2014 by AlexKirst
jdelaney Posted June 23, 2014 Posted June 23, 2014 (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 June 23, 2014 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.
AlexKirst Posted June 23, 2014 Author Posted June 23, 2014 (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 June 23, 2014 by AlexKirst
jdelaney Posted June 23, 2014 Posted June 23, 2014 (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 June 23, 2014 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.
Zedna Posted June 23, 2014 Posted June 23, 2014 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. Resources UDF ResourcesEx UDF AutoIt Forum Search
jdelaney Posted June 23, 2014 Posted June 23, 2014 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.
AlexKirst Posted June 23, 2014 Author Posted June 23, 2014 $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?
alecs Posted February 4, 2015 Posted February 4, 2015 @AlexKirst did you find a solution to your problem ? I'm also interested in making this work and I'd appreciate any help. Thanks !
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now