LibFunc>imglib,CompareBitmaps, match,d:\screen1.bmp,d:\sc
Moderators: Dorian (MJT support), JRL
LibFunc>imglib,CompareBitmaps, match,d:\screen1.bmp,d:\sc
I've started to play with the Image Library and ran this sample from the help section
Macro Scheduler Example
In this example we use CompareBitmaps to wait for the screen to change by more than 90%:
Let>imglibDLL=%SCRIPT_DIR%\imglib.dll
LibLoad>imglibDll,imglib
LibFunc>imglib,GetScreenRes,screen,ref:0,ref:0
ScreenCapture>0,0,screen_1,screen_2,d:\screen1.bmp
Let>match=0
Repeat>match
ScreenCapture>0,0,screen_1,screen_2,d:\screen2.bmp
LibFunc>imglib,CompareBitmaps,match,d:\screen1.bmp,d:\screen2.bmp
Wait>0.2
Until>matchWe have a new screen ...
LibFree>imglib
So the first thing that seemed counter-intuitive to me was 'match<90'
which to me means that if 11% or more of the screen doesn't match we
get the message box.
Ignoring this I went ahead and ran the script, and as stated in the help I need to change the vast majority of the screen before I got the message box.
So for me logic would have it that match<10 would be at the other extreme.
So I ran it with match<10 and still I need to change almost the entire screen to get the message box.
I started the script and brought up yahoo messenger which occupies about
30% of the screen and got no message box.
Next I changed my desktop to a flat gray. tried at both extremes and still
had the same results.
Also the shortcut icons on my desktop got broken up and stayed that way even after I shutdown the script and the program. I needed to click on each of the effected icons to restore them.
I dont think it has to do the my computer hardware ,I have 2 gigs of ram
a P4 630 and a 10K rpm hard drive.
Any help with why the image library seems to have this effect on my computer and why changing 'match< x' doesnt seem to have any effect
the outcome is appreciated.[/b]
Macro Scheduler Example
In this example we use CompareBitmaps to wait for the screen to change by more than 90%:
Let>imglibDLL=%SCRIPT_DIR%\imglib.dll
LibLoad>imglibDll,imglib
LibFunc>imglib,GetScreenRes,screen,ref:0,ref:0
ScreenCapture>0,0,screen_1,screen_2,d:\screen1.bmp
Let>match=0
Repeat>match
ScreenCapture>0,0,screen_1,screen_2,d:\screen2.bmp
LibFunc>imglib,CompareBitmaps,match,d:\screen1.bmp,d:\screen2.bmp
Wait>0.2
Until>matchWe have a new screen ...
LibFree>imglib
So the first thing that seemed counter-intuitive to me was 'match<90'
which to me means that if 11% or more of the screen doesn't match we
get the message box.
Ignoring this I went ahead and ran the script, and as stated in the help I need to change the vast majority of the screen before I got the message box.
So for me logic would have it that match<10 would be at the other extreme.
So I ran it with match<10 and still I need to change almost the entire screen to get the message box.
I started the script and brought up yahoo messenger which occupies about
30% of the screen and got no message box.
Next I changed my desktop to a flat gray. tried at both extremes and still
had the same results.
Also the shortcut icons on my desktop got broken up and stayed that way even after I shutdown the script and the program. I needed to click on each of the effected icons to restore them.
I dont think it has to do the my computer hardware ,I have 2 gigs of ram
a P4 630 and a 10K rpm hard drive.
Any help with why the image library seems to have this effect on my computer and why changing 'match< x' doesnt seem to have any effect
the outcome is appreciated.[/b]
I don't understand why your desktop is effected by the program, but I use ImageLibrary constantly and love it.
My understanding of Match<90 is that the system is waiting for the compared bitmaps to be less than a 90% match.
I, personally, don't care about the match. I always (almost always) use the FindImgPos call to know if/when an image is loaded, so I can take some action or click on the image.
If you are trying something similar, let me know and I'll post some of my code...
SkunkWorks
My understanding of Match<90 is that the system is waiting for the compared bitmaps to be less than a 90% match.
I, personally, don't care about the match. I always (almost always) use the FindImgPos call to know if/when an image is loaded, so I can take some action or click on the image.
If you are trying something similar, let me know and I'll post some of my code...
SkunkWorks
Thank you
I am just determined to get these type of questions answered because I
am interested in the Pro version for creating executables.
This program has a lot of features other macro programs don't offer.
For personal use it is not inexpensive , so as a self-taught computer user
I'm just making certain that I find answers to the questions I have.
The issue with having to refresh the screen is bothersome because I
don't have it with any other application.
I am just determined to get these type of questions answered because I
am interested in the Pro version for creating executables.
This program has a lot of features other macro programs don't offer.
For personal use it is not inexpensive , so as a self-taught computer user
I'm just making certain that I find answers to the questions I have.
The issue with having to refresh the screen is bothersome because I
don't have it with any other application.
-
- Automation Wizard
- Posts: 1101
- Joined: Fri Jan 07, 2005 5:55 pm
- Location: Somewhere else on the planet
I tested that script when I saw your first post and it works fine for me. I do agree that the amount of change in Match is not always what you might expect. If (like me) you want to play with changing screens and seeing the effect on Match then here is one way to do that.
Set up these two scripts and assign them to hotkeys. The first one grabs the baseline screen shot, the second makes and displays the match calculation.
Step 1: Use the hotkey to execute the first script.
Step 2: Change the screen and use the hotkey to execute the second script to display the match %
Repeat step two as many times as you like.
//baseline
Let>imglibDLL=C:\Program Files\Macro Scheduler Image Library\imglib.dll
LibLoad>imglibDll,imglib
LibFunc>imglib,GetScreenRes,screen,ref:0,ref:0
ScreenCapture>0,0,screen_1,screen_2,c:\test\screen1.bmp
LibFree>imglib
//end
//match
Let>imglibDLL=C:\Program Files\Macro Scheduler Image Library\imglib.dll
LibLoad>imglibDll,imglib
LibFunc>imglib,GetScreenRes,screen,ref:0,ref:0
Let>match=0
ScreenCapture>0,0,screen_1,screen_2,c:\test\screen2.bmp
LibFunc>imglib,CompareBitmaps,match,c:\test\screen1.bmp,c:\test\screen2.bmp
Wait>0.2
MessageModal>%match%
LibFree>imglib
//end
Note: You may have to modify the directories to match your system.
Set up these two scripts and assign them to hotkeys. The first one grabs the baseline screen shot, the second makes and displays the match calculation.
Step 1: Use the hotkey to execute the first script.
Step 2: Change the screen and use the hotkey to execute the second script to display the match %
Repeat step two as many times as you like.
//baseline
Let>imglibDLL=C:\Program Files\Macro Scheduler Image Library\imglib.dll
LibLoad>imglibDll,imglib
LibFunc>imglib,GetScreenRes,screen,ref:0,ref:0
ScreenCapture>0,0,screen_1,screen_2,c:\test\screen1.bmp
LibFree>imglib
//end
//match
Let>imglibDLL=C:\Program Files\Macro Scheduler Image Library\imglib.dll
LibLoad>imglibDll,imglib
LibFunc>imglib,GetScreenRes,screen,ref:0,ref:0
Let>match=0
ScreenCapture>0,0,screen_1,screen_2,c:\test\screen2.bmp
LibFunc>imglib,CompareBitmaps,match,c:\test\screen1.bmp,c:\test\screen2.bmp
Wait>0.2
MessageModal>%match%
LibFree>imglib
//end
Note: You may have to modify the directories to match your system.
I tried these two scripts.
Good idea.
I took my first screenshot of the desktop with a black background.
When I ran the match I had a 100% match until I covered at least 50%
of the screen, and in some cases needed to cover 2/3 before I saw a change in the variable.
Which is why I was looking for an explaination on this function.
Is there a misunderstanding on it's purpose?
If not it is truely defective.
Good idea.
I took my first screenshot of the desktop with a black background.
When I ran the match I had a 100% match until I covered at least 50%
of the screen, and in some cases needed to cover 2/3 before I saw a change in the variable.
Which is why I was looking for an explaination on this function.
Is there a misunderstanding on it's purpose?
If not it is truely defective.
-
- Automation Wizard
- Posts: 1101
- Joined: Fri Jan 07, 2005 5:55 pm
- Location: Somewhere else on the planet
The function does work correctly. I'm not seeing the same result that you are. I did not find a way to make a change and not have match show less than 100%, eg I move an icon a little on the desktop and it'll reduce to 99%.
All I can suggest is that you look at the screen1.bmp and screen2.bmp and check that they are capturing the screen correctly.
All I can suggest is that you look at the screen1.bmp and screen2.bmp and check that they are capturing the screen correctly.
I did look at the image files and they saved OK.
Like I was saying in my test I could open a window and change for example 1/3 and even more of the screen and see no change in the match variable.
I did open the images files to visually check that they were saving correctly, and they were.
I did have cases when the variable changed to something other than either 100 or a number at the other extreme but it only did so when say 2/3 or more of the screen was covered. And even then the match variable seemed to be way off.
Like I was saying in my test I could open a window and change for example 1/3 and even more of the screen and see no change in the match variable.
I did open the images files to visually check that they were saving correctly, and they were.
I did have cases when the variable changed to something other than either 100 or a number at the other extreme but it only did so when say 2/3 or more of the screen was covered. And even then the match variable seemed to be way off.
Could you clarify what you mean by "the screen was covered". I have a feeling we are all missing something in how you are conducting your test. If you use a webpage like MJTNET, take the first ScreenCapture, then have the script click on some link like Discussion Forums, then take your next screencapture, do those screens compare with predictable results? I would suggest running this type of test with your browser at full screen (WindowAction>1,SomeBrowserWindowName)
we will eventually get to the bottom of this...
we will eventually get to the bottom of this...
I dont know how much clearer I can get.
I take a screenshot of a desktop with a solid black background, the only
pixels that arent black are from 15 or so icons.
The second screenshot is one in which I open yahoo messenger which is primarily white.
It covers over 25% of the screen.
The code I am using is the very same code copied from this thread.
I then open the file to check the screenshots after running the code.
They are as expected. One is the full desktop no windows open, the second is the desktop with yahoo messenger.
I can open a second window that takes my coverage to close to 50%
of the screen and still get a match of 100%.
It isnt until I exceed more that half the screen , and an most cases,
substantially more than half that I begin to show new values for MATCH.
And those values dont seem to relate to the amount of change until I cross a certain threshold.
What I am redescribing here is what is happening.
If I had the means to do so I would record a video of my desktop as I walk you through the steps I take to dispell any notion that I have a misundestanding of the code or how to run it.
This would return the discussion back to..why doesn't this MATCH variable behave anything like it is described.
Would you be satisfied with stills of my desktop as I take these steps?
Give me an email address and I will be more than happy to send them as a step by step through the code and open the file to show the screenshots
taken by the code.
I take a screenshot of a desktop with a solid black background, the only
pixels that arent black are from 15 or so icons.
The second screenshot is one in which I open yahoo messenger which is primarily white.
It covers over 25% of the screen.
The code I am using is the very same code copied from this thread.
I then open the file to check the screenshots after running the code.
They are as expected. One is the full desktop no windows open, the second is the desktop with yahoo messenger.
I can open a second window that takes my coverage to close to 50%
of the screen and still get a match of 100%.
It isnt until I exceed more that half the screen , and an most cases,
substantially more than half that I begin to show new values for MATCH.
And those values dont seem to relate to the amount of change until I cross a certain threshold.
What I am redescribing here is what is happening.
If I had the means to do so I would record a video of my desktop as I walk you through the steps I take to dispell any notion that I have a misundestanding of the code or how to run it.
This would return the discussion back to..why doesn't this MATCH variable behave anything like it is described.
Would you be satisfied with stills of my desktop as I take these steps?
Give me an email address and I will be more than happy to send them as a step by step through the code and open the file to show the screenshots
taken by the code.
-
- Automation Wizard
- Posts: 1101
- Joined: Fri Jan 07, 2005 5:55 pm
- Location: Somewhere else on the planet
Yes, a lot, thanks I essentially confirm your results and with some more testing I made an interesting discovery. The result of match depends a lot on the position on the screen of the change, it is pretty sensitive at the left side, and very insensitive at the right side - which was where you made big changes but saw little change in the value.
Consider these four screenshots, the first is of the original desktop. The second and third show My Computer opened at the right side of the screen, the bitmaps of these two screens show a 99% match to the bitmap of the first screen. The fourth shows the My Computer window, size unchanged, moved to the left side of the screen, this bitmap shows only a 57% match to the original. I don't know if this is a feature of the design or a bug, I think we'll need Marcus back from his hols to go further with this.
#1 Original screen
#2 Change 1 = 99% match to #1
#3 Change 2 = 99% match to #1
#4 Change 3 = 57% match to #1
Consider these four screenshots, the first is of the original desktop. The second and third show My Computer opened at the right side of the screen, the bitmaps of these two screens show a 99% match to the bitmap of the first screen. The fourth shows the My Computer window, size unchanged, moved to the left side of the screen, this bitmap shows only a 57% match to the original. I don't know if this is a feature of the design or a bug, I think we'll need Marcus back from his hols to go further with this.
#1 Original screen
#2 Change 1 = 99% match to #1
#3 Change 2 = 99% match to #1
#4 Change 3 = 57% match to #1