NELyon Posted June 26, 2006 Posted June 26, 2006 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.
GaryFrost Posted June 26, 2006 Posted June 26, 2006 if you have the pids to the processes you could use process close to kill each individual processhttp://www.autoitscript.com/forum/index.ph...mp;#entry114302http://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.
NELyon Posted June 26, 2006 Author Posted June 26, 2006 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
Moderators SmOke_N Posted June 26, 2006 Moderators Posted June 26, 2006 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 itHighLander 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.
Moderators SmOke_N Posted June 26, 2006 Moderators Posted June 26, 2006 wait... it won't workDid you try to mod it? 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.
Moderators SmOke_N Posted June 26, 2006 Moderators Posted June 26, 2006 (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: noBefore I posted. Edited June 26, 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.
Moderators big_daddy Posted June 26, 2006 Moderators Posted June 26, 2006 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
AutoItKing Posted June 26, 2006 Posted June 26, 2006 You could try my _ShutDown script? http://www.autoitking.co.nr Site is DOWN | My deviantART | No Topic Topic - Don't do it!-------------------- UDF's/Scripts:AutoIt: [BenEditor 3.6] [_ShutDown()]PHP: [CommentScript]Web Based AutoIt: [MemStats] [HTML to AU3] [User LogIn and SignUp script]
Moderators SmOke_N Posted June 26, 2006 Moderators Posted June 26, 2006 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 ;==>_KillExistingIEWould that work if there were more than one .exe running? I had something similar until I thought about that, and the PID being different. 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.
Moderators big_daddy Posted June 26, 2006 Moderators Posted June 26, 2006 It worked for me, I opened three different browsers, then ran the script. All but the one that was created were closed.
Moderators SmOke_N Posted June 26, 2006 Moderators Posted June 26, 2006 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. 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.
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