Jump to content

Mouse click versus control click


Phaser
 Share

Recommended Posts

I do seem to find the odd ones, well I finished my script it works perfect on my pc, I sentit to the laptop to see if it worked and it didnt, mouseclick works on the correct coordinates but pixelgetcolour doesn't, so, I installed autoit on th elaptop and ran the windowinfo tool to locate the problem, first thing I noticed was when dragging across the desktop it measures fine but didnt recognise the edge of the window (an exe file) on my pc it counts up the resolution of the screen the goes to zero as it hits the edge of the window, but not on the laptop.

I am using the first 2 array values from wingetpos like this

$size = WinGetPos("Window name")

$x1 = $size[0]

$y1 = $size[1]

And calling them into

$var = PixelGetColor( $x1+550 , $y1+220 )

if Not ($var = 0x081A58) Then ; check if note blocks view

MouseClick("left", $x1+571, $y1+211);

Mousae click hits its spot but pixelgetcolour misses completely

We tried it on another pc too and the same issue, so only my pc actually works fine with the script, what am I doing wrong? controlclick works fine too, I must use pixelgetcolor.

Link to comment
Share on other sites

If these machines are running different screen resolutions, that would explain it.

I wouldn't be surprised if the mouse click was a bit off as well, but maybe the control was large enough that it didn't matter.

Try using more logic to get the location of the pixel to check, or try using relative coordinates to the size of the window.

Link to comment
Share on other sites

I have reset the resolution on my pc to as many different ones a spossible, it works fine all the time.

I think the fact that the Autoit Window Info tool behaves differently is the key point here, as I said, on my pc, dragging the mouse from left to right it counts the pixels and goes to zero as it hits the edge of the window, on the laptop it doesnt see the window (yes it is active when I do it)

The tool reads the desktop coordinates even when going over a window, I tested it on notepad too on both machines, my machine the tool measures the coordinates of notepad but the laptop doesn't it looks through it, the tool does know its there as it states it on the basic window info tab???

EDIT

Can someone test their window info tool with notepad, does it go to zero as it hits the left edge of notepad?

In this portion of my code

$var = PixelGetColor( $x1+550 , $y1+220 )

if Not ($var = 0x081A58) Then

MouseClick("left", $x1+550, $y1+220);

MouseClick hits its target but pixegetcolor doesn't on the laptop but it both works on my pc.

The fact that the autoit tool behaves very differently must be a clue

Edited by Phaser
Link to comment
Share on other sites

Can someone test their window info tool with notepad, does it go to zero as it hits the left edge of notepad?

With coord mode set to "window", yes, it approaches 0. - Opt('MouseCoordMode', 0)

If set to "client", I get 0 before hitting the windows frame, and once into the left portion of the window frame, it shows as a negative. - Opt('MouseCoordMode', 2)

Edited by danwilli
Link to comment
Share on other sites

OK yes it was set to window on my machine and screen on the laptop.

But that still doesn't explain this

In this portion of my code

$var = PixelGetColor( $x1+550 , $y1+220 ); misses completely

if Not ($var = 0x081A58) Then

MouseClick("left", $x1+550, $y1+220); hits dead on

MouseClick hits its target but pixegetcolor doesn't on the laptop but it both works on my pc.

Can you explain this MouseCoordMode a bit more, where should I put it if I need it, will it fix pixelgetcolor?

Link to comment
Share on other sites

Aha, I think we are getting to the root of your issue here :D

You must use the appropriate PixelCoordMode.

PixelCoordMode

Sets the way coords are used in the pixel functions, either absolute coords or coords relative to the window defined by hwnd (default active window):

0 = relative coords to the defined window

1 = absolute screen coordinates (default)

2 = relative coords to the client area of the defined window

So if you wanted 0 to be the farthest left point of the window you would need to use:

Opt('PixelCoordMode', 0)

If you are doing ALL (both mouseclick and pixel functions) calculations based on the furthest left side of the window being 0, then you will need both Mouse and Pixel coord modes set to 0 (Window).

Opt('PixelCoordMode', 0)
Opt('MouseCoordMode', 0)
;Rest of your script
Link to comment
Share on other sites

Hi danwilli, first up, thanks for the help so far, OK, I have obviousley built the script on my pc which I got it working fine on but I put in the

Opt('PixelCoordMode', 0)

Opt('MouseCoordMode', 0)

and on my machine it now doesn't work, the only mention I have of a specific window is wingetpos so need to know what I have missed out that will make it cross pc compatible, looking at the help file I note it says

hwnd [optional] Window handle to be used.

for pixelgetcolor, is this what I need? and would this be correct

Global $hWnd = WinGetHandle("Window Name Here")

$var = PixelGetColor( $x1+550 , $y1+220, $hWnd )

do I still need to use WinGetPos?

Edited by Phaser
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...