Sign in to follow this  
Followers 0
boogieoompa

Closing another autoit from within autoit

5 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by SmOke_N

[center]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.[/center]

Share this post


Link to post
Share on other sites

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]

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by SmOke_N

[center]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.[/center]

Share this post


Link to post
Share on other sites

...but it would probably be more like this...

Yep, better. Keep it up.

[size="1"][font="Arial"].[u].[/u][/font][/size]

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