Jeffrey1988 Posted January 22, 2007 Share Posted January 22, 2007 hi there, I made a script for a game that searches for a red dot on a radar, if there isn't a red dot on the given area then the code starts to press on the right keyboard button until it sees a red dot below you can see the code I made for this (NOTE: the message box in the code is only for testing if the code actually did work) expandcollapse popupOpt("ColorMode",1) $aPixelSearch = PixelSearch(943,658,950,716,0x303AF8,0) If @error Then send ( "{right}" ) autoitsetoption ( "sendkeydowndelay", 100 ) else MsgBox(0, "X and Y are:", $aPixelSearch[0] & "," & $aPixelSearch[1]) EndIf oÝ÷ ÚØ^¦ºé¡£¯z¸¬¶"wvÚ+z¶Ø^¦,^ÇÈ_ºw-ÛyÆ®±ì!zzkzË" âmç(uë-¢,q©çx-æ«y¤ájÝý³r!ÈZ¶¡×¢Ø^¢wzZ0jëh×6 Opt("ColorMode",1) $aPixelSearch = PixelSearch(943,658,950,716,0x303AF8,0) If @error Then send ( "{right}" ) autoitsetoption ( "sendkeydowndelay", 100 ) $aPixelSearch = PixelSearch(943,658,950,716,0x303AF8,0) If @error Then send ( "{right}" ) autoitsetoption ( "sendkeydowndelay", 100 ) $aPixelSearch = PixelSearch(943,658,950,716,0x303AF8,0) If @error Then send ( "{right}" ) autoitsetoption ( "sendkeydowndelay", 100 ) $aPixelSearch = PixelSearch(943,658,950,716,0x303AF8,0) If @error Then send ( "{right}" ) autoitsetoption ( "sendkeydowndelay", 100 ) $aPixelSearch = PixelSearch(943,658,950,716,0x303AF8,0) If @error Then send ( "{right}" ) autoitsetoption ( "sendkeydowndelay", 100 ) $aPixelSearch = PixelSearch(943,658,950,716,0x303AF8,0) If @error Then send ( "{right}" ) autoitsetoption ( "sendkeydowndelay", 100 ) else MsgBox(0, "X and Y are:", $aPixelSearch[0] & "," & $aPixelSearch[1]) EndIf else MsgBox(0, "X and Y are:", $aPixelSearch[0] & "," & $aPixelSearch[1]) EndIf else MsgBox(0, "X and Y are:", $aPixelSearch[0] & "," & $aPixelSearch[1]) EndIf else MsgBox(0, "X and Y are:", $aPixelSearch[0] & "," & $aPixelSearch[1]) EndIf else MsgBox(0, "X and Y are:", $aPixelSearch[0] & "," & $aPixelSearch[1]) EndIf else MsgBox(0, "X and Y are:", $aPixelSearch[0] & "," & $aPixelSearch[1]) EndIf My question: Is it possible to loop this code somehow , that even when the code presses the right button it still does a pixelsearch? Best regards, Jeffrey Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 22, 2007 Moderators Share Posted January 22, 2007 (edited) Opt('SendKeyDownDelay', 100) Opt('ColorMode', 1) $aPixelSearch = PixelSearch(943,658,950,716,0x303AF8) While @error $aPixelSearch = PixelSearch(943,658,950,716,0x303AF8) Send('{RIGHT}') Sleep(10) WEnd MsgBox(0, "X and Y are:", $aPixelSearch[0] & "," & $aPixelSearch[1]) Edit:! Edited January 22, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Jeffrey1988 Posted January 22, 2007 Author Share Posted January 22, 2007 Opt('SendKeyDownDelay', 100) Opt('ColorMode', 1) $aPixelSearch = PixelSearch(943,658,950,716,0x303AF8) While @error $aPixelSearch = PixelSearch(943,658,950,716,0x303AF8) Send('{RIGHT}') Sleep(10) WEnd MsgBox(0, "X and Y are:", $aPixelSearch[0] & "," & $aPixelSearch[1]) Edit:! Thanks for the fast reply, but it doesn't work it gives me a error MsgBox(0, "X and Y are:", $aPixelSearch[0] & "," & $aPixelSearch[1]) MsgBox(0, "X and Y are:", $aPixelSearch^ERROR Error: Subscript used with non-Array variable. I tried to edit the script but I keep getting the same error Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 22, 2007 Moderators Share Posted January 22, 2007 Try this then (It's an all nighter for me) While Not @error $aPixelSearch = PixelSearch(943,658,950,716,0x303AF8) Send('{RIGHT}') Sleep(10) WEnd MsgBox(0, "X and Y are:", $aPixelSearch[0] & "," & $aPixelSearch[1]) Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Jeffrey1988 Posted January 23, 2007 Author Share Posted January 23, 2007 Try this then (It's an all nighter for me) While Not @error $aPixelSearch = PixelSearch(943,658,950,716,0x303AF8) Send('{RIGHT}') Sleep(10) WEnd MsgBox(0, "X and Y are:", $aPixelSearch[0] & "," & $aPixelSearch[1])It's still giving the same error somehow , I've been trying to figure out how to get it work but it just wont. I tried Do and Until functions but nothing seems to work.Perhaps I should do it on a totally different way?The script only has to search for a red dot on a given area,if on that area isn't a red dot then the script needs to keep pressing right until the red dot appears on the given area.I hope someone can come up with perhaps a totally new script? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 23, 2007 Moderators Share Posted January 23, 2007 Opt('SendKeyDownDelay', 100) Opt('ColorMode', 1) $aPixelSearch = PixelSearch(943,658,950,716,0x303AF8) If @error Then While @error $aPixelSearch = PixelSearch(943,658,950,716,0x303AF8) Send('{RIGHT}') Sleep(10) WEnd EndIf MsgBox(0, "X and Y are:", $aPixelSearch[0] & "," & $aPixelSearch[1]) Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
herewasplato Posted January 23, 2007 Share Posted January 23, 2007 @error is cleared by the sendOpt('SendKeyDownDelay', 100) Opt('ColorMode', 1) $aPixelSearch = PixelSearch(943, 658, 950, 716, 0x303AF8) If @error Then Do Send('{RIGHT}') Sleep(10) $aPixelSearch = PixelSearch(943, 658, 950, 716, 0x303AF8) Until Not @error EndIf MsgBox(0, "X and Y are:", $aPixelSearch[0] & "," & $aPixelSearch[1]) [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 23, 2007 Moderators Share Posted January 23, 2007 (edited) @error is cleared by the sendOpt('SendKeyDownDelay', 100) Opt('ColorMode', 1) $aPixelSearch = PixelSearch(943, 658, 950, 716, 0x303AF8) If @error Then Do Send('{RIGHT}') Sleep(10) $aPixelSearch = PixelSearch(943, 658, 950, 716, 0x303AF8) Until Not @error EndIf MsgBox(0, "X and Y are:", $aPixelSearch[0] & "," & $aPixelSearch[1])oÝ÷ Ûú®¢×k+¦NßÛ0«Hë_¢¹Þ½êízËb +$x-«'q«Gb´hmºË®±ç«®ß¢·îËb¢{-«kzÛ« ëk+"³r"G©¶Ç+{§+n¥ú+ë"ÇjÊÇ^rV«zl¯j¸nW¬Ü(ºWaj÷yéí+ºÚ"µÍÜ ÌÎNÔÙ[Ù^QÝÛ[^IÌÎNËL BÜ ÌÎNÐÛÛÜ[ÙIÌÎNËJBØØ[ ÌÍØT^[ÙXÚ ÌÍØT^[ÙXÚH^[ÙXÚ MË NML ÌMÌÐQ BÙ[ ÌÎNÞÔQÒIÌÎNÊBÛY L B[[Ð^J ÌÍØT^[ÙXÚ BÙÐÞ ][ÝÖ[HN][ÝË ÌÍØT^[ÙXÚÌH [È ][ÝË ][ÝÈ [È ÌÍØT^[ÙXÚÌWJ Edited January 23, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Glyph Posted January 23, 2007 Share Posted January 23, 2007 (edited) On a side note, why do people insist to ignore the "search" feature of the forums.... i have recently had the same problem and had it resolved... Edited January 23, 2007 by backstabbed tolle indicium Link to comment Share on other sites More sharing options...
Jeffrey1988 Posted January 23, 2007 Author Share Posted January 23, 2007 thanks allot it works now Link to comment Share on other sites More sharing options...
Jeffrey1988 Posted January 23, 2007 Author Share Posted January 23, 2007 (edited) On a side note, why do people insist to ignore the "search" feature of the forums.... i have recently had the same problem and had it resolved...I did, but couldn't find it with the search option Edited January 23, 2007 by Jeffrey1988 Link to comment Share on other sites More sharing options...
Glyph Posted January 23, 2007 Share Posted January 23, 2007 Oh, then forget i said anything tolle indicium 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