Sign in to follow this  
Followers 0
blizzedout

Not allow more then 1 of the same windows?

17 posts in this topic

Not allow more then 1 of the same windows? Like lets say there are two IE windows open would the be a way for AI to find out and close one ?

Share this post


Link to post
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".

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

I answered that too. Try reading next time.

Share this post


Link to post
Share on other sites

I answered that too. Try reading next time.

They have the same titles.

Share this post


Link to post
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


[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

$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.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

thanks, I would of never been able to comeup with this lol.

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..

Edited by slightly_abnormal

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

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

[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

I agree Valik... WinKill() might have been a better option there

Vultar, Vulture... and now Valik

???

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Vultar, Vulture... and now Valik

???

8)

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

What are you talking about :)

_ThereCanBeOnlyOne(' Valuater ')

lol

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

_ThereCanBeOnlyOne(' Valuater ')

lol

8)

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

[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

There can be only one High Lander!

Share this post


Link to post
Share on other sites

There can be only one High Lander!

it's easier to call him/her val

Share this post


Link to post
Share on other sites

You didn't get it.

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