Jump to content

Activating A Random Window


Cerb
 Share

Recommended Posts

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

Link to comment
Share on other sites

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!
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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...

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...