Hello everyone,
First off I'd like to thank all active members on this forum. I'm new to scripting and by using this forum I was able to tackle a lot of problems.
I'd like to ask if it is possible to search for a certain image within a fixed region of an active window? That way I'll counter some occasional false positives and speed up the total script without using tight loops.
Thanks in advance!
Rick
Help: Possibility to use FindImagePos in region of SCREEN?
Moderators: JRL, Dorian (MJT support)
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Help: Possibility to use FindImagePos in region of SCREE
Yes, absolutely. FindImagePos can take SCREEN, or a Window title or a bitmap. That bitmap could be the result of a ScreenCapture of a portion of the screen. So e.g.:
ScreenCapture>x1,y,1,x2,y2,haystack.bmp
FindImagePos>needle,haystack.bmp .....
Just remember to add the origin of the screen capture (x1,y1) to the result of the FindImagePos to translate back to a screen position.
ScreenCapture>x1,y,1,x2,y2,haystack.bmp
FindImagePos>needle,haystack.bmp .....
Just remember to add the origin of the screen capture (x1,y1) to the result of the FindImagePos to translate back to a screen position.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Re: Help: Possibility to use FindImagePos in region of SCREE
Thanks for the quick reply. Sorry in case my question below isn't clear, English is not my native language.
I haven't used the screencapture functionality yet. The following question pops up in mind:
1) The background of my active window is dynamic and changes all the time, so I assume it has to make a new screencapture every time I'd like to use FindImagePos. Are these screencaptures being saved to my project folder or will the script overwrite the old screencapture when i takes a new one?
(edit: Sorry, I might have the solution already)
Thanks Marcus
I haven't used the screencapture functionality yet. The following question pops up in mind:
1) The background of my active window is dynamic and changes all the time, so I assume it has to make a new screencapture every time I'd like to use FindImagePos. Are these screencaptures being saved to my project folder or will the script overwrite the old screencapture when i takes a new one?
(edit: Sorry, I might have the solution already)
Thanks Marcus
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Help: Possibility to use FindImagePos in region of SCREE
Yes you'd need to use ScreenCapture every time - do it immediately prior to your FindImagePos. You specify the path in the ScreenCapture command so it can be wherever you want!
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Re: Help: Possibility to use FindImagePos in region of SCREE
Hi Marcus,
The following part is working:
However, I get a syntax error when i want to use the following MouseMove command in the "Working" (line 32) part:
The error message: Line 32 Invalid Numeric Value for MouseMove command.
Do you see any problems in my code?
The following part is working:
Code: Select all
Screencapture>1582,303,1559,586,%TEMP_DIR%\screenrect.bmp
FindImagePos>here my path to needle file,%TEMP_DIR%\screenrect.bmp,10,1,XArr,YArr,NumFound, CCOEFF
If>NumFound>0
MessageModal>Working
Else
MessageModal>Not Working
EndIf
Exit
Code: Select all
MouseMove>{%XArr_0%+1582},{%YArr_0%+303}
Do you see any problems in my code?
Re: Help: Possibility to use FindImagePos in region of SCREE
ScreenCapture> requires the first X,Y coordinates to be the upper left corner of the rectangle being captured and the second X,Y pair to be the lower right corner of the rectangle being captured. In your code the second X coordinate is smaller than the first x coordinate so there is no rectangle being captured. This will result in a failure for FindImagePos> which will mean there is no value for the variables "XArr_0" and "YArr_0". That all means the MouseMove> will fail with the message " Line 32 Invalid Numeric Value for MouseMove command"
Otherwise your code looks workable. If it were me I'd make sure the MouseMove was inside an If> block that tested for NumFound>0. You have that in the posted code but apparently the MouseMove is not in that If/EndIf block.
Otherwise your code looks workable. If it were me I'd make sure the MouseMove was inside an If> block that tested for NumFound>0. You have that in the posted code but apparently the MouseMove is not in that If/EndIf block.
Re: Help: Possibility to use FindImagePos in region of SCREE
You can't believe how stupid I feel after reading your reply. It solved my problem. Working troughout the night isn't a good thing to do I guess. The MouseMove command is inside the If statement (I try to follow the form of codes on this forum as much as possible. Many thanks!Otherwise your code looks workable. If it were me I'd make sure the MouseMove was inside an If> block that tested for NumFound>0. You have that in the posted code but apparently the MouseMove is not in that If/EndIf block.