Sign in to follow this  
Followers 0
HockeyFan

Active Window Help

13 posts in this topic

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



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

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

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

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

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

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

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

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

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.

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

#10 ·  Posted

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

#11 ·  Posted

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.

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

#12 ·  Posted

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

#13 ·  Posted

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

:)

no problem. always glad to help

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

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