Sign in to follow this  
Followers 0
PcExpert

More WinWaitActive commands at once

12 posts in this topic

Hello,

Is it possible to run more winwaitactive's at once? So the program wont only wait for a window called 'I am here' but it will also wait for a window called 'you are there'.

Thanks!

Share this post


Link to post
Share on other sites



Hello,

Is it possible to run more winwaitactive's at once? So the program wont only wait for a window called 'I am here' but it will also wait for a window called 'you are there'.

Thanks!

No, but you can build a loop with a number of " If WinExists()" in it ....

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Hello,

Is it possible to run more winwaitactive's at once? So the program wont only wait for a window called 'I am here' but it will also wait for a window called 'you are there'.

Thanks!

Write your own function that accepts an array of window titles and loops using WinExists/WinActive to determine if one of the windows exists and is active.

Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

Hello,

Is it possible to run more winwaitactive's at once? So the program wont only wait for a window called 'I am here' but it will also wait for a window called 'you are there'.

Thanks!

Dim $aWins[4] = ['', 'This Window', 'That Window', 'Some Other Window']
_WinWaitMulti($aWins, 5)

Func _WinWaitMulti($aArray, $nTime = 0)
    If IsArray($aArray) = 0 Then Return SetError(1, 0, 0)
    Local $iTimer = TimerInit()
    While 1
        Sleep(100)
        For $iCC = 1 To UBound($aArray) -1
            If WinActive($aArray[$iCC]) Then Return $aArray[$iCC]
        Next
        If $nTime And (TimerDiff($iTimer) / 1000) >= $nTime Then Return SetError(2, 0, 0)   
    WEnd
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

Regex is an option...

Opt('WinTitleMatchMode', 4)
Opt('WinWaitDelay', 2000)
For $i = 1 To 10
    Switch Random(1, 3, 1)
        Case 1
            Run('explorer "' & @ProgramFilesDir & '"')
        Case 2
            Run('explorer "' & @WindowsDir & '"')
        Case 3
            Run('explorer "' & @SystemDir & '"')
    EndSwitch
    If Not WinWaitActive('regexp=(?i)program files|windows|system32', '', 3) Then ExitLoop
    $title = WinGetTitle('regexp=(?i)program files|windows|system32')
    WinClose($title)
Next

:whistle:

Share this post


Link to post
Share on other sites

Hmmm... Nice option MHz... but why not just use $title = WinGetTitle('') after the WinWaitActive()?


[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

Hmmm... Nice option MHz... but why not just use $title = WinGetTitle('') after the WinWaitActive()?

Thanks. :whistle:

Why, cause that leaves an element of risk for another title to jump in on the act. I have not used this regexp concept in reality as Adlib() or a loop with WinExist() normally does ok to cover for multiple windows to target.

Share this post


Link to post
Share on other sites

Thanks. :whistle:

Why, cause that leaves an element of risk for another title to jump in on the act. I have not used this regexp concept in reality as Adlib() or a loop with WinExist() normally does ok to cover for multiple windows to target.

My only concern was that WinGetTitle('') directly is going to get the immediate active window once WinWaitActive() is done and has not failed. However, if I'm reading your regexp right, it's going to get any of those titles (active or not) and close that window (the first one it finds).

[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

My only concern was that WinGetTitle('') directly is going to get the immediate active window once WinWaitActive() is done and has not failed. However, if I'm reading your regexp right, it's going to get any of those titles (active or not) and close that window (the first one it finds).

WinActive() can be used in many more lines of code that can be added but I am not going to go into making a big example out of it just to show that it can work with assurance of handling the correct window. :whistle:

Share this post


Link to post
Share on other sites

WinActive() can be used in many more lines of code that can be added but I am not going to go into making a big example out of it just to show that it can work with assurance of handling the correct window. :whistle:

I tested it... It looks like it went in last active... nice... I love it when I learn something new :P

[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

Is it poosible to do something with winTitlematchmode? Like this: WinWaitActive("this site that site my site")

So it will just wait for a website that has one or more specified keywords?

Share this post


Link to post
Share on other sites

Is it poosible to do something with winTitlematchmode? Like this: WinWaitActive("this site that site my site")

So it will just wait for a website that has one or more specified keywords?

MHz showed you regexp= with Opt('WinTitleMatchMode', 4).... But... I was under the impression that Opt('WinTitleMatchMode', 2) did what you were asking... Is your help file broken again or just being lazy as usual?

[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

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