Post by cyberchipz on Apr 8, 2022 16:23:36 GMT
It seems that when multiples of the same image exist on a screen. Detect Image finds the first one. OK; I understand that.
When I try to detect image using specified Mouse X & Mouse Y locations; It doesn't detect it; but I wish it would work like screen detect, and use the specified Height and Width parameters as it it was the size of the screen, instead, it looks for the image starting at the X/Y locations and it has to be the exact Mouse X/Mouse Y/Width and Height. This is great, if one can capture the image at that exact location. But, if the image at that exact location is a rare event; but does occur even if rarely. Capturing it without constant monitoring, and even capturing images at that location is extremely time intensive; and depending upon the rarity of the event, neigh on impossible. And yet, it is a critical event. So far, even though I have captured every image at that location, I have been unlucky and have failed to capture the image I want. (I could give my reasons for wanting and needing to do this; but, let's save it for if you need to know. ;-) Basically I'm trying to avoid attacking my teammates when I'm doing an activity with MMM. :-)
THIS WORKS; but, it only detects the first instance of an image.
I could see two possible solutions:
1. Screen capture reporting the locations of every instance of the image; depending on the number of instances, one would need the number of variables of the potential number of instances. Initializing to zero those locations would only contain data indicating the instances found. - Seems unwieldy. I think not.
2. Allow the width and height location to specify an area to search for the image, like a small screen capture where it would seach within the height and width like it would if that was the screen area/size. IOW use the screen capture option, but allow us specify the location of the screen search area with height and width starting at Mouse X&Y. Which is how I was hoping it worked. But, I can't get it to detect the image. Ideally the search width and height should be, within reason, larger than the image size, but less than the entire screen.. or it could be the entire screen. :-)
Screen search works great; but it always only captures the first instance of the image; One could allow the screen capture to search backwards... but, that still would only allow two possible locations for detection.
I think if one modified the code to detect the partial screen area using the same method as it does for the entire screen area; it would solve the issue. One would need to create a line of code for each area to be searched, and it would default to the entire screen; or optionally only a specified area. This should ensure backward compatibility with existing code; and also reduce the overall code to a single routine with user specified parameters for the screen size. IOW Screen capture, but defaulting to entire screen unless width and height parameters are provided; and searching within the width and height only if the parameters were supplied.
Below are three code samples I tried to see if it could find the image.
Sample 1 (line 61), the exact X&Y location and exact width and height are used and of course it found the image; which I captured at a specific location.
But, the image could also appear at one of the other two locations with variations in where the images first starts.
Sample 2 (line 62) could work; but if the image captured was off by a few pixels, it doesn't match exactly, or if the starting location is off or I use a partial image, which should be detected if contained within the area. (I had to use a screen capture of the image at the first position and that was off a little and trimmed part of the image, and it would be detected, if I could start the detection at the exact pixel) and so the match fails at any other location, if the images exists more than once on the screen and not in the original location of the capture.
Sample 3 (line 63) would work, if the IMAGE DETECT worked like searching the entire screen; but instead limits the size of the area being search to less than the entire screen. Then like screen search; which I imagine can have a few false starts if it detects similar pixels in the image; but the code doesn't work like this and at some point fails to detect enough similarity (I suspect because the height and width method requires an exact image.)
Of course line 63 does not work, and neither does line 62 because the starting positions are off. Line 61 works; but only finds the instance in line 61, and line 62 if off by pixels; and line 63 sould find it if it treated the information like it was the size of a "smaller" screen; and uses those methods.
Besides; I think this modification would make the IMAGE DETECT an extremely robust function! :-) Even with screen detect (and partial screen detect) ; as long as the image is unique enough (no repetitious pattern that partially matches the search image); screen detect is quick.
When I try to detect image using specified Mouse X & Mouse Y locations; It doesn't detect it; but I wish it would work like screen detect, and use the specified Height and Width parameters as it it was the size of the screen, instead, it looks for the image starting at the X/Y locations and it has to be the exact Mouse X/Mouse Y/Width and Height. This is great, if one can capture the image at that exact location. But, if the image at that exact location is a rare event; but does occur even if rarely. Capturing it without constant monitoring, and even capturing images at that location is extremely time intensive; and depending upon the rarity of the event, neigh on impossible. And yet, it is a critical event. So far, even though I have captured every image at that location, I have been unlucky and have failed to capture the image I want. (I could give my reasons for wanting and needing to do this; but, let's save it for if you need to know. ;-) Basically I'm trying to avoid attacking my teammates when I'm doing an activity with MMM. :-)
53 | IF | DETECT IMAGE | image path C:\HWFLAGS\GuildFlag2.bmp::match quick::move mouse no::save to vars XPOS YPOS | IMAGE NOT FOUND | GOTO MACRO LINE | Message1
THIS WORKS; but, it only detects the first instance of an image.
I could see two possible solutions:
1. Screen capture reporting the locations of every instance of the image; depending on the number of instances, one would need the number of variables of the potential number of instances. Initializing to zero those locations would only contain data indicating the instances found. - Seems unwieldy. I think not.
2. Allow the width and height location to specify an area to search for the image, like a small screen capture where it would seach within the height and width like it would if that was the screen area/size. IOW use the screen capture option, but allow us specify the location of the screen search area with height and width starting at Mouse X&Y. Which is how I was hoping it worked. But, I can't get it to detect the image. Ideally the search width and height should be, within reason, larger than the image size, but less than the entire screen.. or it could be the entire screen. :-)
Screen search works great; but it always only captures the first instance of the image; One could allow the screen capture to search backwards... but, that still would only allow two possible locations for detection.
I think if one modified the code to detect the partial screen area using the same method as it does for the entire screen area; it would solve the issue. One would need to create a line of code for each area to be searched, and it would default to the entire screen; or optionally only a specified area. This should ensure backward compatibility with existing code; and also reduce the overall code to a single routine with user specified parameters for the screen size. IOW Screen capture, but defaulting to entire screen unless width and height parameters are provided; and searching within the width and height only if the parameters were supplied.
Below are three code samples I tried to see if it could find the image.
Sample 1 (line 61), the exact X&Y location and exact width and height are used and of course it found the image; which I captured at a specific location.
But, the image could also appear at one of the other two locations with variations in where the images first starts.
Sample 2 (line 62) could work; but if the image captured was off by a few pixels, it doesn't match exactly, or if the starting location is off or I use a partial image, which should be detected if contained within the area. (I had to use a screen capture of the image at the first position and that was off a little and trimmed part of the image, and it would be detected, if I could start the detection at the exact pixel) and so the match fails at any other location, if the images exists more than once on the screen and not in the original location of the capture.
Sample 3 (line 63) would work, if the IMAGE DETECT worked like searching the entire screen; but instead limits the size of the area being search to less than the entire screen. Then like screen search; which I imagine can have a few false starts if it detects similar pixels in the image; but the code doesn't work like this and at some point fails to detect enough similarity (I suspect because the height and width method requires an exact image.)
61 | IF | DETECT IMAGE | image path C:\HWFLAGS\GuildFlag1.bmp::at 758 378 58 69::match quick::move mouse no::save to vars XPOS YPOS | IMAGE NOT FOUND | GOTO MACRO LINE | Message3
62 | IF | DETECT IMAGE | image path C:\HWFLAGS\GuildFlag1.bmp::at 1079 464 58 69::match quick::move mouse no::save to vars XPOS YPOS | IMAGE NOT FOUND | GOTO MACRO LINE | Message3
63 | IF | DETECT IMAGE | image path C:\HWFLAGS\GuildFlag1.bmp::at 1079 464 200 200::match quick::move mouse no::save to vars XPOS YPOS | IMAGE NOT FOUND | GOTO MACRO LINE | Message3
Of course line 63 does not work, and neither does line 62 because the starting positions are off. Line 61 works; but only finds the instance in line 61, and line 62 if off by pixels; and line 63 sould find it if it treated the information like it was the size of a "smaller" screen; and uses those methods.
Besides; I think this modification would make the IMAGE DETECT an extremely robust function! :-) Even with screen detect (and partial screen detect) ; as long as the image is unique enough (no repetitious pattern that partially matches the search image); screen detect is quick.