Jump to content
Sign in to follow this  
blizzedout

Not allow more then 1 of the same windows?

Recommended Posts

blizzedout

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
greenmachine

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
blizzedout

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
greenmachine

I answered that too. Try reading next time.

Share this post


Link to post
Share on other sites
blizzedout

I answered that too. Try reading next time.

They have the same titles.

Share this post


Link to post
Share on other sites
SmOke_N

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

Share this post


Link to post
Share on other sites
blizzedout

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

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
Valuater

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
SmOke_N

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.

Share this post


Link to post
Share on other sites
Valuater

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
SmOke_N

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.

Share this post


Link to post
Share on other sites
Valuater

What are you talking about :)

_ThereCanBeOnlyOne(' Valuater ')

lol

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
SmOke_N

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

Share this post


Link to post
Share on other sites
greenmachine

There can be only one High Lander!

Share this post


Link to post
Share on other sites
slightly_abnormal

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
greenmachine

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  

×