Jump to content

MouseCoord issue across multiple OS


Recommended Posts

So I'm writing scripts to do a few tests on my software, but I need to test it out on different operating systems. I already have a test setup, with different machines, running different versions of Windows. I'm running into an issue with mouse coordinates though. I'm having an issue with precise clicking, mainly to check/uncheck check boxes. I can do something like this code below, and on XP/Vista/7 it works great. However, I just started to test it out on Win Server 2008, and for some reason it misses the check box! It will click just slightly below the check box.

WinWaitActive("My Software's Dialog")
AutoItSetOption("MouseCoordMode", 0)  ;Switch the mouse coord mode to be relative to window
MouseClick("left", 25, 125, 1, 2)   ;Left click on a check box in my software window

I'm wondering if there's a theme selection in Server 2008 that will make it not get screwy with the mouse coords. I would really hate to have to do something like this below for every one of my mouse clicks, since it would take a really long time to make those changes:

If @OSVersion == "WIN_2008" Then
  MouseClick("left", 25, 123, 1, 2)  ;left click high
Else
  MouseClick("left", 25, 125, 1, 2)  ;for all other OS's
EndIf

Thanks in advance for your thoughts!

Link to comment
Share on other sites

1. Repeat previous answer.

2. Also try to avoid MouseClick() if possible (for obvious reasons). Look at ControlClick() and it's brethren to automate controls directly.

3. And it could be argumented that forcing a string comparison (see Operators in helpfile) on what already is 2 strings is superfluous.... You do know you are doing that, right?

Edited by AdmiralAlkex
Link to comment
Share on other sites

The position of the button could be different from one OS to another. It might even be affected if someone has their system set to a different DPI setting.

How about using ControlClick instead of MouseClick?

ControlClick("Form1", "", "[CLASS:Button; TEXT:Button1; Instance:1;]")

#include <ByteMe.au3>

Link to comment
Share on other sites

1. Repeat previous answer.

2. Also try to avoid MouseClick() if possible (for obvious reasons). Look at ControlClick() and it's brethren to automate controls directly.

3. And it could be argumented that forcing a string comparison (see Operators in helpfile) on what already is 2 strings is superfluous.... You do know you are doing that, right?

Thanks Admiral! Yeah I suppose I could swap them out for ControlClicks, which would allow me to optionally use mouse coordinates, or not at all. And I stick to using double equals just out of habit of coding, however superfluous, it still executes the way I want it to, but thanks for pointing it out anyway.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...