Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Activating A Random Window


  • Please log in to reply
6 replies to this topic

#1 Cerb

Cerb

    Seeker

  • Active Members
  • 13 posts

Posted 23 February 2004 - 01:31 AM

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







#2 CyberSlug

CyberSlug

    Overwhelmed with work....

  • MVPs
  • 3,587 posts

Posted 23 February 2004 - 04:36 AM

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!

#3 Valik

Valik

    Former developer.

  • Active Members
  • PipPipPipPipPipPip
  • 18,879 posts

Posted 23 February 2004 - 05:22 AM

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.

#4 Valik

Valik

    Former developer.

  • Active Members
  • PipPipPipPipPipPip
  • 18,879 posts

Posted 23 February 2004 - 06:03 AM

WinEnum

and

RegEnumKeys
and/or
RegEnumValues

all go on the wishlist me thinketh...

Lar.

And possibly ProcEnum?

#5 CyberSlug

CyberSlug

    Overwhelmed with work....

  • MVPs
  • 3,587 posts

Posted 23 February 2004 - 06:16 AM

Larry's "proof of concept" should go in the UDF library!
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

#6 MattNis

MattNis

    Adventurer

  • Active Members
  • PipPip
  • 108 posts

Posted 23 February 2004 - 04:11 PM

Opt("WinTitleMatchMode",2)


OPT???

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.


#7 Nutster

Nutster

    Developer at Large

  • Developers
  • 1,450 posts

Posted 23 February 2004 - 04:19 PM

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





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users