Sign in to follow this  
Followers 0
Hyflex

Resolution Adjustment?

10 posts in this topic

Hey,

I'm trying to work out how to create an auto-resolution adjustment feature so coordinates are adjusted to each resolution.

1920x1080 Coordinates: 380, 400

800x600 Coordinates: 210, 220 (I think, it's hard to get the exact location)

How do I make it work out the correct coordinates based of my original coordinates what I've created in 1920x1080

If $Res = "1680x1050" Then
  MouseClick("left", $pos[1], pos[2], 1)
EndIf

Share this post


Link to post
Share on other sites



XxXGoD,

Hey,

How about posting in the correct section? ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

First, you are posting in the wrong forum section, this belongs in General Help and Support. Second, you would use basic math (1680/1920)*xPosition, (1050/1080)*yPosition should adjust according to the current dimensions.


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

#4 ·  Posted (edited)

First, you are posting in the wrong forum section, this belongs in General Help and Support. Second, you would use basic math (1680/1920)*xPosition, (1050/1080)*yPosition should adjust according to the current dimensions.

Sorry about the wrong forum section, I realised that after I posted ;) and thanks for your reply. I'm somewhat confused how to use this "basic math"

Is the below example in your view correct?

$OriginalXPosition = "380"
$OriginalYPosition = "400"

$1680x1050AdjustedXPosition = 1680 / 1920 * $OriginalXPosition
$1680x1050AdjustedYPosition = 1050 / 1080 * $OriginalYPosition

$800x600AdjustedXPosition = 800 / 1920 * $OriginalXPosition
$800x600AdjustedYPosition = 600 / 1080 * $OriginalYPosition
Edited by XxXGoD

Share this post


Link to post
Share on other sites

I would use parentheses around the division, just to be sure it's processed in the right order, but that's pretty much how I'd do it.


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

#6 ·  Posted (edited)

I guess it only works for the same aspect ratios... how do I make it compatible with each aspect ratio? I don't understand aspect ratios at all.

Edited by XxXGoD

Share this post


Link to post
Share on other sites

It should work the same regardless of aspect ratio. I just ran it on my system and changed resolutions in between clicks, and it clicked in exactly the same place on the screen in both resolutions.


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

I just tried a 1920x1080 converting it to 1600x900 and it worked fine but as soon as I tried to 1680x1050 it was pointing to the wrong area.

I could get around this maybe by doing three sets. 4:3 (I think) and 16:10 and 16:9, I'll post back with it once I've finished it just so if anyone can make use of it then atleast I have done something good ;)

Share this post


Link to post
Share on other sites

There is a slight difference between each aspect ratio, here is what I'm using at the moment obviously it can be turned into a function fairly easily but for me this is good enough.

Please remember some of the 16:9 resolutions are not true 16:9, and there are also 5:3, 5:4, 3:4, 17:10 as used aspect ratios.

; 16:9
    If $Resolution = "1920x1080" Or $Resolution = "1600x900" Or $Resolution = "1366x768" Or $Resolution = "1360x768" Or $Resolution = "1280x720" Then
        $OriginalXCoord = "345"
        $OriginalYCoord = "420"
        $ResolutionXorY = StringSplit($Resolution, "x")
        $AdjustedXCoord = ($ResolutionXorY[1] / 1920) * $OriginalXCoord
        $AdjustedYCoord = ($ResolutionXorY[2] / 1080) * $OriginalYCoord
        MouseClick("Left", $AdjustedXCoord, $AdjustedYCoord, 1)
    EndIf
    ; 16:10
    If $Resolution = "1680x1050" Or $Resolution = "1440x900" Or $Resolution = "1280x800" Then
        $OriginalXCoord = ""
        $OriginalYCoord = ""
        $ResolutionXorY = StringSplit($Resolution, "x")
        $AdjustedXCoord = ($ResolutionXorY[1] / 1680) * $OriginalXCoord
        $AdjustedYCoord = ($ResolutionXorY[2] / 1050) * $OriginalYCoord
        MouseClick("Left", $AdjustedXCoord, $AdjustedYCoord, 1)
    EndIf
    ; 4:3 Resoltions
    If $Resolution = "1400x1050" Or $Resolution = "1360x1024" Or $Resolution = "1280x960" Or $Resolution = "1152x864" Or $Resolution = "1024x768" Or $Resolution = "800x600" Then
        $OriginalXCoord = ""
        $OriginalYCoord = ""
        $ResolutionXorY = StringSplit($Resolution, "x")
        $AdjustedXCoord = ($ResolutionXorY[1] / 1400) * $OriginalXCoord
        $AdjustedYCoord = ($ResolutionXorY[2] / 1050) * $OriginalYCoord
        MouseClick("Left", $AdjustedXCoord, $AdjustedYCoord, 1)
    EndIf

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

#cs

Problems running on Greg's computer. Possible issues:
- speed was too fast for mouse clicks to respond
- did not copensate for different resolution

#ce




Dim $qty = 3

Dim $mousespeed = 3
Dim $msgboxactiontimes = 0
Dim $runtimes

Func Au3RecordSetup()
Opt('WinWaitDelay',100)
Opt('WinDetectHiddenText',1)
Opt('MouseCoordMode',0)
EndFunc



HotKeySet("{Esc}", "captureEsc")
Func captureEsc() ;hit escape and stop the script
    ; ... can do stuff here
    MsgBox(0, "Times Ran", "You cancelled the program with (ESC). This has run "&$msgboxactiontimes&" times.")
    HotKeySet("{Esc}")
    Send("{Esc}")
    HotKeySet("{Esc}", "captureEsc")
    Exit

EndFunc

AU3RecordSetup()

Func _WinWaitActivate($title,$text,$timeout=0)
    WinWait($title,$text,$timeout)
    If Not WinActive($title,$text) Then WinActivate($title,$text)
    WinWaitActive($title,$text,$timeout)
EndFunc

For $runtimes = 1 to $qty

_WinWaitActivate("Shipments","xtpBarBottom")
MouseClick("left",95,199,1,$mousespeed)
MouseClick("right",96,198,1,$mousespeed)
MouseClick("left",190,428,1,$mousespeed)

_WinWaitActivate("Purchase Orders","xtpBarBottom")
MouseClick("right",81,161,1,$mousespeed)
MouseClick("left",151,401,1,$mousespeed)
_WinWaitActivate("Order Status Report","Create &Order Status")
MouseClick("left",431,211,1,$mousespeed)
MouseClick("left",346,247,1,$mousespeed)
MouseClick("left",534,219,1,$mousespeed)
MouseClick("left",399,466,1,$mousespeed)
MouseClick("left",350,492,1,$mousespeed)
MouseClick("left",433,461,1,$mousespeed)
MouseClick("left",439,418,1,$mousespeed)
MouseClick("left",611,317,1,$mousespeed)
_WinWaitActivate("EDI Software","You have already cre")
MouseClick("left",160,161,1,$mousespeed)
_WinWaitActivate("EDI Software","Purchase Order Statu")
MouseClick("left",167,100,1,$mousespeed)
_WinWaitActivate("Purchase Orders","xtpBarBottom")
MouseClick("left",911,11,1,$mousespeed)
_WinWaitActivate("Shipments","xtpBarBottom")
MouseClick("right",98,204,1,$mousespeed)
MouseClick("left",132,251,1,$mousespeed)
$msgboxactiontimes = $msgboxactiontimes + 1
Next
MsgBox(0, "This has run", "This program has run "&$msgboxactiontimes&" times.")
#endregion --- Au3Recorder generated code End ---

So in my last bit of code, there are an ton of mouse clicks. I'm knew to auto it and need to adjust for screen resolution. How would I adjust my code to fit different screen resolutions?  I do this task as part of my job daily, and other tasks like it. It would be great that my programs wouldn't be debilitated once I change monitors. 

Would I have to run a function for each mouse click pair of coordinate? And, lets say you pick the first 3 mouse clicks out...what would that look like? I'm lost :-(

Edited by ryanadanderson

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  
Followers 0