Jump to content

Array help :-(


Recommended Posts

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

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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

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

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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