Jump to content
Sign in to follow this  
HockeyFan

Active Window Help

Recommended Posts

HockeyFan

HELP! :)

How do I make an active window always stay the topmost active window, even if something else is clicked on the Desktop?

:(

Share this post


Link to post
Share on other sites
seandisanti

HELP! :)

How do I make an active window always stay the topmost active window, even if something else is clicked on the Desktop?

:(

easy way:

Opt("WinTitleMatchMode",4)
$aw = WinGetTitle("active")
While 1
    If WinExists($aw) And Not WinActive($aw) Then WinActivate($aw)
    Sleep(10)
WEnd

Share this post


Link to post
Share on other sites
HockeyFan

easy way:

Opt("WinTitleMatchMode",4)
$aw = WinGetTitle("active")
While 1
    If WinExists($aw) And Not WinActive($aw) Then WinActivate($aw)
    Sleep(10)
WEnd
Thank you!!! :)

Share this post


Link to post
Share on other sites
HockeyFan

Thank you!!! :(

:)

Ooops...what if I already have Opt("WinTitleMatchMode",3) in my script? Will it only work under option 4?

Thanks for your help. :D

Share this post


Link to post
Share on other sites
HockeyFan

Also...can you call a Function from within a Function?

I already have a Function call running when the window in question is active.

Thanks again for your help! :)

Share this post


Link to post
Share on other sites
HockeyFan

easy way:

Opt("WinTitleMatchMode",4)
$aw = WinGetTitle("active")
While 1
    If WinExists($aw) And Not WinActive($aw) Then WinActivate($aw)
    Sleep(10)
WEnd

Ooops...what if I already have Opt("WinTitleMatchMode",3) in my script? Will it only work under option 4?

Thanks for your help.

Share this post


Link to post
Share on other sites
HockeyFan

easy way:

Opt("WinTitleMatchMode",4)
$aw = WinGetTitle("active")
While 1
    If WinExists($aw) And Not WinActive($aw) Then WinActivate($aw)
    Sleep(10)
WEnd
Also...can you call a Function from within a Function?

I already have a Function call running when the window in question is active.

Thanks again for your help!

Share this post


Link to post
Share on other sites
RobM

easy way:

Opt("WinTitleMatchMode",4)
$aw = WinGetTitle("active")
While 1
    If WinExists($aw) And Not WinActive($aw) Then WinActivate($aw)
    Sleep(10)
WEnd
Very timely information. I came here to search for this and found it -- Posted today, thanks cameronsdad!

Share this post


Link to post
Share on other sites
seandisanti

Ooops...what if I already have Opt("WinTitleMatchMode",3) in my script? Will it only work under option 4?

option 4 allows for the "active" substitution in the WinGetTitle("active"). assuming you already know the title of your window, you can just assign that value to the variable, or use the literal string in your WinActive() check. so you don't need to set the option to 4

Also...can you call a Function from within a Function?

yes, you can call a function from within a function, but i think what you're really asking is can you put this loop into another loop; if this while loop never exits, the outer loop will never continue, effectively hanging your program indefinitely. what you want to do, is just take the statements from inside the sample loop, and toss them into your current loop. that way the check is still performed while the other while loop is running, but you're not killing your script with a never ending loop.

Very timely information. I came here to search for this and found it -- Posted today, thanks cameronsdad!

no problem, always glad to help.

Share this post


Link to post
Share on other sites
HockeyFan

yes, you can call a function from within a function, but i think what you're really asking is can you put this loop into another loop; if this while loop never exits, the outer loop will never continue, effectively hanging your program indefinitely. what you want to do, is just take the statements from inside the sample loop, and toss them into your current loop. that way the check is still performed while the other while loop is running, but you're not killing your script with a never ending loop.

no problem, always glad to help.

Thanks for the info, but I'm still a little confused. My original loop is this:

While 1
  Sleep(1000) ; Idle around
WEnd

Do you mean add the sample loop you gave me into the above loop, like this?

While 1
  Sleep(1000) ; Idle around
  $aw = WinGetTitle("New Connection Wizard")
        While 1
              If WinExists($aw) And Not WinActive($aw) Then WinActivate($aw)
              Sleep(10)
        WEnd
WEnd

:"> Thanks!

Share this post


Link to post
Share on other sites
seandisanti

Thanks for the info, but I'm still a little confused. My original loop is this:

While 1
  Sleep(1000); Idle around
WEnd

Do you mean add the sample loop you gave me into the above loop, like this?

While 1
  Sleep(1000); Idle around
  $aw = WinGetTitle("New Connection Wizard")
        While 1
              If WinExists($aw) And Not WinActive($aw) Then WinActivate($aw)
              Sleep(10)
        WEnd
WEnd

:"> Thanks!

actually, that's precisely what we're trying to avoid, remove the nested "while 1" and "WEnd" and just leave the body of the loop. you also shouldn't need the sleep(10) sincce you already have a sleep in the only while loop that will be left.

Share this post


Link to post
Share on other sites
HockeyFan

actually, that's precisely what we're trying to avoid, remove the nested "while 1" and "WEnd" and just leave the body of the loop. you also shouldn't need the sleep(10) sincce you already have a sleep in the only while loop that will be left.

Thank you...that makes sense...and it works. Thanks so much for your help.

:)

Share this post


Link to post
Share on other sites
seandisanti

Thank you...that makes sense...and it works. Thanks so much for your help.

:)

no problem. always glad to help

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  

×