|
Post by mrclicker on Jul 29, 2021 15:53:39 GMT
Hi, I am struggling with the "mouse to image" and "detect image" features. I want my macro to wait untill it detects the image in a certain area, then click in the centre of it and continue with the macro. I am testing it by adding the line : 1 | IF | DETECT IMAGE | image path D:\test.bmp::at 442 252 400 401::match quick::move mouse yes | IMAGE FOUND | CONTINUE The logic I am testing here is "If the image: test.bmp can be matched anywhere between 442,252 and 842,453 then continue.." I took a screen clipping of the image I am looking for with in that range, i pasted it in to paint, and cropped it so there is no margins apart from the small image, and saved it as D:\test.bmp I run the macro, and trigger the screen to show that image and the macro never continues. Can any one help me with the syntax ? Or why this is happening , and more important of all - how do I get this to work ? Thanks ps. when i tab between the X,Y,width,hight of the "detect image condition" dialogue box i am getting an unhandled exception saying cant convert string to integer but if i hit continue it allows me to complete the entries. i opened a bug report for it . i dont think its related to the fail but am putting it in here for completeness
|
|
|
Post by mrclicker on Jul 29, 2021 15:58:14 GMT
this line:
1 | IF | DETECT IMAGE | image path D:\test.bmp::match quick::move mouse yes | IMAGE FOUND | CONTINUE
also fails
|
|
|
Post by zeak on Jul 30, 2021 2:54:36 GMT
this line: 1 | IF | DETECT IMAGE | image path D:\test.bmp::match quick::move mouse yes | IMAGE FOUND | CONTINUE also fails Hi MrClicker, just our of curiosity, have to tried the image path in a different drive location? and have to you tried match full? Does your image contain any transparent parts that might change?
|
|
|
Post by mrclicker on Jul 30, 2021 11:20:08 GMT
tried it now - no change.
tried both full screen or section - still fails.
there is nothing PARTIALLY transparent that i can see, no.
By way of update i just discovered the #TEST button on the "Detect image - Configure" box. and when i use that, the mouse jumps to the centre of the image no problems.
However, when i close and save the macro, and then run it, the macro runs indefinitely and even when i keep triggering that test image. it doesn't pass that line.
Any thoughts on why the test option detects the image but the macro doesn't seem to ?
|
|
|
Post by Steve on Jul 30, 2021 22:35:05 GMT
By way of update i just discovered the #TEST button on the "Detect image - Configure" box. and when i use that, the mouse jumps to the centre of the image no problems. However, when i close and save the macro, and then run it, the macro runs indefinitely and even when i keep triggering that test image. it doesn't pass that line. Any thoughts on why the test option detects the image but the macro doesn't seem to ?
If the #TEST finds the image and moves the mouse then it should very well find the image during playback. This might be a silly question but I have to ask, are you sure the image exist on screen when you play the macro? I mean, it just should work.
The reason why the image shouldn't match are the things that zeak covered off on. 1. The image isn't found on the screen 2. The image has transparency 3. The image file is write protected and can't be loaded (however MMM spews out some errors to the MMM event log when this happens)
4. The image is not a bitmap
5. The image has been presented to the screen by an image viewer that changes the bitmap pixel layout slightly
As I type this I figure number 5 might be the problem. How are you presenting this image to the screen? Some image viewers load the image and change the size slightly to match the viewer. Could this be happening? How does the image from your file look as a pixel variable when loaded into MMM?
Try this. Build a DEFINE PIXEL RANGE variable and select to load the var from the image file, click on the beaker (bottom left) in the 'Define Pixel Range' dialog box to load the variable in, and then click on the 'image' picture (next to the beaker).
|
|
|
Post by mrclicker on Aug 3, 2021 13:46:38 GMT
thanks for the reply.. yeah i am a bit confused myself i think it is , otherwise the test wouldnt have found it. you mean the image in the screen? or the image i saved and am using as the image to look for? either way, i dont think there is. is there a way to test for this ? i dont think thats the case (and again, the test is working so it must be able to read it then. there are no errors in the log Definitely saved as bmp i dont understand this option. can you explain that in more details (and make it simpler for a simpleton like myself to understand ? again.. not folowing this bit, apologies, but can you explain that again?
|
|
|
Post by mrclicker on Aug 3, 2021 13:59:42 GMT
ok, perhaps i should have tried a bit harder to follow the instructions now i did.. and when i load the image from file during the define pixel range, i get to see the image and the following variables: %PIXEL_RANGE%: 0
%PIXEL_RANGE.XPOS%: 0
%PIXEL_RANGE.YPOS%: 0
%PIXEL_RANGE.WIDTH%: 243
%PIXEL_RANGE.HEIGHT%: 62
%PIXEL_RANGE.TIME%: 14:54:31
%PIXEL_RANGE.DATE%: 03/08/2021 what does that mean ?
|
|
|
Post by mrclicker on Aug 3, 2021 16:24:10 GMT
so a bit more info might help. the image i am saving is a 96DPI, 24bit bmp image. its 82pixels by 19. (saved from WIN+SHIFT+S screen clipping that is pasted, cropped and saved via paint) My screen settings: the image appears on a few locations on the page, and when i test on full screen it detects one but not another . a few questions.. 1. does the image have to be *.bmp ? 2. if i save the image as 24bit bmp and my screen's colour depth is set to 32 does that matter ? 3. is there a way to tweek how accurate a match the image needs to be ?
|
|
|
Post by Steve on Aug 4, 2021 21:33:15 GMT
you mean the image in the screen? or the image i saved and am using as the image to look for? either way, i dont think there is. is there a way to test for this ? i dont understand this option. can you explain that in more details (and make it simpler for a simpleton like myself to understand ? 2. I'm not sure how to test for this. Transparency is when parts of the image may be 'see through'. Transparent images often blend into the background. For example, the big "Mini Mouse Macro" logo at the top of the forum page is transparent and blends into the blue background tile at the top. If I were to try and detect this image with MMM I would need to save this image as a bmp image and loose the transparency.
5. How the image is presented on screen matters. The image from the file must be the same pixel by pixel as it is presented on screen. The image within the file will always be loaded as a bitmap pixel array however on screen when it is not always the same. How are you seeing the image on screen to compare it? Is it in a web browser? Is it using an image viewer? Is it in a game? Is it on the desktop background? It matters because we are at the mercy of how the image is rendered by anyone of these. I know if I use windows image viewer to open a bitmap It may stretch the bitmap pixel layout to match the border of the viewer. This 'stretching' is bad because it changes the pixel mapping. Stretching the image to match the viewer border means it no longer looks exactly pixel by pixel as it did in the file. I hope this explains what I mean.
ok, perhaps i should have tried a bit harder to follow the instructions now i did.. and when i load the image from file during the define pixel range, i get to see the image and the following variables: %PIXEL_RANGE%: 0 %PIXEL_RANGE.XPOS%: 0 %PIXEL_RANGE.YPOS%: 0 %PIXEL_RANGE.WIDTH%: 243 %PIXEL_RANGE.HEIGHT%: 62 %PIXEL_RANGE.TIME%: 14:54:31 %PIXEL_RANGE.DATE%: 03/08/2021 what does that mean ? This means that the PIXEL_RANGE variable you defined has content and loaded your pixel range. the image i am saving is a 96DPI, 24bit bmp image. its 82pixels by 19. (saved from WIN+SHIFT+S screen clipping that is pasted, cropped and saved via paint) the image appears on a few locations on the page, and when i test on full screen it detects one but not another . a few questions.. 1. does the image have to be *.bmp ? 2. if i save the image as 24bit bmp and my screen's colour depth is set to 32 does that matter ? 3. is there a way to tweek how accurate a match the image needs to be ? 1. Yes but technically no. YES because the closer we can get to a bitmap pixel mapping the better. MMM takes the image and converts it to a bitmap pixel array. BMP files are most likely to have the greatest chance of success here for a positive true match. NO because i've had success with jpg and some other image formats during my testing. However I strongly recommend true BMP bitmap files.
2. No that doesn't matter. I replicated your WIN+SHIFT+S - crop in paint - save as 24bit bmp and had success in matching with the macro. I did notice it prompted for transparency when I saved it in paint. If the image is transparent we will never get a match. So at that option I said 'no' to transparency.
3. Yes. Two ways. Firstly select 'Match Quick' rather than 'Match Full'. Secondly create the saved bmp file you want to detect with MMM. This way we can ensure that the image file bmp is a a true bitmap file compatible with MMM detect image. Using the PIXEL RANGE dialog draw out the location and save the image as a bmp.
|
|
|
Post by mrclicker on Aug 5, 2021 12:29:01 GMT
Thank you for the long and detailed response.. i'll get back to the drawing board(literally) and respond with results shortly
|
|
|
Post by mrclicker on Aug 5, 2021 13:04:52 GMT
this is in a website. i use brave, but i tried it on chrome too (both use the same engine i think). i tried using developer tools to isolate the image to find if there is any transparancy but the way this site is coded i cant just right click on a screen element and inspect it. so in short, i can't figure out if there's a blend of multiple images to create the button.. i tried saving the bitmap directly from the pixel range dialogue box . exact same results, ie another failure what i did was : drawn the pixel range around the image; saved to file; created a new condition detect image; clicked the test; no detection im at my wits end.. any ideas what else i could try ?
|
|
|
Post by mrclicker on Aug 5, 2021 14:06:25 GMT
found a workaround, and when i look for only half the button the detection works every time - so hooray !! i then completed the condition operator and added image detect ACTION of mouse click on %X% and %Y% 2 | IF | DETECT IMAGE |
image path D:\Play.bmp::at 50 525 600 400::match quick::move mouse no::save to vars X Y | IMAGE FOUND | MOUSE CLICK | Left click at %X% %Y% 1 times with 0 ms delay (also tried without the "1 times with 0 ms delay" like its documented here: detect image ) when i do that i get this in the event log: Event Time Text
08/05/2021 02:53:45.20 PM Macro re-listed
08/05/2021 02:53:45.21 PM Starting macro playback
08/05/2021 02:53:45.23 PM Macro condition: 1 | IF | DETECT IMAGE | image path D:\Play.bmp::at 50 525 600 400::match quick::move mouse no::save to vars X Y | IMAGE FOUND | MOUSE CLICK | Left click at %X% %Y% 1 times with 0 ms delay
08/05/2021 02:53:45.25 PM Macro condition - Condition FALSE
08/05/2021 02:53:45.28 PM Playback error: 1 | IF | DETECT IMAGE | image path D:\Play.bmp::at 50 525 600 400::match quick::move mouse no::save to vars X Y | IMAGE FOUND | MOUSE CLICK | Left click at %X% %Y% 1 times with 0 ms delay - Condition action is not valid. This condition action is not found in the ACTION list of valid condition actions: MOUSE CLICK
08/05/2021 02:53:45.32 PM Macro playback finished from my limited understanding it says that that the condition is false so i take it it still isnt detecting the image ? even though the tests are now all good.. Events from Test: and finally, if i set the action to move mouse to image the condition is now showing true and the action completes successfully: can you tell me if i have the wrong syntax in my original detect image and click on %X% %Y% ? or is there something else i missed ?
|
|
|
Post by Steve on Aug 11, 2021 9:01:31 GMT
|
|
|
Post by mrclicker on Aug 11, 2021 15:04:15 GMT
thanks Steve, yeah, i just saw this thread as i logged on. i tried what martin did exactly and it didnt work for me too - so maybe it is a bug ? i'll try the work around you suggested now
many thnks
|
|