Jump to content
Sign in to follow this  
ags911

Detect Resolution and change coordinates using elseif statements

Recommended Posts

ags911

I have a script that has to work on multiple resolutions but each resolution has slightly different co-ordinates due to automatic UI scaling. I have had to make separate files for each but would like to implement them all in one script. I have a similar program written for Java which uses else if statements to use different co-ordinates for each resolution after it has been detected. I'm not good with Java so I would like to implement this on AutoIt before later making a Java version.

 

This is a snippet of the autoit code I have.

ToolTip("1 - Search")
MouseClick("Left", @DesktopWidth *0.823, @DesktopHeight *0.925, 1, 25)

ToolTip("2 - Buy Now")
MouseClick("Left", @DesktopWidth *0.83, @DesktopHeight *0.798, 1, 27)

ToolTip("3 - OK")
MouseClick("Left", @DesktopWidth *0.555, @DesktopHeight *0.596, 1, 15)

ToolTip("4 - OK Clear Error")
MouseClick("Left", @DesktopWidth *0.49, @DesktopHeight *0.597, 1, 30)

ToolTip("5 - Back to Search")
MouseClick("Left", @DesktopWidth *0.161, @DesktopHeight *0.108, 1, 15)

 

This is a snippet of a java code I used.

Thanks.

private static void goToSearch(double maxX, double maxY, Robot bot) throws InterruptedException {

    int currentX = 0;

    int currentY = 0;

    if (maxX == 2650 && maxY == 1440) {

        currentX = 734;

        currentY = 1316;

    } else if (maxX == 1920 && maxY == 1200) {

        currentX = 551;

        currentY = 1096;

    } else if (maxX == 1920 && maxY == 1080) {

        currentX = 551;

        currentY = 1042;

    } else if (maxX == 1680 && maxY == 1050) {

        currentX = 482;

        currentY = 959;

    } else if (maxX == 1440 && maxY == 900) {

        currentX = 413;

        currentY = 822;

    } else if (maxX == 1366 && maxY == 768) {

        currentX = 392;

        currentY = 741;

    } else if (maxX == 1280 && maxY == 800) {

        currentX = 367;

        currentY = 731;

Share this post


Link to post
Share on other sites
JLogan3o13

@ags911 can you please explain what your end goal is with the AutoIt script? There is almost certainly a much better way of accomplishing what you're after than with unreliable MouseClicks based on screen resolution (as you are finding out).


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
ags911

Thanks for the reply. Please find the file attached. The mouse interacts with different elements onscreen of an online game via google chrome. Do you have anything in mind? The elements change and scale slightly for each resolution so I've had to compile a different script for each. The idea was that I could put everything into one simple script that detects the monitor resolution and automatically uses the script for that resolution.

PAB Forum - 1920 x 1080 - Speed (Slow).au3

Share this post


Link to post
Share on other sites
JLogan3o13

Unfortunately, you seem to have missed the forum rules during your time here. Please read them now, especially the part on game automation, and you will see why this thread is now locked.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Similar Content

    • Raj0813
      By Raj0813
      Launch the web application which has security certificate associated. On launching we get "Select a Certificate from the list of certificates" . how to handle this certificates using AutoIT and certificates are in a drop down. i have only chrome browser to launch the application.  do i need to install autoIt or just the add jar files and dll to it. it is not a pop up.
      Tried adding the certificate to trusted source dint work.. 
      Please find the screenshot attached for the screen obtained.

    • c1one
      By c1one
      Something simple enough, and I am sure it's an oversight, but I have not been able to track this down. The entire script is attached, but here is the point of failure.
      Note: I am getting the "Error: subscript used on non-accessible variable" but I thought the initial line of:
      AutoItSetOption('MouseCoordMode', 0)
      Should address that issue? 
      <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
      ; Install updates (minimized and updating for many minutes)
      ; Updates Not Installed Screen
         ; Wait for updates to complete
      WinWait("ProSeries Update")
         ; Wait just over 9 minutes to ensure popup is ready (test alternative to WinWait)
      Sleep(550000)
         ; Set focus on Product Licenses window
      WinActivate("ProSeries Update")
         ; Send Mouse Click to Install Now button
      MouseClick ( "left" [, 581, 362 [, clicks = 1 [, speed = 10]]] )
      ; end Installing Updates screen
      >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       
      Thanks for any insights!
      c1one
      ProSeries2017_No_Customer_Info.au3
    • XaelloNegative
      By XaelloNegative
      Hi team,
      I have a "well-built" autoIt exe app. Its running smooth until I open another application that when I run through the window info tool, returns as "SunAwtFrame". After running said application, my "well-built" autoIt exe app ceases to run.
      What seems to be the problem here and is there a possible turn around for it? Any suggestion or recommendation will be greatly appreciated. Thanks in advance.
      ~XN~
    • dadalt
      By dadalt
      Hi!
      I have a button where I need to close it!
      I was doing through  clicking same position in screen but there are some id's that have different sizes.
      What are the possible ways to click this closable button?
      Is there a way to close it through id? Is there a way to get it's position through it's ID?  
      Thanks in advance!


    • Miliardsto
      By Miliardsto
      Hello I got this script works below and I want to do not move cursor on screen when action is performed.
      Opt("MouseCoordMode", 1) ; cause it gets whole screen coords Local $x, $y Local $search = _ImageSearch('item.bmp', 0, $x, $y, 0) If $search = 1 Then MouseMove($x, $y,0) MouseClick("right", $x, $y)) MouseMove($xMiddle, $yMiddle,0) MouseClick("left", $xMiddle, $yMiddle) EndIf I changed this above to this below and what happen is. It clicks right button and then left button but not move mouse to $x $y and then to $xMiddle $yMiddle.
      Opt("MouseCoordMode", 1) ; cause it gets whole screen coords Local $x, $y Local $search = _ImageSearch('item.bmp', 0, $x, $y, 0) If $search = 1 Then ControlClick("","",0,"secondary",1,$x,$y) ControlClick("","",0,"primary",1,$xMiddle,$yMiddle) EndIf If needed I got handle in var $hwnd
      Please tell me how parameters in ControlClick would like be
×