Sign in to follow this  
Followers 0
allywilson

Array help :-(

5 posts in this topic

hi guys, am having horrible results when trying to setup an array in autoit :-(

Basically, my company is having small recurring issues with users and certain apps.

i've created a simple little script that checks for an active window with the title of e.g. Windows Media Player then shuts it straightaway and loops.

While 1 = 1
WinWaitActive("Windows Media Player")
WinKill("")
Wend

What I'd like to do is have something like

Dim $AnArray
    $AnArray[1] = "Solitaire"
    $AnArray[2] = "Windows Media Player"
    $AnArray[3] = "Calculator"
While 1 = 1
IF WinWaitActive("$AnArray") THEN
WinKill("")
ENDIF
Wend

But I cannot get the syntax correct. I've tried pretty much every format I can think of (I'm not too clued up on AutoIT). The above probably looks like complete gibberish really...The only reference in the autoit handbook isn't very detailed.

Can anyone help? :-(

Ally

Share this post


Link to post
Share on other sites



Dim $AnArray[4]
$AnArray[1] = "Solitaire"
$AnArray[2] = "Windows Media Player"
$AnArray[3] = "Calculator"
While 1 = 1
    For $x = 1 To 3
        If WinWaitActive($AnArray[$x]) Then WinKill($AnArray[$x])
    Next
    Sleep(500)
WEnd


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Dim $AnArray[4]
$AnArray[1] = "Solitaire"
$AnArray[2] = "Windows Media Player"
$AnArray[3] = "Calculator"
While 1 = 1
    For $x = 1 To 3
        If WinWaitActive($AnArray[$x]) Then WinKill($AnArray[$x])
    Next
    Sleep(500)
WEnd
Excellent thanks very much! Another problem though...

The above script doesn't run unless the first window title is activated. If I open calculator first it won't kill it, if I then open solitaire it'll start killing the windows. Any way to change that?

Thanks!

Share this post


Link to post
Share on other sites

Excellent thanks very much! Another problem though...

The above script doesn't run unless the first window title is activated. If I open calculator first it won't kill it, if I then open solitaire it'll start killing the windows. Any way to change that?

Thanks!

Don't worry! Seemed to get around it by changing WinWaitActive to WinActive.

Cheers for the help!

Share this post


Link to post
Share on other sites

Don't worry! Seemed to get around it by changing WinWaitActive to WinActive.

Cheers for the help!

Correct ... didn't concentrate on the Win command... just the array question .. ;)

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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