AJ6594 Posted April 1, 2008 Share Posted April 1, 2008 Func activate1() Local $x = WinList(), $position For $i = 1 to $x[0][0] $position = WinGetPos($x[$i][1],"") If $position[1] = 5 Then WinActivate($x[$i][1],"") EndIf Next EndFunc this kicks back an error ==> Subscript used with non-Array variable.: If $position[1] = 5 Then If $position^ ERROR What is wrong ? Link to comment Share on other sites More sharing options...
Developers Jos Posted April 1, 2008 Developers Share Posted April 1, 2008 First test if the WinGetPos() was successful by testing for @error=0Failure: Returns 0 and sets @error to 1 if windows is not found. 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 More sharing options...
PsaltyDS Posted April 1, 2008 Share Posted April 1, 2008 (edited) Func activate1() Local $x = WinList(), $position For $i = 1 to $x[0][0] $position = WinGetPos($x[$i][1],"") If $position[1] = 5 Then WinActivate($x[$i][1],"") EndIf Next EndFunc this kicks back an error ==> Subscript used with non-Array variable.: If $position[1] = 5 Then If $position^ ERROR What is wrong ? Works fine for me. Try it like this to see if you get some error reporting: activate1() Func activate1() Local $x = WinList(), $position For $i = 1 To $x[0][0] $position = WinGetPos($x[$i][1], "") If IsArray($position) Then ConsoleWrite("$position[1] = " & $position[1] & @LF) If $position[1] = 5 Then WinActivate($x[$i][1], "") EndIf Else MsgBox(16, "Error", "$x[" & $i & "][0] = " & $x[$i][0] & @CRLF & _ "$x[" & $i & "][1] = " & $x[$i][1] & @CRLF & _ "$position = " & $position & " @error = " & @error) EndIf Next EndFunc ;==>activate1 Edit: Beaten by the Jos-bot! Edited April 1, 2008 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now