Screen Resolution Problems
Moderators: JRL, Dorian (MJT support)
Screen Resolution Problems
Hi
I have a script that I have working very well on one machine. I compiled to an exe and moved to another machine and it stoped working. I figured out that it has to do with the screen resolution of the secondary machine.
When my script starts it opens several windows (java applications) and moves each one to a different portion of the screen.
I have an INI file that I created for the script which it reads upon startup which defines each postion I have to use for the mousemove command. For example I know that a given field on window A is at postion 410,433 and I have this setup in the ini file using two fields (X,Y). However due to the screen size differences this does not equate to the correct position.
Due this being a Java app I don't beleive there is anyway to get the handles of the actual fields on the screen.
One way to resolve this is to create a simple script that opens up each window and places it in the starting position, and then have the Cursor monitor to collect the information of each postion I need. However, Cursor monitor does not work unless you have Macro Scheduler completly installed on the second machine.
So question 1 is : Is there a Cursor Monitor Executable that I can use.
Question 2: Is there an easier way to handle different Screen Resolutions for the same script? If so can you give me a detail example. I need the script to be very fast so I do not want to use any Bitmap comparisons.
Thank you,
David L.
I have a script that I have working very well on one machine. I compiled to an exe and moved to another machine and it stoped working. I figured out that it has to do with the screen resolution of the secondary machine.
When my script starts it opens several windows (java applications) and moves each one to a different portion of the screen.
I have an INI file that I created for the script which it reads upon startup which defines each postion I have to use for the mousemove command. For example I know that a given field on window A is at postion 410,433 and I have this setup in the ini file using two fields (X,Y). However due to the screen size differences this does not equate to the correct position.
Due this being a Java app I don't beleive there is anyway to get the handles of the actual fields on the screen.
One way to resolve this is to create a simple script that opens up each window and places it in the starting position, and then have the Cursor monitor to collect the information of each postion I need. However, Cursor monitor does not work unless you have Macro Scheduler completly installed on the second machine.
So question 1 is : Is there a Cursor Monitor Executable that I can use.
Question 2: Is there an easier way to handle different Screen Resolutions for the same script? If so can you give me a detail example. I need the script to be very fast so I do not want to use any Bitmap comparisons.
Thank you,
David L.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
I would recommend using Image Recognition. I know you say it needs to be fast, but in v10 it IS fast. Very fast. 0.1 - 0.2 seconds to find an image at bottom right of a 1600x1200 screen.
Alternatively just position windows relative to the top left of the screen. Move the window to 0,0 and resize it. So each time the window starts at 0,0 and is the same size. So everything always appears in the same place regardless of screen resolution.
The Cursor Monitor just does the same as GetCursorPos. But I'm not sure how that will help you.
Alternatively just position windows relative to the top left of the screen. Move the window to 0,0 and resize it. So each time the window starts at 0,0 and is the same size. So everything always appears in the same place regardless of screen resolution.
The Cursor Monitor just does the same as GetCursorPos. But I'm not sure how that will help you.
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?
hmmm.
Lets Start with option two that you gave.
These windows are not resizable so I cannot resize.
Does Image Recognition ignore the Screen Resolution and if so, since I cannot resize the window how can I get to the postion of a field in the window.
Basically my solution was to have the INI file contain a section called.
[WINDOWINFO_1920x1200]
Where 1920x1200 would be the definiitions of that screen size. Before reading the INI file I would
Let>WINDOWSIZE=WINDOWINFO_%ScrXWidth%x%ScrYHeight%
And then when reading the INI I would
ReadIniFile>%path%\%WINDOWSIZE%.ini,%WINDOWSIZE%,NUS_QTYFIELDX,NUS_QtyFieldX
ReadIniFile>%path%\%WINDOWSIZE%.ini,%WINDOWSIZE%,NUS_QTYFIELDY,NUS_QtyFieldY
My thought was to write a seperate program/macro that would get the current window size Open the window(s) needed and then Ask the user a question like Move Mouse to the right most part of the QTY field and click.
When the click came in it would writeln to a WINDOWINFO_%SCRXWIDTHxT%SCRYHEIGHT%.ini file with the approprate field that I was requesting. Of cours starting with the Header [WINDOWINFO_1920x1200]
Or just have the user log each postion for the current Screen resolution they are using and manually write it to the ini file.
The ending ini file from the new program/script would contain something like this.
[WINDOWINFO_1920x1200]
// NUS_INIT = X and Y Postion of upper Left Corner of RNL Window.
NUS_INITX=5
NUS_INITY=5
// NUS_CENTER Should be Mouse Pointer in the Center of Window with No Fields Around
NUS_CENTERX=410
NUS_CENTERY=334
// NUS_QTYFIELD Is Postion of the Mouse Pointer At the End of the Quantity Field.
NUS_QTYFIELDX=931
NUS_QTYFIELDY=97
Where the First 3 letters would be the abreviation of the screen name.
To further the thought I could ask the person to type in the X,Y of any postion of the screen through a script and write out how the INI file should be set.
For example: I would have a Text file or Database that would be read to ask the user the question.
NUS, Position the mouse at the end of the Qunaity Field of the NUS Screen and type in the X and Y Cordinates.
I could then write those cordinates in the INI file for that screen size.
Regardless, I would like recomendations of how I should accomplish this.
Thank you,
David
Lets Start with option two that you gave.
These windows are not resizable so I cannot resize.
Does Image Recognition ignore the Screen Resolution and if so, since I cannot resize the window how can I get to the postion of a field in the window.
Basically my solution was to have the INI file contain a section called.
[WINDOWINFO_1920x1200]
Where 1920x1200 would be the definiitions of that screen size. Before reading the INI file I would
Let>WINDOWSIZE=WINDOWINFO_%ScrXWidth%x%ScrYHeight%
And then when reading the INI I would
ReadIniFile>%path%\%WINDOWSIZE%.ini,%WINDOWSIZE%,NUS_QTYFIELDX,NUS_QtyFieldX
ReadIniFile>%path%\%WINDOWSIZE%.ini,%WINDOWSIZE%,NUS_QTYFIELDY,NUS_QtyFieldY
My thought was to write a seperate program/macro that would get the current window size Open the window(s) needed and then Ask the user a question like Move Mouse to the right most part of the QTY field and click.
When the click came in it would writeln to a WINDOWINFO_%SCRXWIDTHxT%SCRYHEIGHT%.ini file with the approprate field that I was requesting. Of cours starting with the Header [WINDOWINFO_1920x1200]
Or just have the user log each postion for the current Screen resolution they are using and manually write it to the ini file.
The ending ini file from the new program/script would contain something like this.
[WINDOWINFO_1920x1200]
// NUS_INIT = X and Y Postion of upper Left Corner of RNL Window.
NUS_INITX=5
NUS_INITY=5
// NUS_CENTER Should be Mouse Pointer in the Center of Window with No Fields Around
NUS_CENTERX=410
NUS_CENTERY=334
// NUS_QTYFIELD Is Postion of the Mouse Pointer At the End of the Quantity Field.
NUS_QTYFIELDX=931
NUS_QTYFIELDY=97
Where the First 3 letters would be the abreviation of the screen name.
To further the thought I could ask the person to type in the X,Y of any postion of the screen through a script and write out how the INI file should be set.
For example: I would have a Text file or Database that would be read to ask the user the question.
NUS, Position the mouse at the end of the Qunaity Field of the NUS Screen and type in the X and Y Cordinates.
I could then write those cordinates in the INI file for that screen size.
Regardless, I would like recomendations of how I should accomplish this.
Thank you,
David
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
I'm not sure why the resolution matters. The whole point of Image Recognition is that it can locate a screen object anywhere on the screen and return its position. It does not care what the screen resolution is.
Use SCREEN as the haystack parameter and FindImagePos will automatically scan the screen. No need to capture it first.
Use SCREEN as the haystack parameter and FindImagePos will automatically scan the screen. No need to capture it first.
Hi,
I have attempted to use FindImagePos. Buttons seem to work good, however getting the correct postion of a data entry field (x,y) to put the mouse in seems to be unreliable. Furthermore sometimes there is data in the fields on the real screen, and I found it to be unreliable in when compariing to a bitmap that has no data in the field.
Maybe I'm doing something wrong.
1st I created Bitmaps of all of the screen postions I wanted to move the Mouse (so I could LClick). I made each with something unique in them like a word or a few letters that are always on the screen.
2nd I opened the window and set its focus, I used
FindImagePos>d:\xxx\bitmaps\Qty.bmp,SCREEN,0,1,X,Y,NumFound
Normally NumFound was 0
I have tested with data in the fields and without (which looked like the bitmap I created).
Let me know if I'm doing something wrong.
Thank you
David
I have attempted to use FindImagePos. Buttons seem to work good, however getting the correct postion of a data entry field (x,y) to put the mouse in seems to be unreliable. Furthermore sometimes there is data in the fields on the real screen, and I found it to be unreliable in when compariing to a bitmap that has no data in the field.
Maybe I'm doing something wrong.
1st I created Bitmaps of all of the screen postions I wanted to move the Mouse (so I could LClick). I made each with something unique in them like a word or a few letters that are always on the screen.
2nd I opened the window and set its focus, I used
FindImagePos>d:\xxx\bitmaps\Qty.bmp,SCREEN,0,1,X,Y,NumFound
Normally NumFound was 0
I have tested with data in the fields and without (which looked like the bitmap I created).
Let me know if I'm doing something wrong.
Thank you
David
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Clearly if you capture a text field with no data in it it is not the same image as the text field with data, or different data in it.
Instead capture the area encompassing the field's label and the edge of the field. When found move the mouse to the right most edge of it.
http://www.mjtnet.com/blog/2007/02/20/h ... cognition/
However, any reason why you need to use image recognition to locate a data field (text box)? Normally text boxes on forms do not move around. Once the first is focused you just need to TAB from one to the other:
Send>first item
Press Tab
Send>second field
Press Tab
Send>etc etc
Keep it simple. Keystrokes. TAB is your friend - it moves focus from one field to the next. Works in every kind of app, even web pages.
http://www.mjtnet.com/blog/2006/01/16/k ... shortcuts/
http://www.mjtnet.com/blog/2006/01/17/h ... on-script/
Instead capture the area encompassing the field's label and the edge of the field. When found move the mouse to the right most edge of it.
http://www.mjtnet.com/blog/2007/02/20/h ... cognition/
However, any reason why you need to use image recognition to locate a data field (text box)? Normally text boxes on forms do not move around. Once the first is focused you just need to TAB from one to the other:
Send>first item
Press Tab
Send>second field
Press Tab
Send>etc etc
Keep it simple. Keystrokes. TAB is your friend - it moves focus from one field to the next. Works in every kind of app, even web pages.
http://www.mjtnet.com/blog/2006/01/16/k ... shortcuts/
http://www.mjtnet.com/blog/2006/01/17/h ... on-script/
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?
Currently once I set focus on the first field (Which requires a Mouse Pointer click in this window) I use Tabs to move from field to field. However, Based on the information I type in and after the process is completed I need to go to a Message field (non entrent) and copy what is inside of it to a clipboard so I can get the Status/Message. Based on the Message I will need to go to 1 of three List Boxes that are on the same window to get the data (one at a time using Clip Board, Down Arrow, etc)
To make a long story short, the window is farily complex, and based on what I type and the results different information will show up on different parts of the screen which I need to capture and decide what to do with it. I have tried using Start at Field 1 and tab through the fields but it never seems to work. When I Move Mouse Pointer and click it always works. Which is the reason I came up with the INI file solution. However, as stated in my original post, is there any external program that will get the X,Y position of the mouse so I don't need to purchase and install the full version of Macro Scheduler on each machine, and I can instruct end users on how to fill in the variables in the INI file.
Thank you,
David
To make a long story short, the window is farily complex, and based on what I type and the results different information will show up on different parts of the screen which I need to capture and decide what to do with it. I have tried using Start at Field 1 and tab through the fields but it never seems to work. When I Move Mouse Pointer and click it always works. Which is the reason I came up with the INI file solution. However, as stated in my original post, is there any external program that will get the X,Y position of the mouse so I don't need to purchase and install the full version of Macro Scheduler on each machine, and I can instruct end users on how to fill in the variables in the INI file.
Thank you,
David
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Assuming you have Macro Scheduer Pro, here's how to get an "external program" to get the X,Y position:
1. Start Macro Scheduler on your machine.
2. Create a new macro
3. Paste in this code:
4. Compile this macro to an EXE
5. Run this EXE on PC of your choice.
It will show you the coordinates of the mouse position.
1. Start Macro Scheduler on your machine.
2. Create a new macro
3. Paste in this code:
Code: Select all
Dialog>Dialog1
Caption=Dialog1
Width=183
Height=101
Top=216
Left=196
Max=0
Min=0
Close=1
Resize=0
Edit=msEdit1,24,16,121,msEdit1
EndDialog>Dialog1
Show>Dialog1
Label>main_loop
GetDialoGAction>Dialog1,r
If>r=2,end
GetCursorPos>x,y
Let>Dialog1.msEdit1=%x%, %y%
ResetDialogAction>Dialog1
Wait>0.2
Goto>main_loop
Label>end
5. Run this EXE on PC of your choice.
It will show you the coordinates of the mouse 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?
I have a program that I wrote and use for the purpose of getting information from computers that don't have Macro Scheduler installed. I have put it on Microsoft SkyDrive and its available for anyone to download. The program name is Mouse coordinate dialog.exe. After starting it you can press F1 to see the following help for its functions.
Here is the help to tell you what it does:
Press Ctrl + F12 to copy currently selected window information
to the clipboard.
* Press Ctrl + mouse left click to copy color number and current
cursor X,Y coordinates to the clipboard.
* Press Ctrl + F2 toggles through window types No Child Windows, All Windows,
Visible Windows and Child Windows Only
* Press Ctrl + F3 toggles window stay-on-top On or Off
* Click [Window X/Y]/[Screen X/Y] button to toggle between viewing X,Y
coordinates relative to the entire screen, and viewing X,Y coordinates
relative to the home position of the currently selected window.
* Click [Lock To Cursor] button to attach window to the mouse cursor.
* Press Ctrl + mouse right click to "unlock" window from the mouse cursor.
* Clicking [Log] will put the clipboard contents into notepad
* Clicking [ClrLog] will delete the logfile and/or clear the contents of notepad
* Clicking [Help] or pressing F1 while the Mouse Position window is in focus
will call this help screen. To close Help, either click [Help] or press
F1 a second time.
Here is the help to tell you what it does:
Press Ctrl + F12 to copy currently selected window information
to the clipboard.
* Press Ctrl + mouse left click to copy color number and current
cursor X,Y coordinates to the clipboard.
* Press Ctrl + F2 toggles through window types No Child Windows, All Windows,
Visible Windows and Child Windows Only
* Press Ctrl + F3 toggles window stay-on-top On or Off
* Click [Window X/Y]/[Screen X/Y] button to toggle between viewing X,Y
coordinates relative to the entire screen, and viewing X,Y coordinates
relative to the home position of the currently selected window.
* Click [Lock To Cursor] button to attach window to the mouse cursor.
* Press Ctrl + mouse right click to "unlock" window from the mouse cursor.
* Clicking [Log] will put the clipboard contents into notepad
* Clicking [ClrLog] will delete the logfile and/or clear the contents of notepad
* Clicking [Help] or pressing F1 while the Mouse Position window is in focus
will call this help screen. To close Help, either click [Help] or press
F1 a second time.