MightyWeird Posted March 28, 2019 Share Posted March 28, 2019 Hello, I am having some trouble with my script After ending my script it wont close, keeps on running ( at end select) Wat am I doing wrong? Inserted the whole code below expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.5 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #requireadmin ;AutoIt3Wrapper_Run_Debug_Mode=Y AutoItSetOption ("TrayIconDebug", 1);0-off ;AdlibRegister('_adlib') #include <MsgBoxConstants.au3> #include <GUIConstantsEx.au3> closeeset() Func closeeset() ; Run Notepad if ProcessExists ( "esetonlinescanner_nld.exe" ) Then ProcessClose ( "esetonlinescanner_nld.exe" ) EndIf Local $iPID = Run(".\eset\esetonlinescanner_nld.exe") WinWait("[CLASS:#32770]", "", 10) Sleep(2000) EndFunc if WinExists ("ESET Online Scanner","Volledige beveiliging") Then installed() Else new() EndIf ;Functie new voor schone installatie Func new() WinActive("ESET Online Scanner","Aan de slag") WinActivate("ESET Online Scanner","Aan de slag") ControlClick("ESET Online Scanner", "Aan de slag",1159) WinWait("ESET Online Scanner","Accepteren") WinActivate("ESET Online Scanner","Accepteren") ControlClick("ESET Online Scanner", "Accepteren",1008) WinWait("ESET Online Scanner","Volledige beveiliging") WinActivate("ESET Online Scanner","Volledige beveiliging") ControlClick("ESET Online Scanner", "Volledige beveiliging",1094) WinWait("ESET Online Scanner","Volledige scan") WinActivate("ESET Online Scanner","Volledige scan") ControlClick("ESET Online Scanner", "Volledige scan",1084) WinWait("ESET Online Scanner", "ESET potentieel ongewenste toepassingen laten detecteren en deze in quarantaine laten plaatsen") WinActivate("ESET Online Scanner", "ESET potentieel ongewenste toepassingen laten detecteren en deze in quarantaine laten plaatsen") ControlClick("ESET Online Scanner", "",1014) While 1 Select Case WinExists("ESET Online Scanner", "Geen bedreigingen gevonden") Winactivate("ESET Online Scanner", "Geen bedreigingen gevonden") ControlClick("ESET Online Scanner", "",1102) WinWait("ESET Online Scanner", "Periodieke scan") WinActivate("ESET Online Scanner", "Periodieke scan") ControlClick("ESET Online Scanner", "",1103) WinWait("ESET Online Scanner", "GRATIS DOWNLOADEN") WinActivate("ESET Online Scanner", "GRATIS DOWNLOADEN") ControlClick("ESET Online Scanner", "",1105) WinWait("ESET Online Scanner", "Toepassingsgegevens zoals modules worden verwijderd om schijfruimte vrij te maken") WinActivate("ESET Online Scanner", "Toepassingsgegevens zoals modules worden verwijderd om schijfruimte vrij te maken") ControlClick("ESET Online Scanner", "",1139) ControlClick("ESET Online Scanner", "",1106) Case WinExists("ESET Online Scanner", "Detecties gevonden en opgelost:") ControlClick("ESET Online Scanner", "",1102) WinWait("ESET Online Scanner", "Periodieke scan") WinActivate("ESET Online Scanner", "Periodieke scan") ControlClick("ESET Online Scanner", "",1103) WinActive("ESET Online Scanner", "GRATIS DOWNLOADEN") WinActivate("ESET Online Scanner", "GRATIS DOWNLOADEN") ControlClick("ESET Online Scanner", "",1105) WinWait("ESET Online Scanner", "Toepassingsgegevens zoals modules worden verwijderd om schijfruimte vrij te maken") WinActivate("ESET Online Scanner", "Toepassingsgegevens zoals modules worden verwijderd om schijfruimte vrij te maken") ControlClick("ESET Online Scanner", "",1139) ControlClick("ESET Online Scanner", "",1106) EndSelect ; $pid = ProcessExists(esetonlinescanner_nld.exe) If not ProcessExists("esetonlinescanner_nld.exe") then Exit EndIf WEnd EndFunc ; Functie Wanneer Eset er al op staat Func installed() WinWait("ESET Online Scanner","Volledige beveiliging") Winactivate("ESET Online Scanner","Volledige beveiliging") ControlClick("ESET Online Scanner", "Volledige beveiliging",1094) WinWaitActive("ESET Online Scanner","Volledige scan") ControlClick("ESET Online Scanner", "Volledige scan",1084) winwait ("ESET Online Scanner","Scantype wijzigen") WinActivate("ESET Online Scanner","Scantype wijzigen") Send("{SPACE}") ControlClick("ESET Online Scanner", "",1014) While 1 Select Case WinExists("ESET Online Scanner", "Geen bedreigingen gevonden") ;WinActive("ESET Online Scanner", "Geen bedreigingen gevonden") WinActivate("ESET Online Scanner", "Geen bedreigingen gevonden") ControlClick("ESET Online Scanner", "",1102) WinWait("ESET Online Scanner", "Periodieke scan") Winactivate("ESET Online Scanner", "Periodieke scan") ControlClick("ESET Online Scanner", "",1103) WinWait("ESET Online Scanner", "GRATIS DOWNLOADEN") WinActivate("ESET Online Scanner", "GRATIS DOWNLOADEN") ControlClick("ESET Online Scanner", "",1105) WinWait("ESET Online Scanner", "Toepassingsgegevens zoals modules worden verwijderd om schijfruimte vrij te maken") WinActivate("ESET Online Scanner", "Toepassingsgegevens zoals modules worden verwijderd om schijfruimte vrij te maken") ControlClick("ESET Online Scanner", "",1139) ControlClick("ESET Online Scanner", "",1106) Case WinExists("ESET Online Scanner", "Detecties gevonden en opgelost:") ControlClick("ESET Online Scanner", "",1102) WinWait("ESET Online Scanner", "Periodieke scan") WinActivate("ESET Online Scanner", "Periodieke scan") ControlClick("ESET Online Scanner", "",1103) WinActive("ESET Online Scanner", "GRATIS DOWNLOADEN") WinActivate("ESET Online Scanner", "GRATIS DOWNLOADEN") ControlClick("ESET Online Scanner", "",1105) WinActivate("ESET Online Scanner", "Toepassingsgegevens zoals modules worden verwijderd om schijfruimte vrij te maken") ControlClick("ESET Online Scanner", "",1139) ControlClick("ESET Online Scanner", "",1106) ; If not ProcessExists("esetonlinescanner_nld.exe") then ; Exit; ;EndIf EndSelect ;exitloop WEnd EndFunc Link to comment Share on other sites More sharing options...
Developers Jos Posted March 28, 2019 Developers Share Posted March 28, 2019 Does it help to see why when you look at it after running it through Tidy? : expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.5 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #RequireAdmin ;AutoIt3Wrapper_Run_Debug_Mode=Y AutoItSetOption("TrayIconDebug", 1) ;0-off ;AdlibRegister('_adlib') #include <MsgBoxConstants.au3> #include <GUIConstantsEx.au3> closeeset() Func closeeset() ; Run Notepad If ProcessExists("esetonlinescanner_nld.exe") Then ProcessClose("esetonlinescanner_nld.exe") EndIf Local $iPID = Run(".\eset\esetonlinescanner_nld.exe") WinWait("[CLASS:#32770]", "", 10) Sleep(2000) EndFunc ;==>closeeset If WinExists("ESET Online Scanner", "Volledige beveiliging") Then installed() Else new() EndIf ;Functie new voor schone installatie Func new() WinActive("ESET Online Scanner", "Aan de slag") WinActivate("ESET Online Scanner", "Aan de slag") ControlClick("ESET Online Scanner", "Aan de slag", 1159) WinWait("ESET Online Scanner", "Accepteren") WinActivate("ESET Online Scanner", "Accepteren") ControlClick("ESET Online Scanner", "Accepteren", 1008) WinWait("ESET Online Scanner", "Volledige beveiliging") WinActivate("ESET Online Scanner", "Volledige beveiliging") ControlClick("ESET Online Scanner", "Volledige beveiliging", 1094) WinWait("ESET Online Scanner", "Volledige scan") WinActivate("ESET Online Scanner", "Volledige scan") ControlClick("ESET Online Scanner", "Volledige scan", 1084) WinWait("ESET Online Scanner", "ESET potentieel ongewenste toepassingen laten detecteren en deze in quarantaine laten plaatsen") WinActivate("ESET Online Scanner", "ESET potentieel ongewenste toepassingen laten detecteren en deze in quarantaine laten plaatsen") ControlClick("ESET Online Scanner", "", 1014) While 1 Select Case WinExists("ESET Online Scanner", "Geen bedreigingen gevonden") WinActivate("ESET Online Scanner", "Geen bedreigingen gevonden") ControlClick("ESET Online Scanner", "", 1102) WinWait("ESET Online Scanner", "Periodieke scan") WinActivate("ESET Online Scanner", "Periodieke scan") ControlClick("ESET Online Scanner", "", 1103) WinWait("ESET Online Scanner", "GRATIS DOWNLOADEN") WinActivate("ESET Online Scanner", "GRATIS DOWNLOADEN") ControlClick("ESET Online Scanner", "", 1105) WinWait("ESET Online Scanner", "Toepassingsgegevens zoals modules worden verwijderd om schijfruimte vrij te maken") WinActivate("ESET Online Scanner", "Toepassingsgegevens zoals modules worden verwijderd om schijfruimte vrij te maken") ControlClick("ESET Online Scanner", "", 1139) ControlClick("ESET Online Scanner", "", 1106) Case WinExists("ESET Online Scanner", "Detecties gevonden en opgelost:") ControlClick("ESET Online Scanner", "", 1102) WinWait("ESET Online Scanner", "Periodieke scan") WinActivate("ESET Online Scanner", "Periodieke scan") ControlClick("ESET Online Scanner", "", 1103) WinActive("ESET Online Scanner", "GRATIS DOWNLOADEN") WinActivate("ESET Online Scanner", "GRATIS DOWNLOADEN") ControlClick("ESET Online Scanner", "", 1105) WinWait("ESET Online Scanner", "Toepassingsgegevens zoals modules worden verwijderd om schijfruimte vrij te maken") WinActivate("ESET Online Scanner", "Toepassingsgegevens zoals modules worden verwijderd om schijfruimte vrij te maken") ControlClick("ESET Online Scanner", "", 1139) ControlClick("ESET Online Scanner", "", 1106) EndSelect ; $pid = ProcessExists(esetonlinescanner_nld.exe) If Not ProcessExists("esetonlinescanner_nld.exe") Then Exit EndIf WEnd EndFunc ;==>new ; Functie Wanneer Eset er al op staat Func installed() WinWait("ESET Online Scanner", "Volledige beveiliging") WinActivate("ESET Online Scanner", "Volledige beveiliging") ControlClick("ESET Online Scanner", "Volledige beveiliging", 1094) WinWaitActive("ESET Online Scanner", "Volledige scan") ControlClick("ESET Online Scanner", "Volledige scan", 1084) WinWait("ESET Online Scanner", "Scantype wijzigen") WinActivate("ESET Online Scanner", "Scantype wijzigen") Send("{SPACE}") ControlClick("ESET Online Scanner", "", 1014) While 1 Select Case WinExists("ESET Online Scanner", "Geen bedreigingen gevonden") ;WinActive("ESET Online Scanner", "Geen bedreigingen gevonden") WinActivate("ESET Online Scanner", "Geen bedreigingen gevonden") ControlClick("ESET Online Scanner", "", 1102) WinWait("ESET Online Scanner", "Periodieke scan") WinActivate("ESET Online Scanner", "Periodieke scan") ControlClick("ESET Online Scanner", "", 1103) WinWait("ESET Online Scanner", "GRATIS DOWNLOADEN") WinActivate("ESET Online Scanner", "GRATIS DOWNLOADEN") ControlClick("ESET Online Scanner", "", 1105) WinWait("ESET Online Scanner", "Toepassingsgegevens zoals modules worden verwijderd om schijfruimte vrij te maken") WinActivate("ESET Online Scanner", "Toepassingsgegevens zoals modules worden verwijderd om schijfruimte vrij te maken") ControlClick("ESET Online Scanner", "", 1139) ControlClick("ESET Online Scanner", "", 1106) Case WinExists("ESET Online Scanner", "Detecties gevonden en opgelost:") ControlClick("ESET Online Scanner", "", 1102) WinWait("ESET Online Scanner", "Periodieke scan") WinActivate("ESET Online Scanner", "Periodieke scan") ControlClick("ESET Online Scanner", "", 1103) WinActive("ESET Online Scanner", "GRATIS DOWNLOADEN") WinActivate("ESET Online Scanner", "GRATIS DOWNLOADEN") ControlClick("ESET Online Scanner", "", 1105) WinActivate("ESET Online Scanner", "Toepassingsgegevens zoals modules worden verwijderd om schijfruimte vrij te maken") ControlClick("ESET Online Scanner", "", 1139) ControlClick("ESET Online Scanner", "", 1106) ; If not ProcessExists("esetonlinescanner_nld.exe") then ; Exit; ;EndIf EndSelect ;exitloop WEnd EndFunc ;==>installed Assume the issue is with the func installed() as you never exit the While-wend loop? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Nine Posted March 28, 2019 Share Posted March 28, 2019 And spreading your main code between your functions is not helping either. I suggest you create a Func _Main () and regroup all your code into it. Earthshine 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Earthshine Posted March 28, 2019 Share Posted March 28, 2019 (edited) 30 minutes ago, Nine said: And spreading your main code between your functions is not helping either. I suggest you create a Func _Main () and regroup all your code into it. this.... yes, if you adhere to modular programming concepts, things will be much cleaner and better. then your function code is in ONE place, so when you update or fix it, it's done once. not to mention it's way easier to debug If you find yourself repeating code more than once, make it it's own function. Edited March 28, 2019 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
BrewManNH Posted March 28, 2019 Share Posted March 28, 2019 6 minutes ago, Earthshine said: his.... yes, if you adhere to modular programming concepts, This is the exact opposite of modular programming. TheDcoder, Earthshine and Davidowicza 3 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Earthshine Posted March 28, 2019 Share Posted March 28, 2019 Oops. I misread that post completely. Lol. My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
MightyWeird Posted March 31, 2019 Author Share Posted March 31, 2019 Allright.. Kinda newbie here, but I googled: autoit and Func _Main () . Made some changes on my code. Seems to work now. Thank you guys! expandcollapse popupFunc Esetmain() $esetsourcefolder = @WorkingDir & "\Resources" & "\ESET" $esetdestfolder = @LocalAppDataDir IF not FileExists ($esetdestfolder & "\ESET\") Then ;DirCreate ($destfolder & "\ESET\") DirCopy ($esetsourcefolder, $esetdestfolder & "\ESET\", $FC_OVERWRITE) EndIf If ProcessExists("esetonlinescanner_nld.exe") Then ProcessClose("esetonlinescanner_nld.exe") EndIf Local $iPID = Run( @WorkingDir & "\Resources\ESET" & "\esetonlinescanner_nld.exe" ) WinWait("[CLASS:#32770]", "", 10) installed() Endfunc Func installed() ; Functie Wanneer Eset er al op staat WinWait("ESET Online Scanner", "Volledige beveiliging") WinActivate("ESET Online Scanner", "Volledige beveiliging") ControlClick("ESET Online Scanner", "Volledige beveiliging", 1094) WinWaitActive("ESET Online Scanner", "Volledige scan") ControlClick("ESET Online Scanner", "Volledige scan", 1084) WinWait("ESET Online Scanner", "Scantype wijzigen") WinActivate("ESET Online Scanner", "Scantype wijzigen") Send("{SPACE}") ControlClick("ESET Online Scanner", "", 1014) While 1 Select Case WinExists("ESET Online Scanner", "Geen bedreigingen gevonden") SubFunctiongeenvirus() return Case WinExists("ESET Online Scanner", "Detecties gevonden en opgelost:") SubFunctionwelvirus() return EndSelect wend endfunc Func SubFunctiongeenvirus() ;deze bij geen detectie WinActivate("ESET Online Scanner", "Geen bedreigingen gevonden") ControlClick("ESET Online Scanner", "Scanlogboek opslaan", 1065) sleep (200) winwait ("Opslaan als") WinActivate("Opslaan als") ControlSend("", "", "", "c:\apklogs\esetlog.txt") ControlClick("Opslaan als", "&Opslaan", 1) ControlClick("ESET Online Scanner", "", 1102) WinWait("ESET Online Scanner", "Periodieke scan") WinActivate("ESET Online Scanner", "Periodieke scan") ControlClick("ESET Online Scanner", "", 1103) WinWait("ESET Online Scanner", "GRATIS DOWNLOADEN") WinActivate("ESET Online Scanner", "GRATIS DOWNLOADEN") ControlClick("ESET Online Scanner", "", 1105) WinWait("ESET Online Scanner", "Toepassingsgegevens zoals modules worden verwijderd om schijfruimte vrij te maken") WinActivate("ESET Online Scanner", "Toepassingsgegevens zoals modules worden verwijderd om schijfruimte vrij te maken") ControlClick("ESET Online Scanner", "", 1139) ControlClick("ESET Online Scanner", "", 1106) return endfunc ;einde subfunctie SubFunctiongeenvirus ; deze wanneer wel detectie Func SubFunctionwelvirus() ;Case WinExists("ESET Online Scanner", "Detecties gevonden en opgelost:") ControlClick("ESET Online Scanner", "Scanlogboek opslaan", 1065) sleep (200) winwait ("Opslaan als") WinActivate("Opslaan als") ControlSend("", "", "", "c:\apklogs\esetlog.txt") ControlClick("Opslaan als", "&Opslaan", 1) ControlClick("ESET Online Scanner", "", 1102) WinWait("ESET Online Scanner", "Periodieke scan") WinActivate("ESET Online Scanner", "Periodieke scan") ControlClick("ESET Online Scanner", "", 1103) WinActive("ESET Online Scanner", "GRATIS DOWNLOADEN") WinActivate("ESET Online Scanner", "GRATIS DOWNLOADEN") ControlClick("ESET Online Scanner", "", 1105) WinActivate("ESET Online Scanner", "Toepassingsgegevens zoals modules worden verwijderd om schijfruimte vrij te maken") ControlClick("ESET Online Scanner", "", 1139) ControlClick("ESET Online Scanner", "", 1106) return endfunc ;einde subfunctie SubFunctionwelvirus Link to comment Share on other sites More sharing options...
Developers Jos Posted March 31, 2019 Developers Share Posted March 31, 2019 I would still add a brief sleep in this close loop as that will currently trigger an high cpu consumption while waiting for these popups: While 1 Select Case WinExists("ESET Online Scanner", "Geen bedreigingen gevonden") SubFunctiongeenvirus() Return Case WinExists("ESET Online Scanner", "Detecties gevonden en opgelost:") SubFunctionwelvirus() Return EndSelect sleep(50) WEnd Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
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