I'm automating some inventory management within a PC game that I play. An item will show up with a number in the image, and when that number reaches "4" or "5", I want to take an action (e.g. click and move it to specific position on the screen). It works well in theory, and when I use the Image Capture wizard in a brand new script, it works the first time I capture and run it.
Once the item reaches the "4" trigger again, it will not detect it a 2nd time and fails to recognize the FindImagePos. I'm fairly certain the game is using the same image every time, in the exact same relative screen position (I always run the game in full screen).
Why does it work when I first create it using the capture tool, but when the game starts playing and item numbers are changing, it won't recognize it the second time? How can I view the raw image that the Macro is capturing, to compare it to the save image I am scanning for?
I don't quite understand the Coefficient and Tolerance levels. It is defaulting to 0.7, but I've seen some topics here this can be between 0 and 255?? I've tried adjusting this down and up (not sure which direction to go, it isn't clear) to give a better chance of matching the images.
Here is an example of the items I am watching for:
I capture the actual portion of the image (Just the number) using the Image Capture Tool, then I select for the FindImagePos to search only within this area of the screen (slightly bigger box surrounding the number). Here is the code I am using:
ScreenCapture>1167,167,1189,198,%TEMP_DIR%\screenrect.bmp
//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_2.bmp,%TEMP_DIR%\screenrect.bmp,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>{%XArr_0%+1167},{%YArr_0%+167}
LClick
MouseMove>957,534
LClick
Endif
After creating this script, I can run it successfully. The same item will then go back into the same exact spot, starting with the number 1 and then working it's way back up to 4. I have the correct triggers in place to execute the FindImagePos again once it's at 4 again (the exact same image within the game where it worked previously), but it fails to recognize it. It's driving me crazy Any assistance is appreciated.
FindImagePos stops working after success
Moderators: Dorian (MJT support), JRL
-
- Pro Scripter
- Posts: 70
- Joined: Sun May 03, 2009 11:49 pm
- Location: AU
Re: FindImagePos stops working after success
Try this....
Code: Select all
ScreenCapture>1167,167,1189,198,%TEMP_DIR%\screenrect.bmp
//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_2.bmp,%TEMP_DIR%\screenrect.bmp,15,1,XArr,YArr,NumFound
If>NumFound>0
MouseMove>{%XArr_0%+1167},{%YArr_0%+167}
LClick
MouseMove>957,534
LClick
Else
GetActiveWindow>title,AWX,AWY,AWW,AWH
Let>TopLeftX=%AWX%
Let>TopLeftY=%AWY%
Let>BottRightX={%AWX%+%AWW%}
Let>BottRightY={%AWY%+%AWH%}
ScreenCapture>%TopLeftX%,%TopLeftY%,%BottRightX%,%BottRightY%,%TEMP_DIR%\screenrect.bmp
FindImagePos>%BMP_DIR%\image_2.bmp,%TEMP_DIR%\screenrect.bmp,15,1,XArr,YArr,NumFound
If>NumFound>0
MouseMove>%XArr_0%,%YArr_0%
LClick
EndIf
Endif
Loving MS's Capabilities!!!