Sign in to follow this  
Followers 0

Activating A Random Window

7 posts in this topic

#1 ·  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



#2 ·  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


Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

#3 ·  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

#4 ·  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

#6 ·  Posted

Opt("WinTitleMatchMode",2)

OPT???


[quote]I was busy waiting all night for the Columbus Day Bunny to come down my chimney and light fireworks in my pumpkin.There's so much wrong with that.Oh, I'm sorry, i forgot you were Jewish.[/quote]

Share this post


Link to post
Share on other sites

#7 ·  Posted

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


David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

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