Styles2304 Posted February 14, 2008 Share Posted February 14, 2008 (edited) Ok . . . this is some code I've written/modified from a users post on a separate forum. It's a macro for afk crafting. Now, what's supposed to happen is, during the setup process, when you click on certain objects, it records the mousepos then uses pixelchecksum to take a temporary screen shot for later comparison. It compares the old checksum with the new and if they're the same, it moves the item and grabs a new one. It's supposed to do this two separate times. However, it appears that the program is firing both parts of the if statement as if there were no criteria to decide which should be activated. Does this make sense? Here is the code (NOTE: I know I can use mouseclickdrag but the particular game doesn't like. Also, I emphasized the problem areas.): expandcollapse popup;StarWarsGalaxies AFK Reverse Engineering Script MsgBox ("48", "Auto 35s", "END = Stop, PAUSE = Pause. Be Sure to have a finished +35 of any order in your first available inventory slot and something crafted with an available slot in the second available inventory slot. Note: You MAY want to pause the Macro after the settup is complete and RE something yourself to use the crafted item, otherwise this program will drop it. Ready?") Sleep ("3000") ;Sets up Pause and Disable keys. Global $Paused HotKeySet("{HOME}", "TogglePause") HotKeySet("{END}", "Terminate") #include <Misc.au3> Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc ;Defines Variables SplashTextOn ( "AFK RE Setup", "Click once on the center of your Main RE Tool", 400, 100, 615, 779, 0, "Ariel", 15 ) While 1 Sleep ( 100 ) If _IsPressed("01") Then $pos = MouseGetPos() ExitLoop EndIf WEnd SplashOff() $mainrex = $pos[0] $mainrey = $pos[1] Sleep ( 1000 ) SplashTextOn ( "AFK RE Setup", "Click once on the center of your JunkLoot RE Tool", 400, 100, 615, 779, 0, "Ariel", 15 ) While 1 Sleep ( 100 ) If _IsPressed("01") Then $pos = MouseGetPos() ExitLoop EndIf WEnd SplashOff() $junkrex = $pos[0] $junkrey = $pos[1] Sleep ( 1000 ) SplashTextOn ( "AFK RE Setup", "Click once on the center of the first available slot (Should be occupied by +35) in your main inventory", 400, 100, 615, 779, 0, "Ariel", 15 ) While 1 Sleep ( 100 ) If _IsPressed("01") Then $pos = MouseGetPos() ExitLoop EndIf WEnd SplashOff() $islot1x = $pos[0] $islot1y = $pos[1] Sleep ( 1000 ) SplashTextOn ( "AFK RE Setup", "Click once on the center of the second available slot (Should be occupied by slotted item) in your main inventory", 400, 100, 615, 779, 0, "Ariel", 15 ) While 1 Sleep ( 100 ) If _IsPressed("01") Then $pos = MouseGetPos() ExitLoop EndIf WEnd SplashOff() $islot2x = $pos[0] $islot2y = $pos[1] Sleep ( 1000 ) SplashTextOn ( "AFK RE Setup", "Click once on the center of your first factory crate.", 400, 100, 615, 779, 0, "Ariel", 15 ) While 1 Sleep ( 100 ) If _IsPressed("01") Then $pos = MouseGetPos() ExitLoop EndIf WEnd SplashOff() $cratex = $pos[0] $cratey = $pos[1] Sleep ( 1000 ) SplashTextOn ( "AFK RE Setup", "Click once anywhere inside the container for finished +35s", 400, 100, 615, 779, 0, "Ariel", 15 ) While 1 Sleep ( 100 ) If _IsPressed("01") Then $pos = MouseGetPos() ExitLoop EndIf WEnd SplashOff() $fincontx = $pos[0] $finconty = $pos[1] Sleep ( 1000 ) SplashTextOn ( "AFK RE Setup", "Click once on the next powerbit in line to be grinded to +35", 400, 100, 615, 779, 0, "Ariel", 15 ) While 1 Sleep ( 100 ) If _IsPressed("01") Then $pos = MouseGetPos() ExitLoop EndIf WEnd SplashOff() $powerbitx = $pos[0] $powerbity = $pos[1] Sleep ( 1000 ) ;PROBLEM AREA --> SplashTextOn ( "AFK RE Setup", "Click once in between the '+' of the +35", 400, 100, 615, 779, 0, "Ariel", 15 ) While 1 Sleep ( 100 ) If _IsPressed("01") Then $pos = MouseGetPos() ExitLoop EndIf WEnd SplashOff() $finishedx = $pos[0] $finishedy = $pos[1] $picturex1 = $finishedx-12 $picturex2 = $finishedx+12 $picturey1 = $finishedy-12 $picturey2 = $finishedy+12 $finished35 = PixelChecksum(($picturex1), ($picturey1), ($picturex2), ($picturey2)) Sleep ( 1000 ) SplashTextOn ( "AFK RE Setup", "Finally, Click on the green text of an item with an available slot.", 400, 100, 615, 779, 0, "Ariel", 15 ) While 1 Sleep ( 100 ) If _IsPressed("01") Then $pos = MouseGetPos() ExitLoop EndIf WEnd SplashOff() $itemx = $pos[0] $itemy = $pos[1] $functionalx1 = $itemx-7 $functionalx2 = $itemx+7 $functionaly1 = $itemy-7 $functionaly2 = $itemy+7 $functional = PixelChecksum(($functionalx1), ($functionaly1), ($functionalx2), ($functionaly2)) Sleep ( 1000 ) ;<-- PROBLEM AREA SplashTextOn("El Fin!", "This concludes the AFK RE Setup. The program will start in 5 seconds... don't forget to run your p-up macros, and enjoy!", 400, 100, 615, 779, 0, "Ariel", 15) Sleep ("5000") SplashOff() ;Moves +35 into +35 Container MouseMove ( $islot1x, $islot1y ) Sleep (200) MouseDown ( "left" ) Sleep (100) MouseMove ( $fincontx, $finconty ) Sleep (200) MouseUp ( "left" ) Sleep (200) ;Destroys RE Item MouseClick ( "right" , $islot1x, $islot1y, 1 ) Sleep (1000) Send ("{3}") Sleep (1000) ;Grabs Powerbit MouseMove ( $powerbitx, $powerbity ) Sleep (200) MouseDown ( "left" ) Sleep (100) MouseMove ( $islot1x, $islot1y ) Sleep (200) MouseUp ( "left" ) Sleep (200) $i = 0 Do ;REs Junk Loot MouseClick ( "right" , $junkrex, $junkrey, 1 ) Sleep (1000) Send ("{5}") Sleep (1000) ;Moves Bits into RE Tool MouseMove ( $islot1x, $islot1y ) Sleep (200) MouseDown ( "left" ) Sleep (100) MouseMove ( $mainrex, $mainrey ) Sleep (200) MouseUp ( "left" ) Sleep (200) MouseMove ( $islot1x, $islot1y ) Sleep (200) MouseDown ( "left" ) Sleep (100) MouseMove ( $mainrex, $mainrey ) Sleep (200) MouseUp ( "left" ) Sleep (200) ;Creates an SEA MouseClick ( "right" , $mainrex, $mainrey, 1 ) Sleep (1000) Send ("{6}") Sleep (1000) ;Grabs Knife from Factory Crate MouseClick ( "right" , $cratex, $cratey, 1 ) Sleep (500) Send ("{1}") Sleep (1000) ;PROBLEM AREA --> ;Checks to see if item is defunct If PixelChecksum(($functionalx1), ($functionaly1), ($functionalx2), ($functionaly2)) = $functional Then Else ;Deletes bad item MouseClick ( "right" , $islot2x, $islot2y, 1 ) Sleep (500) Send ("{3}") Sleep (1000) ;Grabs a new item MouseClick ( "right" , $cratex, $cratey, 1 ) Sleep (500) Send ("{1}") Sleep (1000) EndIf ;<-- PROBLEM AREA ;Attaches SEA to Knife MouseMove ( $islot1x, $islot1y ) Sleep (500) MouseDown ( "left" ) Sleep (100) MouseMove ( $islot2x, $islot2y ) Sleep (500) MouseUp ( "left" ) Sleep (500) ;Says Yes to "Are you sure . . ." Send ("{ENTER}") Sleep (500) ;Moves Knife into RE Tool MouseMove ( $islot1x, $islot1y ) Sleep (500) MouseDown ( "left" ) Sleep (100) MouseMove ( $mainrex, $mainrey ) Sleep (500) MouseUp ( "left" ) Sleep (500) ;REs Knife MouseClick ( "right" , $mainrex, $mainrey, 1 ) Sleep (500) Send ("{5}") Sleep (1000) ;PROBLEM AREA --> ;Checks to see if a 35 has been made If PixelChecksum(($picturex1), ($picturey1), ($picturex2), ($picturey2)) = $finished35 Then ;Moves +35 to finished container MouseMove ( $islot1x, $islot1y ) Sleep (200) MouseDown ( "left" ) Sleep (100) MouseMove ( $fincontx, $finconty ) Sleep (200) MouseUp ( "left" ) Sleep (200) ;Retrieves new powerbit to grind MouseMove ( $powerbitx, $powerbity ) Sleep (200) MouseDown ( "left" ) Sleep (100) MouseMove ( $islot2x, $islot2y ) Sleep (200) MouseUp ( "left" ) Sleep (200) Else EndIf ;<-- PROBLEM AREA ;Re-Fires PUPs Send ("{3}") Sleep (200) Send ("{4}") Sleep (200) Send ("{5}") Sleep (200) Until $i = 1 Edited February 14, 2008 by Styles2304 Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 14, 2008 Share Posted February 14, 2008 This has been covered many times before. PixelChecksum() is not, and never was, useful for OCR, sprite recognition, or graphic interpretation. Its only use is to detect any short term change in a portion of the screen. It is not useful to store a pixel checksum value for any length of time because, as you found, it will not give the same value next time you run it. 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...
Styles2304 Posted February 15, 2008 Author Share Posted February 15, 2008 This has been covered many times before. PixelChecksum() is not, and never was, useful for OCR, sprite recognition, or graphic interpretation. Its only use is to detect any short term change in a portion of the screen. It is not useful to store a pixel checksum value for any length of time because, as you found, it will not give the same value next time you run it. I apologize for letting my newbish tendencies get in the way of me using the search button. Do you have any advice or guidance as far as a solution for what I'm trying to accomplish. I thought about using pixel colors but the cursor isn't specific enough to get in a certain spot everytime.I apologize again for this but I don't really know enough about what I'm needing to do to know what to search for. Link to comment Share on other sites More sharing options...
Styles2304 Posted February 15, 2008 Author Share Posted February 15, 2008 Just so we're on the same page. What's happening is as you craft the item, it's number increases. Once it reaches 35, the item is complete. I need to be able to tell when the item reaches 35 so I can execute certain code. Also, there are items that are occasionally dud items. To the naked eye, good items are neon green, dud items are white, but the pixels vary so much . . . I'm at a stand still until someone can at least point me in the right direction. Link to comment Share on other sites More sharing options...
CodeMaster Rapture Posted February 15, 2008 Share Posted February 15, 2008 PixelSearch might be a better solution to the "quality" issue. Take a look at the help files and note the Shades variable. Something like: $pos = PixelSearch($itemX1,$itemY1,$itemX2,$itemY2,$Green,$Shades,$Step) If (not @error) Then MsgBox(0,"Green!", "Item is green!") Else $pos = PixelSearch($itemX1,$itemY1,$itemX2,$itemY2,$White,$Shades,$Step) If (not @error) Then MsgBox(0,"White!", "Item is white!") EndIf EndIf Alot of code for something so simple, but if it works... -CMR Link to comment Share on other sites More sharing options...
martin Posted February 15, 2008 Share Posted February 15, 2008 This has been covered many times before. PixelChecksum() is not, and never was, useful for OCR, sprite recognition, or graphic interpretation. Its only use is to detect any short term change in a portion of the screen. It is not useful to store a pixel checksum value for any length of time because, as you found, it will not give the same value next time you run it. I didn't know that. Why doesn't it return the same value if the display is identical, or do you mean the display is not going to be identical because you cannot be sure the sprite or whatever is in exactly the same position? 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...
Styles2304 Posted February 15, 2008 Author Share Posted February 15, 2008 I tried pixel search but forgot about the shades so I'll try that. Martin: I have no idea why it doesn't return because the sprites are in the exact same position and the display SHOULD be identical. As far as I know, someone HAS used this for this same function and it has been confirmed to work. That's why I posted here, I figured there was something wrong with my syntax. Like I said, I'll try the pixelsearch but that will only work for determining whether or not the item is a dud. Any ideas how to tell when the item is "+35" as opposed to "+27"? 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