Jump to content
Sign in to follow this  
Tinnu

Closing other Auoit Process instances

Recommended Posts

Nice idea with the Winlist ;)...

_AutoIt_Close_Other_Instances()

Func _AutoIt_Close_Other_Instances()
    $aWinlist = WinList("[REGEXPCLASS:.*?AutoIt.*?]")
    Local $s_PID, $s_PIDs
    For $i = 1 To UBound($aWinlist) - 1
        $s_PID = WinGetProcess($aWinlist[$i][1])
        If Not StringInStr($s_PIDs, $s_PID) Then $s_PIDs &= $s_PID & ";"
    Next
    $s_PIDs = StringLeft($s_PIDs, StringLen($s_PIDs) - 1)
    $a_PIDs = StringSplit($s_PIDs, ";")
    For $i = 1 To $a_PIDs[0]
        If ProcessExists($a_PIDs[$i]) Then
            If $a_PIDs[$i] <> @AutoItPID Then ProcessClose($a_PIDs[$i])
        EndIf
    Next
EndFunc   ;==>_AutoIt_Close_Other_Instances

Share this post


Link to post
Share on other sites

Thanks to HavikTech for the idea & KaFu for the script.

now i am trying to understand it. ;)

Edited by Tinnu

Share this post


Link to post
Share on other sites

I think this one 'll be easy to understand...

Close_Autoit_Programs()
Func Close_Autoit_Programs()
    Local $My_Process_ID = @AutoItPID
    Local $Get_List = WinList("[REGEXPCLASS:.*?AutoIt.*?]")
    Local $PID = 0
    For $i = 1 To $Get_List[0][0]
        $PID = WinGetProcess($Get_List[$i][1])
        If $PID <> $My_Process_ID Then
            WinKill($Get_List[$i][1])
            ProcessClose($PID)
        EndIf
    Next
    Return
EndFunc

Share this post


Link to post
Share on other sites

Thanks HavikTech for the short version.

but i want to know that which one is fast and better?

Your script or KaFu's?


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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...