AJ6594 Posted December 8, 2007 Share Posted December 8, 2007 I created my first script to help me play poker. Opt("WinTitleMatchMode", 2) $table = Winlist("UB","") For $i = 1 to $table[0][0] $title = $table[$i][0] $position = WinGetPos($title,"") $pixel1 = PixelGetColor( 1300,14 ) $pixel1a = PixelGetColor( 1300,20 ) $pixel2 = PixelGetColor( 1300 , 277 ) $pixel2a = PixelGetColor( 1300 , 283 ) $pixel3 = PixelGetColor( 1300 , 557 ) $pixel3a = PixelGetColor( 1300 , 563 ) $pixel4 = PixelGetColor( 1300 , 905 ) $pixel4a = PixelGetColor( 1300 , 905 ) Select Case ($position[0] = 1300 And $position[1] = 14) Or ($position[0] = 1300 And $position[1] = 277) Or ($position[0] = 1300 And $position[1] = 557) Or ($position[0] = 1300 And $position[1] = 905) MsgBox(0,"Already There","No Movement") Case ($position[0] <> 1300 And $position[1] <> 14) And ($position[0] <> 1300 And $position[1] <> 277) And ($position[0] <> 1300 And $position[1] <> 557) And ($position[0] <> 1300 And $position[1] <> 905) And $pixel1a = 0 MsgBox(0,"pix 1",$pixel1a) WinMove($title,"",1300,14) MsgBox(0,"Slot1","Slot1 was empty, but now filled") Case ($position[0] <> 1300 And $position[1] <> 14) And ($position[0] <> 1300 And $position[1] <> 277) And ($position[0] <> 1300 And $position[1] <> 557) And ($position[0] <> 1300 And $position[1] <> 905) And ($pixel1a <> 0 And $pixel2a = 0) MsgBox(0,"pix 2",$pixel2a) WinMove($title,"",1300,277) MsgBox(0,"Slot2","Slot2 was empty, but now filled") Case ($position[0] <> 1300 And $position[1] <> 14) And ($position[0] <> 1300 And $position[1] <> 277) And ($position[0] <> 1300 And $position[1] <> 557) And ($position[0] <> 1300 And $position[1] <> 905) And ($pixel1a <> 0 And $pixel2a <>0 And $pixel3a = 0) MsgBox(0,"pix 3",$pixel3a) WinMove($title,"",1300,557) MsgBox(0,"Slot3","Slot3 was empty, but now filled") Case ($position[0] <> 1300 And $position[1] <> 14) And ($position[0] <> 1300 And $position[1] <> 277) And ($position[0] <> 1300 And $position[1] <> 557) And ($position[0] <> 1300 And $position[1] <> 905) And ($pixel1a <> 0 And $pixel2a <>0 And $pixel3a <> 0 And $pixel4a = 0) MsgBox(0,"pix 4",$pixel4a) WinMove($title,"",1300,905) MsgBox(0,"Slot4","Slot4 was empty, but now filled") EndSelect Sleep(5000) MsgBox(0,"Loop Complete", "OK") Next Im getting an error : (16) : ==> Subscript used with non-Array variable.: Case ($position[0] = 1300 And $position[1] = 14) Or ($position[0] = 1300 And $position[1] = 277) Or ($position[0] = 1300 And $position[1] = 557) Or ($position[0] = 1300 And $position[1] = 905) Case ($position^ ERROR Link to comment Share on other sites More sharing options...
Developers Jos Posted December 8, 2007 Developers Share Posted December 8, 2007 You need to test the @error returned by WinGetTitle() to ensure it has returned an Array.Failure: Returns 0 and sets @error to 1 if windows is not found.Jos 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...
AJ6594 Posted December 8, 2007 Author Share Posted December 8, 2007 You need to test the @error returned by WinGetTitle() to ensure it has returned an Array. Jos How does this look ? Opt("WinTitleMatchMode", 2) WinWait("UltimateBet","") $UBopen = WinExists("UltimateBet","") While $UBopen = 1 MsgBox(0, "UBopen","Lobby is open") WinWait("UB","") MsgBox(0,"Detected","A game has started",1) $table = Winlist("UB","") For $i = 1 to $table[0][0] $title = $table[$i][0] $position = WinGetPos($title,"") $pixel1 = PixelGetColor( 1300,14 ) $pixel1a = PixelGetColor( 1300,20 ) $pixel2 = PixelGetColor( 1300 , 277 ) $pixel2a = PixelGetColor( 1300 , 283 ) $pixel3 = PixelGetColor( 1300 , 557 ) $pixel3a = PixelGetColor( 1300 , 563 ) $pixel4 = PixelGetColor( 1300 , 905 ) $pixel4a = PixelGetColor( 1300 , 905 ) Select Case ($position[0] = 1300 And $position[1] = 14) Or ($position[0] = 1300 And $position[1] = 277) Or ($position[0] = 1300 And $position[1] = 557) Or ($position[0] = 1300 And $position[1] = 905) MsgBox(0,"Already There","No Movement") Case ($position[0] <> 1300 And $position[1] <> 14) And ($position[0] <> 1300 And $position[1] <> 277) And ($position[0] <> 1300 And $position[1] <> 557) And ($position[0] <> 1300 And $position[1] <> 905) And $pixel1a = 0 WinMove($title,"",1300,14) MsgBox(0,"Slot1","Slot1 was empty, but now filled") Case ($position[0] <> 1300 And $position[1] <> 14) And ($position[0] <> 1300 And $position[1] <> 277) And ($position[0] <> 1300 And $position[1] <> 557) And ($position[0] <> 1300 And $position[1] <> 905) And ($pixel1a <> 0 And $pixel2a = 0) WinMove($title,"",1300,277) MsgBox(0,"Slot2","Slot2 was empty, but now filled") Case ($position[0] <> 1300 And $position[1] <> 14) And ($position[0] <> 1300 And $position[1] <> 277) And ($position[0] <> 1300 And $position[1] <> 557) And ($position[0] <> 1300 And $position[1] <> 905) And ($pixel1a <> 0 And $pixel2a <>0 And $pixel3a = 0) WinMove($title,"",1300,557) MsgBox(0,"Slot3","Slot3 was empty, but now filled") Case ($position[0] <> 1300 And $position[1] <> 14) And ($position[0] <> 1300 And $position[1] <> 277) And ($position[0] <> 1300 And $position[1] <> 557) And ($position[0] <> 1300 And $position[1] <> 905) And ($pixel1a <> 0 And $pixel2a <>0 And $pixel3a <> 0 And $pixel4a = 0) WinMove($title,"",1300,905) MsgBox(0,"Slot4","Slot4 was empty, but now filled") EndSelect Sleep(5000) MsgBox(0,"Loop Complete", "OK") Next WEnd Link to comment Share on other sites More sharing options...
Developers Jos Posted December 8, 2007 Developers Share Posted December 8, 2007 I meant you need to test the @error returned by WinGetPos() ... 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...
manofman Posted December 8, 2007 Share Posted December 8, 2007 How does this look ? Opt("WinTitleMatchMode", 2) WinWait("UltimateBet","") $UBopen = WinExists("UltimateBet","") While $UBopen = 1 MsgBox(0, "UBopen","Lobby is open") WinWait("UB","") MsgBox(0,"Detected","A game has started",1) $table = Winlist("UB","") For $i = 1 to $table[0][0] $title = $table[$i][0] $position = WinGetPos($title,"") $pixel1 = PixelGetColor( 1300,14 ) $pixel1a = PixelGetColor( 1300,20 ) $pixel2 = PixelGetColor( 1300 , 277 ) $pixel2a = PixelGetColor( 1300 , 283 ) $pixel3 = PixelGetColor( 1300 , 557 ) $pixel3a = PixelGetColor( 1300 , 563 ) $pixel4 = PixelGetColor( 1300 , 905 ) $pixel4a = PixelGetColor( 1300 , 905 ) Select Case ($position[0] = 1300 And $position[1] = 14) Or ($position[0] = 1300 And $position[1] = 277) Or ($position[0] = 1300 And $position[1] = 557) Or ($position[0] = 1300 And $position[1] = 905) MsgBox(0,"Already There","No Movement") Case ($position[0] <> 1300 And $position[1] <> 14) And ($position[0] <> 1300 And $position[1] <> 277) And ($position[0] <> 1300 And $position[1] <> 557) And ($position[0] <> 1300 And $position[1] <> 905) And $pixel1a = 0 WinMove($title,"",1300,14) MsgBox(0,"Slot1","Slot1 was empty, but now filled") Case ($position[0] <> 1300 And $position[1] <> 14) And ($position[0] <> 1300 And $position[1] <> 277) And ($position[0] <> 1300 And $position[1] <> 557) And ($position[0] <> 1300 And $position[1] <> 905) And ($pixel1a <> 0 And $pixel2a = 0) WinMove($title,"",1300,277) MsgBox(0,"Slot2","Slot2 was empty, but now filled") Case ($position[0] <> 1300 And $position[1] <> 14) And ($position[0] <> 1300 And $position[1] <> 277) And ($position[0] <> 1300 And $position[1] <> 557) And ($position[0] <> 1300 And $position[1] <> 905) And ($pixel1a <> 0 And $pixel2a <>0 And $pixel3a = 0) WinMove($title,"",1300,557) MsgBox(0,"Slot3","Slot3 was empty, but now filled") Case ($position[0] <> 1300 And $position[1] <> 14) And ($position[0] <> 1300 And $position[1] <> 277) And ($position[0] <> 1300 And $position[1] <> 557) And ($position[0] <> 1300 And $position[1] <> 905) And ($pixel1a <> 0 And $pixel2a <>0 And $pixel3a <> 0 And $pixel4a = 0) WinMove($title,"",1300,905) MsgBox(0,"Slot4","Slot4 was empty, but now filled") EndSelect Sleep(5000) MsgBox(0,"Loop Complete", "OK") Next WEnd an example from help file maybe this will help you to understand $result = myDiv(5, 0) If @error Then MsgBox(4096,"Error", "Division by Zero") Else MsgBox(4096, "Result", $result) EndIf Exit Func myDiv($dividend, $divisor) If $dividend = 0 And $divisor = 0 Then SetError(2) ;indeterminate form 0/0 ElseIf $divisor = 0 Then SetError(1) ;plain division by zero EndIf Return $dividend / $divisor EndFunc Link to comment Share on other sites More sharing options...
AJ6594 Posted December 8, 2007 Author Share Posted December 8, 2007 yea, but I think I fixed the problem altogether. Cant test it right now cause Im at work. I wasnt getting error all the time. I think it was just because there were no tables open, so now I made it wait for tables. But I am a newb, so I wanted some expert eyes on my code...to point out anything that may be strange, ineffecient, or dumb Link to comment Share on other sites More sharing options...
manofman Posted December 8, 2007 Share Posted December 8, 2007 yea, but I think I fixed the problem altogether. Cant test it right now cause Im at work.I wasnt getting error all the time. I think it was just because there were no tables open, so now I made it wait for tables.But I am a newb, so I wanted some expert eyes on my code...to point out anything that may be strange, ineffecient, or dumb Looks logical hehe Link to comment Share on other sites More sharing options...
AJ6594 Posted December 9, 2007 Author Share Posted December 9, 2007 (edited) more to come ...hold on edited Edited December 9, 2007 by AJ6594 Link to comment Share on other sites More sharing options...
AJ6594 Posted December 9, 2007 Author Share Posted December 9, 2007 Opt("WinTitleMatchMode", 2) $UBopen = WinExists("UltimateBet","") $table = Winlist("UB","") For $i = 1 to $table[0][0] $title = $table[$i][0] $position = WinGetPos($title,"") $pixel1a = PixelGetColor( 1300,20 ) $pixel2a = PixelGetColor( 1300 , 283 ) $pixel3a = PixelGetColor( 1300 , 563 ) $pixel4a = PixelGetColor( 1300 , 905 ) Select Case ($position[0] = 1300 And $position[1] = 14) Or ($position[0] = 1300 And $position[1] = 277) Or ($position[0] = 1300 And $position[1] = 557) Or ($position[0] = 1300 And $position[1] = 905) MsgBox(0,"Already There","No Movement",1) Case ($position[0] <> 1300 And $position[1] <> 14) And ($position[0] <> 1300 And $position[1] <> 277) And ($position[0] <> 1300 And $position[1] <> 557) And ($position[0] <> 1300 And $position[1] <> 905) And $pixel1a = 0 WinMove($title,"",1300,14) MsgBox(0,"Slot1","Slot1 was empty, but now filled") Case ($position[0] <> 1300 And $position[1] <> 14) And ($position[0] <> 1300 And $position[1] <> 277) And ($position[0] <> 1300 And $position[1] <> 557) And ($position[0] <> 1300 And $position[1] <> 905) And ($pixel1a <> 0 And $pixel2a = 0) WinMove($title,"",1300,277) MsgBox(0,"Slot2","Slot2 was empty, but now filled") Case ($position[0] <> 1300 And $position[1] <> 14) And ($position[0] <> 1300 And $position[1] <> 277) And ($position[0] <> 1300 And $position[1] <> 557) And ($position[0] <> 1300 And $position[1] <> 905) And ($pixel1a <> 0 And $pixel2a <>0 And $pixel3a = 0) WinMove($title,"",1300,557) MsgBox(0,"Slot3","Slot3 was empty, but now filled") Case ($position[0] <> 1300 And $position[1] <> 14) And ($position[0] <> 1300 And $position[1] <> 277) And ($position[0] <> 1300 And $position[1] <> 557) And ($position[0] <> 1300 And $position[1] <> 905) And ($pixel1a <> 0 And $pixel2a <>0 And $pixel3a <> 0 And $pixel4a = 0) WinMove($title,"",1300,905) MsgBox(0,"Slot4","Slot4 was empty, but now filled") EndSelect Sleep(5000) Next MsgBox(0,"End","Table Mover is Ending") sittl getting the same error as before...i tested $title and $position, they seem to be working fine... please help ty error mssg :16) : ==> Subscript used with non-Array Link to comment Share on other sites More sharing options...
martin Posted December 9, 2007 Share Posted December 9, 2007 Opt("WinTitleMatchMode", 2) $UBopen = WinExists("UltimateBet","") $table = Winlist("UB","") For $i = 1 to $table[0][0] $title = $table[$i][0] $position = WinGetPos($title,"") $pixel1a = PixelGetColor( 1300,20 ) $pixel2a = PixelGetColor( 1300 , 283 ) $pixel3a = PixelGetColor( 1300 , 563 ) $pixel4a = PixelGetColor( 1300 , 905 ) Select Case ($position[0] = 1300 And $position[1] = 14) Or ($position[0] = 1300 And $position[1] = 277) Or ($position[0] = 1300 And $position[1] = 557) Or ($position[0] = 1300 And $position[1] = 905) MsgBox(0,"Already There","No Movement",1) Case ($position[0] <> 1300 And $position[1] <> 14) And ($position[0] <> 1300 And $position[1] <> 277) And ($position[0] <> 1300 And $position[1] <> 557) And ($position[0] <> 1300 And $position[1] <> 905) And $pixel1a = 0 WinMove($title,"",1300,14) MsgBox(0,"Slot1","Slot1 was empty, but now filled") Case ($position[0] <> 1300 And $position[1] <> 14) And ($position[0] <> 1300 And $position[1] <> 277) And ($position[0] <> 1300 And $position[1] <> 557) And ($position[0] <> 1300 And $position[1] <> 905) And ($pixel1a <> 0 And $pixel2a = 0) WinMove($title,"",1300,277) MsgBox(0,"Slot2","Slot2 was empty, but now filled") Case ($position[0] <> 1300 And $position[1] <> 14) And ($position[0] <> 1300 And $position[1] <> 277) And ($position[0] <> 1300 And $position[1] <> 557) And ($position[0] <> 1300 And $position[1] <> 905) And ($pixel1a <> 0 And $pixel2a <>0 And $pixel3a = 0) WinMove($title,"",1300,557) MsgBox(0,"Slot3","Slot3 was empty, but now filled") Case ($position[0] <> 1300 And $position[1] <> 14) And ($position[0] <> 1300 And $position[1] <> 277) And ($position[0] <> 1300 And $position[1] <> 557) And ($position[0] <> 1300 And $position[1] <> 905) And ($pixel1a <> 0 And $pixel2a <>0 And $pixel3a <> 0 And $pixel4a = 0) WinMove($title,"",1300,905) MsgBox(0,"Slot4","Slot4 was empty, but now filled") EndSelect Sleep(5000) Next MsgBox(0,"End","Table Mover is Ending") sittl getting the same error as before...i tested $title and $position, they seem to be working fine... please help ty error mssg :16) : ==> Subscript used with non-Array It was suggested that you should check the result of WinGetPos and you say you have checked $position. I don't see either of these things checked in your code so it is difficult to see how to help. If you are getting the error saying non-Array variable then presumably $position is not an array since it is the only array I have noticed in your script. Therefore WingetPos did not return an array. If you check for that ...well why not just do this $position = WinGetPos($title,"") if not IsArray($position) then continueloop;<-------add this line and see if it helps. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
AJ6594 Posted December 9, 2007 Author Share Posted December 9, 2007 (edited) It was suggested that you should check the result of WinGetPos and you say you have checked $position. I don't see either of these things checked in your code so it is difficult to see how to help. If you are getting the error saying non-Array variable then presumably $position is not an array since it is the only array I have noticed in your script. Therefore WingetPos did not return an array. If you check for that ...well why not just do this$position = WinGetPos($title,"")if not IsArray($position) then continueloop;<-------add this line and see if it helps.ty for the helpim not sure what that line means, but it stops me from crashing.my script is not always recognizing each table. sometimes I can have 4 tables open, and it will only cycle twice, then exitis Auto It just not reliable ? or is there something wrong with the way I am identifying the tables ?(btw, it seems to work best with fewer tables) Edited December 9, 2007 by AJ6594 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