Jump to content
Sign in to follow this  
Zer0Velocity

Any resolution mouseclick

Recommended Posts

Zer0Velocity

Hey all, I got this code but want to make it work on another pc, but won't as it has different resolution. Coded resolution 1680x1050

$colour = 0x9A8A2E
$coord = PixelSearch(0,0,@DesktopWidth,@DesktopHeight,$colour)
If not @error Then
MouseClick ("left",$coord[0],$coord[1], 1,1)
MouseClick("left", 572, 906, 1 ,2)
sleep(500)
MouseClick("left", 1120, 1000, 1 ,3)
sleep(500)
MouseClick("left", 876, 518, 1 ,3)
sleep(500)
MouseClick("left", 1164, 791, 1 ,3)
sleep(500)
MouseClick("left", 1180, 846, 1 ,2)
sleep(1000)
MouseClick("left", 636, 911, 1 ,2)
sleep(1000)
MouseMove(550,900,1)
sleep(200)
MouseDown("left")
sleep(200)
MouseMove ($coord[0],$coord[1] +50, 5)
Sleep(500)
MouseUp("left")
sleep(500)
mouseclick ("left", 1180, 851, 1 ,3)
        MouseMove(@DesktopWidth / 2, 0, 0)
EndIf

Share this post


Link to post
Share on other sites
seandisanti

Hey all, I got this code but want to make it work on another pc, but won't as it has different resolution. Coded resolution 1680x1050

$colour = 0x9A8A2E
$coord = PixelSearch(0,0,@DesktopWidth,@DesktopHeight,$colour)
If not @error Then
MouseClick ("left",$coord[0],$coord[1], 1,1)
MouseClick("left", 572, 906, 1 ,2)
sleep(500)
MouseClick("left", 1120, 1000, 1 ,3)
sleep(500)
MouseClick("left", 876, 518, 1 ,3)
sleep(500)
MouseClick("left", 1164, 791, 1 ,3)
sleep(500)
MouseClick("left", 1180, 846, 1 ,2)
sleep(1000)
MouseClick("left", 636, 911, 1 ,2)
sleep(1000)
MouseMove(550,900,1)
sleep(200)
MouseDown("left")
sleep(200)
MouseMove ($coord[0],$coord[1] +50, 5)
Sleep(500)
MouseUp("left")
sleep(500)
mouseclick ("left", 1180, 851, 1 ,3)
        MouseMove(@DesktopWidth / 2, 0, 0)
EndIf

check out controlclick() that may be the best way to go

Share this post


Link to post
Share on other sites
Zer0Velocity

Thanks for reply, but I don't want controlclick. I need it to work as is with any resolution.

Share this post


Link to post
Share on other sites
seandisanti

Thanks for reply, but I don't want controlclick. I need it to work as is with any resolution.

you could figure the position dynamically based on the resolution then

Share this post


Link to post
Share on other sites
Zer0Velocity

The above script is dynamically based on a 1680x1050 resolution. But I want this to work on any resolutions.

Share this post


Link to post
Share on other sites
seandisanti

The above script is dynamically based on a 1680x1050 resolution. But I want this to work on any resolutions.

right... it can't be "dynamically based" on a static value. what i meant was figure out where the clicks should be mathematically based on the screen size, assuming the elements that you're trying to click on are going to be the same relative size and location regardless of the resolution. I'm making that assumption because you said that they're not controls being clicked on, or that you didn't want to go that route, and i don't have a whole lot of other info to go on.

Share this post


Link to post
Share on other sites
saywell

right... it can't be "dynamically based" on a static value. what i meant was figure out where the clicks should be mathematically based on the screen size, assuming the elements that you're trying to click on are going to be the same relative size and location regardless of the resolution. I'm making that assumption because you said that they're not controls being clicked on, or that you didn't want to go that route, and i don't have a whole lot of other info to go on.

That seems sensible - can you work out screen position as % of height and width, and set a variable for each based on @DesktopHeight and @desktopWidth?

William

Share this post


Link to post
Share on other sites
Zer0Velocity

Not sure how I would go about calculating from @DesktopHeight and @Desktopwidth into percentages. But I think this might work for what is needed. How would I go about getting the percentages?

Share this post


Link to post
Share on other sites
saywell

How would I go about getting the percentages?

the traditional way is to divide by 100...

Algebra is the key!

Work out the coordinates in x and y directions as % of 1680 and 1050 respectively, and allocate those values to a pair of variables.

Get resolution of screen using @DesktopHeight and @DesktopWidth and "do the math" for each one into the other to give equivalent position for new screen resolution.

of course, this assumes everything expands/contracts proportionately - if, say, the task-bar has a fixed size in pixels regardless of resolution, this may be inaccurate - but if you're lucky and the button you're clicking is a decent size, this may not matter. You'd need to do some testing and perhaps add or subtract as required on a trial and error basis.

William

Edited by saywell

Share this post


Link to post
Share on other sites
BrewManNH

the traditional way is to divide by 100...

Algebra is the key!

Work out the coordinates in x and y directions as % of 1680 and 1050 respectively, and allocate those values to a pair of variables.

Get resolution of screen using @DesktopHeight and @DesktopWidth and "do the math" for each one into the other to give equivalent position for new screen resolution.

Not to step on any toes, but the usual way to get the percentages that saywell is talking about you would use this formula:

(<screen x position> / <screen x dimension>) * 100 = %

If the button to be clicked is at position 500, 1000, then your X% would be (500/1680)*100, the Y% would be (1000/1050)*100


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Zer0Velocity

Not to step on any toes, but the usual way to get the percentages that saywell is talking about you would use this formula:

(<screen x position> / <screen x dimension>) * 100 = %

If the button to be clicked is at position 500, 1000, then your X% would be (500/1680)*100, the Y% would be (1000/1050)*100

This formula seems right and will test it later tonite ;) Thank you all for the help, really appreciate it :blink:

Share this post


Link to post
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
Sign in to follow this  

×