Rorax Posted September 7, 2006 Posted September 7, 2006 Basically I have a script that can get stopped before completing. $g_szVersion = "Scanner" If WinExists($g_szVersion) Then Exit AutoItWinSetTitle($g_szVersion) But this only does so that the script doesnt start twice. But I want to kill it before it starts if its running. $g_szVersion = "Scanner" If WinExists($g_szVersion) Then ProcessClose("Autoit3.exe") ProcessClose("wiaacmgr.exe") Exit EndIf AutoItWinSetTitle($g_szVersion) That works, but it doesnt check if its the correct script to close. It just closes the first Autoitv3 script it finds. Is there a way to set the processname of a script or a better way to close it if it knows its running while making ure its the correct peocess? Thanks in advance
PsaltyDS Posted September 7, 2006 Posted September 7, 2006 Basically I have a script that can get stopped before completing. $g_szVersion = "Scanner" If WinExists($g_szVersion) Then Exit AutoItWinSetTitle($g_szVersion) But this only does so that the script doesnt start twice. But I want to kill it before it starts if its running. $g_szVersion = "Scanner" If WinExists($g_szVersion) Then ProcessClose("Autoit3.exe") ProcessClose("wiaacmgr.exe") Exit EndIf AutoItWinSetTitle($g_szVersion) That works, but it doesnt check if its the correct script to close. It just closes the first Autoitv3 script it finds. Is there a way to set the processname of a script or a better way to close it if it knows its running while making ure its the correct peocess? Thanks in advance If you compile your script, then the process name will be something like YourScript.exe, and much easier to identify and kill. The name will only be AutoIT3.exe if you are running it uncompiled. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Danny35d Posted September 7, 2006 Posted September 7, 2006 (edited) You can add the following line to the begining of your scriptIf UBound(ProcessList(@ScriptName)) > 2 Then ExitOR you can look for a better solution at the help file for called _SINGLETON Edited September 7, 2006 by Danny35d AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Rorax Posted September 7, 2006 Author Posted September 7, 2006 Damn I'm stupid, didnt know it changed processname after compilation..oops guess I learn something new everyday. Thanks for helping me out! Appreciate it
MHz Posted September 7, 2006 Posted September 7, 2006 You may want to look closer at FAQ 14. There is a illogical difference between recognition of a window title and the concept of closing a process name because of the title.
Rorax Posted September 29, 2006 Author Posted September 29, 2006 (edited) I know it was a while since you replied, but anyway I checked FAQ 14 14. How can I make sure only one copy of my script is run? The easiest way is to rename the title of the hidden AutoIt window when your script first starts. Then in the same script check for that window title existing - if it does then another copy of the script is running. ; Place at the top of your script $g_szVersion = "My Script 1.1" If WinExists($g_szVersion) Then Exit ; It's already running AutoItWinSetTitle($g_szVersion) ; Rest of your script goes here And I'm using $g_szVersion = "TSFAutoSkanner" If WinExists($g_szVersion) Then If ProcessExists("wiaacmgr.exe") then ProcessClose("wiaacmgr.exe") If ProcessExists(@Scriptname) then ProcessClose(@ScriptName) EndIf AutoItWinSetTitle($g_szVersion) But I dont see the illogical difference (not native english speaker so not 100% sure I got the right definition) Basically, it checks if TSFAutoSkanner exists, if it does it closes the process. I cant just use If ProcessExists since the process will start the second the script does. Havent tried to use _Singleton or the Ubound part since it worked with the code above. But is there a chance that it will get messed up? I realise it will get messed up by the slim chance of a windowtitle being TSFAutoSkanner but other then that? Regards, Rorax Edited September 29, 2006 by Rorax
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