Sign in to follow this  
Followers 0
NELyon

Two of the same functions exist, can i end only one?

16 posts in this topic

If i have two or more of the same processes open, is it possible to kill all but one of them using ProcessKill()? ProcessKill will close all of them. If i can get this figured out, i can start programming more IE crap.

Share this post


Link to post
Share on other sites



if you have the pids to the processes you could use process close to kill each individual process

http://www.autoitscript.com/forum/index.ph...mp;#entry114302

http://www.autoitscript.com/forum/index.ph...st&p=200025


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

ok, i'm going to a different question instead. Is it possible to close all IE windows except one specified in a variable? i think this was answered before but i searched and couldn't find it

Share this post


Link to post
Share on other sites

ok, i'm going to a different question instead. Is it possible to close all IE windows except one specified in a variable? i think this was answered before but i searched and couldn't find it

HighLander :D

[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

Lol, thanks smoke

Share this post


Link to post
Share on other sites

wait... it won't work

Share this post


Link to post
Share on other sites

wait... it won't work

Did you try to mod it?

[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

no

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

_WinCloseSpecial('iexplore.exe', 'Some Name To Keep')

Func _WinCloseSpecial($sExe, $sWinKeep)
    $OptWTMM = Opt('WinTitleMatchMode', 2)
    $sWinKeep = WinGetHandle($sWinKeep)
    Local $aWinList = WinList(), $aProcList = ProcessList()
    Local $aStoreProcess = ''
    For $xCount = 1 To $aProcList[0][0]
        If $aProcList[$xCount][0] = $sExe Then $aStoreProcess &= $aProcList[$xCount][1] & Chr(01)
    Next
    $aStoreProcess = StringSplit(StringTrimRight($aStoreProcess, 1), Chr(01))
    For $iCount = 1 To $aWinList[0][0]
        For $xCount = 1 To UBound($aStoreProcess) - 1
            If WinGetProcess($aWinList[$iCount][0]) = $aStoreProcess[$xCount] Then
                If $aWinList[$iCount][1] <> $sWinKeep Then
                    WinClose($aWinList[$iCount][1])
                EndIf
            EndIf
        Next
    Next
    Opt('WinTitleMatchMode', $OptWTMM)
EndFunc

Edit:

Wish I had read this:

no

Before I posted. 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

lol

Share this post


Link to post
Share on other sites

This should work

#include <IE.au3>

; prevent object error from terminating your script
_IEErrorHandlerRegister ()
; create a visible browser window and navigate to a webpage
$oIE = _IECreate ("www.autoitscript.com")
; get the hwnd of the browser window
$hIE = _IEPropertyGet ($oIE, "hwnd")

_KillExistingIE($hIE, 1)

Func _KillExistingIE($h_hwnd, $w_Kill_Close = 0)
    $w_Winlist = WinList()
    For $i = 1 To $w_Winlist[0][0]
        If StringInStr($w_Winlist[$i][0], "Microsoft Internet Explorer") And $w_Winlist[$i][1] <> $h_hwnd Then
            If $w_Kill_Close = 0 Then
                WinKill($w_Winlist[$i][1])
            Else
                WinClose($w_Winlist[$i][1])
            EndIf
        EndIf
    Next
EndFunc   ;==>_KillExistingIE

Share this post


Link to post
Share on other sites

This should work

#include <IE.au3>

; prevent object error from terminating your script
_IEErrorHandlerRegister ()
; create a visible browser window and navigate to a webpage
$oIE = _IECreate ("www.autoitscript.com")
; get the hwnd of the browser window
$hIE = _IEPropertyGet ($oIE, "hwnd")

_KillExistingIE($hIE, 1)

Func _KillExistingIE($h_hwnd, $w_Kill_Close = 0)
    $w_Winlist = WinList()
    For $i = 1 To $w_Winlist[0][0]
        If StringInStr($w_Winlist[$i][0], "Microsoft Internet Explorer") And $w_Winlist[$i][1] <> $h_hwnd Then
            If $w_Kill_Close = 0 Then
                WinKill($w_Winlist[$i][1])
            Else
                WinClose($w_Winlist[$i][1])
            EndIf
        EndIf
    Next
EndFunc   ;==>_KillExistingIE
Would that work if there were more than one .exe running? I had something similar until I thought about that, and the PID being different.

[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

It worked for me, I opened three different browsers, then ran the script. All but the one that was created were closed.

Share this post


Link to post
Share on other sites

It worked for me, I opened three different browsers, then ran the script. All but the one that was created were closed.

Yeah, I'm sorry, I should have said something... I noticed the StringInStr() with Internet Explorer there, that takes care of that.

[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

thanks!

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