Jump to content

Not allow more then 1 of the same windows?


Recommended Posts

If you start it as a new process (like, click the IE icon on the desktop twice), there will be two IEXPLORE.EXE processes in the task manager. Then, you should have gotten the PID from the Run command that started IE so you can know if there are other IE processes that don't match that PID, and close them. If it just starts a new window (such as a popup), you should get the updated window title/text from the window you want to keep open, and close the rest of the windows that don't have that title and text, but do have "- Microsoft Internet Explorer".

Link to comment
Share on other sites

If you start it as a new process (like, click the IE icon on the desktop twice), there will be two IEXPLORE.EXE processes in the task manager. Then, you should have gotten the PID from the Run command that started IE so you can know if there are other IE processes that don't match that PID, and close them. If it just starts a new window (such as a popup), you should get the updated window title/text from the window you want to keep open, and close the rest of the windows that don't have that title and text, but do have "- Microsoft Internet Explorer".

It just opens up two of the same windows with the same process.
Link to comment
Share on other sites

  • Moderators

$WinNotToRepeat = WinGetHandle('Name - Microsoft Internet Explorer')

While 1
    _AllowOnlyOne($WinNotToRepeat)
    Sleep(100)
WEnd

Func _AllowOnlyOne($SingleWindow)
    $w_Winlist = WinList()
    For $i = 1 To $w_Winlist[0][0]
        If $w_Winlist[$i][0] == WinGetTitle($SingleWindow) And $w_Winlist[$i][1] <> $SingleWindow Then WinClose($w_Winlist[$i][1])
    Next
EndFunc

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

$WinNotToRepeat = WinGetHandle('Name - Microsoft Internet Explorer')

While 1
    _AllowOnlyOne($WinNotToRepeat)
    Sleep(100)
WEnd

Func _AllowOnlyOne($SingleWindow)
    $w_Winlist = WinList()
    For $i = 1 To $w_Winlist[0][0]
        If $w_Winlist[$i][0] == WinGetTitle($SingleWindow) And $w_Winlist[$i][1] <> $SingleWindow Then WinClose($w_Winlist[$i][1])
    Next
EndFunc
thanks, I would of never been able to comeup with this lol.
Link to comment
Share on other sites

I was wondering about that... if it kills internet explorer... then there would be a problem

then i thought about winkill....

Although WinKill can work on both minimized and hidden windows, some windows (notably explorer windows) can only be terminated using WinClose.

at least the explorer would not close

8)

NEWHeader1.png

Link to comment
Share on other sites

  • Moderators

that script is EVIL! first it made it made windows go crazy, and then ate my hotkeys program! zeroed all the keys! :)

I try it without internet explorer open..

LOL... That's kind of funny....

I would think you would put the Acutal Titel in there, not a sub title! (P.S... If you use this, and there is no title that matches, it's probably going to take the title of the first active window.)

I agree Valuater... WinKill() might have been a better option there... Maybe even to make sure the window was visible as an option....This should be safer for the people that don't take precautions before they use an UDF

Dim $WinNotToRepeat = WinGetHandle('Name - Microsoft Internet Explorer')

While 1
    _ThereCanBeOnlyOne($WinNotToRepeat)
    Sleep(100)
WEnd

Func _ThereCanBeOnlyOne($w_High_Lander, $w_Kill_Close = 0, $i_IsVisible = 0); $w_Kill_Close = 0 it will use WinKill if will use WinClose
    If $w_High_Lander <> '' Then
        $w_Winlist = WinList()
        For $i = 1 To $w_Winlist[0][0]
            If $i_IsVisible = 0 Then
                If $w_Winlist[$i][0] == WinGetTitle($w_High_Lander) And $w_Winlist[$i][1] <> $w_High_Lander And BitAnd(WinGetState($w_Winlist[$i][1]), 2) Then 
                    If $w_Kill_Close = 0 Then 
                        WinKill($w_Winlist[$i][1])
                    Else
                        WinClose($w_Winlist[$i][1])
                    EndIf
                EndIf
            Else
                If $w_Winlist[$i][0] == WinGetTitle($w_High_Lander) And $w_Winlist[$i][1] <> $w_High_Lander Then 
                    If $w_Kill_Close = 0 Then 
                        WinKill($w_Winlist[$i][1])
                    Else
                        WinClose($w_Winlist[$i][1])
                    EndIf
                EndIf
            EndIf
        Next
    EndIf
EndFunc
Edited 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.

Link to comment
Share on other sites

  • Moderators

Vultar, Vulture... and now Valik

???

8)

What are you talking about :) Edited 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.

Link to comment
Share on other sites

  • Moderators

_ThereCanBeOnlyOne(' Valuater ')

lol

8)

You like the new function name and parameter name? :) wonder if anyone will get it :mellow: .

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...