boogieoompa Posted June 18, 2006 Posted June 18, 2006 I have an autoit script running in the background (the process is named autoit3.exe, even though I named the app differently) but I want to kill this process from another autoit script but I don't know how to close it since both apps have the same process name. Any suggestions? Thanks
Moderators SmOke_N Posted June 18, 2006 Moderators Posted June 18, 2006 (edited) Try this:If _PCloseSameName('autoit.exe') Then MsgBox(0, 'info:', 'You have the only .exe with your name running') Func _PCloseSameName($sExeName) Local $aProcList = ProcessList() For $iCount = 1 To $aProcList[0][0] If $aProcList[$iCount][0] = $sExeName And $aProcList[$iCount][1] <> @AutoItPID Then ProcessClose($aProcList[$iCount][1]) Return 1 EndIf Next Return 0 EndFunc Edited June 18, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
herewasplato Posted June 18, 2006 Posted June 18, 2006 Try this:If _PCloseSameName('autoit.exe') Then MsgBox(0, 'info:', 'You have the only .exe with your name running') Func _PCloseSameName($sExeName) Local $aProcList = ProcessList() For $iCount = 1 To $aProcList[0][0] If $aProcList[$iCount][0] = $sExeName And $aProcList[$iCount][1] <> @AutoItPID Then ProcessClose($aProcList[$iCount][1]) Return 1 EndIf Next Return 0 EndFuncoÝ÷ Ûú®¢×®)e©íßvî´(ºWg¢×âêÞ¢ëp(Â¥vz-Âä~æ{[-ÚÞªè«zËay·j÷«²*'¡ð.¶-ßiÝ @boogieoompa, Have you seen FAQ #14? http://www.autoitscript.com/autoit3/docs/faq.htm#14 Maybe it does not apply here. [size="1"][font="Arial"].[u].[/u][/font][/size]
Moderators SmOke_N Posted June 18, 2006 Moderators Posted June 18, 2006 (edited) Thanks, but it would probably be more like this, since it's going to be the only instance regardless lol:If _PCloseSameName('autoit3.exe') Then MsgBox(64, 'Info:', 'There was another instance that was eliminated.' & @CR & 'You now have the only instance running.') Else MsgBox(0, 'info:', 'You have the only .exe with your name running') EndIf Func _PCloseSameName($sExeName) Local $aProcList = ProcessList(), $iFound = 0 For $iCount = 1 To $aProcList[0][0] If $aProcList[$iCount][0] = $sExeName And $aProcList[$iCount][1] <> @AutoItPID Then ProcessClose($aProcList[$iCount][1]) $iFound = 1 EndIf Next If $iFound Then Return 1 Return 0 EndFunc Edited June 18, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
herewasplato Posted June 18, 2006 Posted June 18, 2006 ...but it would probably be more like this...Yep, better. Keep it up. [size="1"][font="Arial"].[u].[/u][/font][/size]
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