solidacid Posted July 20, 2008 Share Posted July 20, 2008 hey, im making a script for a program, in the program there is a picture, when i hold down ALT the picture changes, i need my script to do a pixelsearch for a certain color(D8B864), then hold down ALT and check if the same pixel still has the same color. if it does, click it. then repeat that(5 times) but start the pixelsearch from the last pixel found. i have some messy code here: func checkforpixel() $amount = 0 $startxline = 75 for $loot = 1 to 5 send("{ALTDOWN}") sleep(30) $maybe = PixelSearch($startxline,65,640,370,"D8B864",0);find the color a the item to click, sleep(100) if not @error then $found = $found + 1 $amount = $amount + 1 send("{ALTUP}");slip {ALT} ;IniWrite("C:\Temp\myfile.ini", $amount, "pixel", $maybe[0] & " " & $maybe[1]) $item = PixelSearch($maybe[0] -1,$maybe[1] -1,$maybe[0] +1,$maybe[1]+1,"D8B864",0);is the color still there? if @error Then;it's not, thats good. send("{ALTDOWN}") mousemove($maybe[0],$maybe[1]) sleep(random(100,120,1)) mouseclick("left") beep(1000, 100) $items = $items +1 endif $startxline = $maybe[0] + 1 send("{ALTUP}") endif next return 0 endfunc im not getting any errors, but the scripts clicks at the wrong places i would appreciate it if someone could modify my script to work OR even better, make a new(less messy) one that does Thanks, Solidacid Link to comment Share on other sites More sharing options...
solidacid Posted July 20, 2008 Author Share Posted July 20, 2008 bumpty any help at all muttley ? Link to comment Share on other sites More sharing options...
d3mon Posted July 20, 2008 Share Posted July 20, 2008 Perhaps because you use Mousemove($maybe[0],$maybe[1]) ; Move to x=$maybe[0] and y=$maybe[0] MouseClick("left") ;Left click on any position No-life of autoit...what could be better ?LAST SCRIPTS WITH AUTO-IT : CLICK HERE Link to comment Share on other sites More sharing options...
d3mon Posted July 20, 2008 Share Posted July 20, 2008 So try this : Func checkforpixel() $amount = 0 $startxline = 75 For $loot = 1 to 5 Send("{ALTDOWN}") Sleep(30) $maybe = PixelSearch($startxline,65,640,370,"D8B864",0);find the color a the item to click, Sleep(100) If not @error then $found = $found + 1 $amount = $amount + 1 Send("{ALTUP}");slip {ALT} ;IniWrite("C:\Temp\myfile.ini", $amount, "pixel", $maybe[0] & " " & $maybe[1]) $item = PixelSearch($maybe[0] -1,$maybe[1] -1,$maybe[0] +1,$maybe[1]+1,"D8B864",0);is the color still there? If @error Then;it's not, thats good. Send("{ALTDOWN}") Mousemove($maybe[0],$maybe[1]) ; Move to x=$maybe[0] and y=$maybe[0] Sleep(random(100,120,1)) MouseClick("left",$maybe[0],$maybe[1],1) ; Click to x=$maybe[0] and y=$maybe[0] and do one click beep(1000, 100) $items = $items +1 Endif $startxline = $maybe[0] + 1 Send("{ALTUP}") Endif Next Return 0 Endfunc No-life of autoit...what could be better ?LAST SCRIPTS WITH AUTO-IT : CLICK HERE Link to comment Share on other sites More sharing options...
solidacid Posted July 20, 2008 Author Share Posted July 20, 2008 (edited) looks promising muttley *Testing* Edited July 20, 2008 by solidacid Link to comment Share on other sites More sharing options...
solidacid Posted July 20, 2008 Author Share Posted July 20, 2008 (edited) im getting these errors: C:\Users\Martin Tandrup\Documents\Autoit\pickup.au3 (23) : ==> Variable used without being declared.: *FIXED C:\Users\Martin Tandrup\Documents\Autoit\pickup.au3 (27) : ==> Subscript used with non-Array variable.: $item = PixelSearch($maybe[0] -1,$maybe[1] -1,$maybe[0] +1,$maybe[1]+1,"D8B864",0) $item = PixelSearch($maybe^ ERROR any ideas? btw, thanks for helping me muttley EDIT: with this exact code: Func pickup() $amount = 0 $startxline = 75 $found = 0 For $loot = 1 to 5 Send("{ALTDOWN}") Sleep(30) $maybe = PixelSearch($startxline,65,640,370,"D8B864",0);find the color a the item to click, Sleep(100) If not @error then $found = $found + 1 $amount = $amount + 1 Send("{ALTUP}");slip {ALT} ;IniWrite("C:\Temp\myfile.ini", $amount, "pixel", $maybe[0] & " " & $maybe[1]) $item = PixelSearch($maybe[0] -1,$maybe[1] -1,$maybe[0] +1,$maybe[1]+1,"D8B864",0);is the color still there? If @error Then;it's not, thats good. Send("{ALTDOWN}") Mousemove($maybe[0],$maybe[1]) ; Move to x=$maybe[0] and y=$maybe[0] Sleep(random(100,120,1)) MouseClick("left",$maybe[0],$maybe[1],1) ; Click to x=$maybe[0] and y=$maybe[0] and do one click beep(1000, 100) $items = $items +1 Endif $startxline = $maybe[0] + 1 Send("{ALTUP}") Endif Next Return 0 Endfunc the script runs to the end without errors but i does not find the pixel nor clicks it the msgboxes tell me that it found 5 pixels of the color but none of them where there after releasing ALT, wich is incorrect(i can see the pixel is there). Edited July 20, 2008 by solidacid Link to comment Share on other sites More sharing options...
solidacid Posted July 20, 2008 Author Share Posted July 20, 2008 for some reason i can't edit my post, so sorry for multiposting. EDIT: with this exact code: msgbox(0, "found:", $found) msgbox(0, "items:", $items) Func pickup() $amount = 0 $startxline = 75 $found = 0 For $loot = 1 to 50 Send("{ALTDOWN}") Sleep(10) $maybe = PixelSearch($startxline,65,640,370,"D8B864",0);find the color a the item to click, Sleep(10) If not @error then $found = $found + 1 $amount = $amount + 1 Send("{ALTUP}");slip {ALT} ;IniWrite("C:\Temp\myfile.ini", $amount, "pixel", $maybe[0] & " " & $maybe[1]) $item = PixelSearch($maybe[0] -1,$maybe[1] -1,$maybe[0] +1,$maybe[1]+1,"D8B864",0);is the color still there? If @error Then;it's not, thats good. Send("{ALTDOWN}") Mousemove($maybe[0],$maybe[1]) ; Move to x=$maybe[0] and y=$maybe[0] Sleep(random(100,120,1)) MouseClick("left",$maybe[0],$maybe[1],1) ; Click to x=$maybe[0] and y=$maybe[0] and do one click beep(1000, 100) $items = $items +1 Endif $startxline = $maybe[0] + 1 Send("{ALTUP}") Endif Next Return 0 Endfunc im getting: C:\Users\Martin Tandrup\Documents\Autoit\pickup.au3 (17) : ==> Subscript used with non-Array variable.: $item = PixelSearch($maybe[0] -1,$maybe[1] -1,$maybe[0] +1,$maybe[1]+1,"D8B864",0) $item = PixelSearch($maybe^ ERROR any ideas? Link to comment Share on other sites More sharing options...
d3mon Posted July 20, 2008 Share Posted July 20, 2008 (edited) im getting these errors: C:\Users\Martin Tandrup\Documents\Autoit\pickup.au3 (23) : ==> Variable used without being declared.: *FIXED C:\Users\Martin Tandrup\Documents\Autoit\pickup.au3 (27) : ==> Subscript used with non-Array variable.: $item = PixelSearch($maybe[0] -1,$maybe[1] -1,$maybe[0] +1,$maybe[1]+1,"D8B864",0) $item = PixelSearch($maybe^ ERROR About Subscript used with non-Array variable that's perhaps because $maybe hasn't found pixel and couldn't have array variable so try IsArray : Func checkforpixel() $amount = 0 $startxline = 75 For $loot = 1 to 5 Send("{ALTDOWN}") Sleep(30) $maybe = PixelSearch($startxline,65,640,370,"D8B864",0);find the color a the item to click, Sleep(100) If IsArray($maybe) =1 Then ;If the pixel has been found $found = $found + 1 $amount = $amount + 1 Send("{ALTUP}");slip {ALT} ;IniWrite("C:\Temp\myfile.ini", $amount, "pixel", $maybe[0] & " " & $maybe[1]) $item = PixelSearch($maybe[0] -1,$maybe[1] -1,$maybe[0] +1,$maybe[1]+1,"D8B864",0);is the color still there? Else;it's not, thats good. Send("{ALTDOWN}") Mousemove($maybe[0],$maybe[1]) ; Move to x=$maybe[0] and y=$maybe[0] Sleep(random(100,120,1)) MouseClick("left",$maybe[0],$maybe[1],1) ; Click to x=$maybe[0] and y=$maybe[0] and do one click beep(1000, 100) $items = $items +1 Endif $startxline = $maybe[0] + 1 Send("{ALTUP}") Endif Next Return 0 Endfunc If the script find some pixel on screen change PixelSearch(40,50,70,60) like this : Edited July 20, 2008 by d3mon No-life of autoit...what could be better ?LAST SCRIPTS WITH AUTO-IT : CLICK HERE Link to comment Share on other sites More sharing options...
solidacid Posted July 20, 2008 Author Share Posted July 20, 2008 (edited) If the script find some pixel on screen change PixelSearch(40,50,70,60) like this : i would but, i dont know where the pixel will be beforehand EDIT: im still getting: C:\Users\Martin Tandrup\Documents\Autoit\pickup.au3 (29) : ==> Subscript used with non-Array variable.: Mousemove($maybe[0],$maybe[1]) Mousemove($maybe^ ERROR muttley btw, sorry for being such a pin in the ass, i just started scripting yesterday. Edited July 20, 2008 by solidacid Link to comment Share on other sites More sharing options...
d3mon Posted July 20, 2008 Share Posted July 20, 2008 I've not error.... $maybe= PixelSearch( 0, 0, 20, 300, 0x000000 ) If IsArray($maybe) =1 Then MsgBox(0, "X and Y are:", $maybe[0] & "," & $maybe[1]) EndIfoÝ÷ Ù8Z·lmçºÇ²¢çh¦,^æ«r"¶¢Z+«Þïj¸¶*'jëh×6PixelSearch($startxline,65,640,370,"D8B864",0)oÝ÷ ØwöÆ޶׫¶hm¸zö««b¢xÊ°j{iº·¢Z+jëh×6PixelSearch($startxline,65,640,370,"D8B864") No-life of autoit...what could be better ?LAST SCRIPTS WITH AUTO-IT : CLICK HERE 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