hendricksonet Posted February 18, 2008 Share Posted February 18, 2008 Hey, I have a way of doing this script in a batch file, but I'm wondering if autoit can do it better/faster. I want to close all open IE windows except for the one(s) with certain words in the title bar. With a batch file I can do this: tasklist /v /NH /FO "CSV" | find /I "iexplore" | find /v /I "TITLE GOES HERE" > tasklist.csv for /F "eol=; tokens=2,3* delims=," %%i in (tasklist.csv) do taskkill /F /PID %%i This will create a csv with a list of all open IE apps without the words title goes here in the titlebar, it then closes those. I've looked around and can't seem to find a way of doing this in AutoIt. Any suggestions? Thanks! Eric Link to comment Share on other sites More sharing options...
JustinReno Posted February 18, 2008 Share Posted February 18, 2008 Where have you "looked around"? Link to comment Share on other sites More sharing options...
hendricksonet Posted February 18, 2008 Author Share Posted February 18, 2008 Google, AutoIt functions, etc. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 18, 2008 Moderators Share Posted February 18, 2008 This should close visible and non-visible as well:;Make sure you separate the words that are safe by commas ;It will return the number of windows it closed MsgBox(64, "Info", "Closed: " & _IEKillWins("blah,oops,hey,findme") & " IE Windows.") Func _IEKillWins($sSafeWords);Seperate words by commas Local $aSafe = StringSplit($sSafeWords, ","), $bSafe = False, $nClosed = 0 Local $aIEWins = WinList("[REGEXPTITLE:.*? - Microsoft Internet Explorer]") For $iCC = 1 To UBound($aIEWins) - 1 For $xCC = 1 To $aSafe[0] If StringInStr($aIEWins[$iCC][0], $aSafe[$xCC]) Then $bSafe = True ExitLoop EndIf Next If $bSafe <> True Then WinClose($aIEWins[$iCC][1]) $bSafe = False $nClosed += 1 EndIf Next Return $nClosed EndFuncSafe words should separated by a comma. 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. Link to comment Share on other sites More sharing options...
hendricksonet Posted February 18, 2008 Author Share Posted February 18, 2008 (edited) Thanks, I guess I didn't see that within the WinList you could add a window name....even though right on the documentatino it shows that .... nice. Edited February 18, 2008 by hendricksonet Link to comment Share on other sites More sharing options...
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