Vista / XP - Display Settings

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
klcmay
Newbie
Posts: 16
Joined: Sun Jun 01, 2008 10:12 pm

Vista / XP - Display Settings

Post by klcmay » Mon Apr 06, 2009 9:32 am

I have had an issue moving a macro from Vista to XP. This macro extensively uses GetPixelColor, WaitPixelColor and MouseMove/LClick to control an application. The macro has positioned the window at known co-ordinates on the screen and has resized the window to a specified size.

Everything works fine on Vista. However, when I move to XP I have run into problems. This seems to be because things like window title bars, borders and menus have different default sizes between the two versions of Windows. As a result, my macro is failing as it is using absolute screen positions which are now wrong.

Has anybody encountered this before and come up with a workable solution?

I know that MouseMoveRel may help but does this exclude the "outer" window borders/title etc? Even then, this wouldn't help with the pixel color logic (although I could calculate and add the offset)

I am also wondering if the ResizeWindow operation may be causing me problems because I assume that that this will be the full size including the borders,titles etc. Therefore, if I resize to the same dimensions on both operating systems unless the display settings are identical the actual size of the application within the window will be different so even working with relative dimensions is likely to fail.

Perhaps the easiest way to deal with this would be to make sure that the sizes are the same in both Vista and XP. I have tried this though and have so far been unable to make them exactly the same. Is there an easy way to do this? Can it be done programatically? Is there a list of the defaults anywhere that you know of?

I'd be very grateful for any other ideas or thoughts on this.

Many thanks,

Ken

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Apr 06, 2009 2:58 pm

I know that MouseMoveRel may help but does this exclude the "outer" window borders/title etc?
Use MouseMoveRel> to move the mouse correctly within a window client area (the area excluding borders and title bar). And use getclient.dll as described HERE to acquire the client area positioning relative to the top left corner of the window no matter what user or operating system settings might have done to the window appearance.

klcmay
Newbie
Posts: 16
Joined: Sun Jun 01, 2008 10:12 pm

Thank you / follow up

Post by klcmay » Tue Apr 07, 2009 8:51 am

Thank you for this, very useful.

However, I may be missing something obvious (or probably going about this in completely the wrong way!) The application that I'm dealing with seems to position its controls and other items depending on the size of the "working area" available to it.

Previously I was resizing the window to a known size and basing mouse movements/pixel colour logic on this resize operation.

This worked fine on the original PC (as the working area was always the same) but I was obviously forgetting the impact of window borders and so on when moving the macro somewhere else. If I resize to say 600x400 then this seems to be the full size of the window including the borders, title bar, menu bar etc and as a result the overall size of the working area may vary depending on OS/user display settings differences. This means that the working area varies and the application draws/scales its components accordingly breaking the macro.

Take the following example. Both windows have been resized to the same dimensions. From your response, I can certainly base everything from the point marked X. However, if the working area varies: I cannot work relative to this point in order to get the pixel color at O (the top right of the window) nor can I click A or B (which are centered).

Code: Select all

XP - smaller borders, equal title, larger menu
   ________________________________
  | ______________________________ |
  || Title Bar                    ||
  ||                              || 
  ||______________________________|| 
  || Menu                         ||
  ||                              || 
  ||------------------------------|| 
  ||X                            o||
  ||                              ||
  ||           _     _            || 
  ||          |A|   |B|           ||
  ||           -     -            ||
  ||                              || 
  ||______________________________||
  |________________________________|


Vista - larger borders, equal title, smaller menu

  _________________________________
  |                                |
  |  _____________________________ |
  | | Title Bar                  | | 
  | |                            | |  
  | |____________________________| | 
  | | Menu                       | |
  | |----------------------------| | 
  | |X                          o| |
  | |                            | |
  | |         _     _            | |  
  | |        |A|   |B|           | |
  | |         -     -            | | 
  | |____________________________| |
  |                                |
  |________________________________|

Therefore, I think I need to either:
- find a way to resize the window so that the working area is a known size. Then I can use the techniques you mentioned to work relative to the top left of the working area.
- control the size of the borders/title bar etc so that I can work with exactly the same dimensions (and working area) on both machines.

Hope this all makes sense. Thanks again for your help.

Ken

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Make Vista look like XP

Post by gdyvig » Tue Apr 07, 2009 3:31 pm

Are you OK with making Vista look like XP?

You can run in XP compatibility mode, or you can change the Display settings to look like XP. Here is a link that shows how:



http://reviews.cnet.com/4354-13747_7-6590428.html

I don't have Vista myself, so I can't check this out to see how precisely this works.


Gale

klcmay
Newbie
Posts: 16
Joined: Sun Jun 01, 2008 10:12 pm

Response

Post by klcmay » Tue Apr 07, 2009 5:11 pm

Yes, this is an option. However, the macro I have was in Vista and I'm trying to move it to XP (not my requirement!)

If the worst comes to the worst then I can always just step through it and tweak the positions and have one macro that works in Vista and one that works in XP.

I was just curious to see if there was a more generic solution. I would imagine people move macros from machine to machine regularly but perhaps the display settings are fairly similar and/or they dont have a lot of pixel dependent processing.

Anyway - thanks to everyone who's helped so far.

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts