Sign in to follow this  
Followers 0

Activating A Random Window

7 posts in this topic

Posted

Well, let's say I have many windows and I want to activate random ones. Those I want to activate have the " - Wnd" string.

In short

let's say i have those windows opened:

"1 - Wnd"

"2 - Wnd"

"3 - Wnd"

"Untitled - Notepad"

"Internet Explorer"

I want to active one of the first three (randomly). How could I do this?

Thanks

Share this post


Link to post
Share on other sites



Posted

Here's a general idea:

- obtain a list of open windows (somehow???)

- put names or handles of windows into an array, say $myWins

- use Random(...) to pick a number 0 to UBound($MyWins)-1

- active the window specified by the randomly generated array element

I don't know how do step one, however :whistle:

Another idea (not tested):

$RndNum = Random(1, 10)
For $i = 1 to $RndNum
   Send("{AltDown}{Tab}{AltUp}")
Next

Good Luck

Share this post


Link to post
Share on other sites

Posted

Here's a general idea:

- obtain a list of open windows (somehow???)

- put names or handles of windows into an array, say $myWins

- use Random(...) to pick a number 0 to UBound($MyWins)-1

- active the window specified by the randomly generated array element

I don't know how do step one, however :whistle:

Another idea (not tested):

$RndNum = Random(1, 10)
For $i = 1 to $RndNum
   Send("{AltDown}{Tab}{AltUp}")
Next

Good Luck

Step one brings up a valid point. We have no way to enumerate windows. At some point, we should probably address that. I think wrapping the API function GetWindow() may be the best method as you can create loops to emulate EnumWindows() and EnumChildWindows() or pretty much find anything in the z-order you want with that function.

Share this post


Link to post
Share on other sites

Posted

WinEnum

and

RegEnumKeys

and/or

RegEnumValues

all go on the wishlist me thinketh...

Lar.

And possibly ProcEnum?

Share this post


Link to post
Share on other sites

Posted

Larry's "proof of concept" should go in the UDF library!

Share this post


Link to post
Share on other sites

Posted

Opt("WinTitleMatchMode",2)

OPT???

Share this post


Link to post
Share on other sites

Posted

Opt() is a new alias for AutoItSetOption(). I guess the name was getting too long. :whistle:

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