Jump to content

Need help with coordinates (aspect ratio/resolution)


Recommended Posts

Hi...

I have a small script that automates a few clicks and control sends. However, I have a problem running the same script successfully using monitor resolutions different than mine.

For example:

My desktop resolution is 1440 x 905

An accurate/working instruction/line in my script that clicks on a radio button reads like this:

MouseClick("left",333,15,1,0)

However, if I want to do the same in another machine with a resolution of 1366 x 768 the line above fails. The equivalent and working code for this other resolution is:

MouseClick("left",430,17,1,0)

Now, the issue is, I can't anticipate the resolution of my script users thus, I need to somehow state the correct/corresponding coordinates in my script so that it works with the different aspect rations/resolutions they have.

I use the AutoIt Window Info tool to get the coordinates and select the Coord Mode = Client option from the menu. In my script, I have these options:

AutoItSetupOption("MouseCoordMode",2)
AutoItSetupOption("CaretCoordMode",2)
AutoItSetupOption("PixelCoordMode",2)

I imagine everyone out there but me knows how to do this - and I feel ashamed about it... but I am terribly lost here after spending many hours with different ideas and searches for examples. I really appreciate if someone could please help!!

Link to comment
Share on other sites

> Why use MouseClick on a Radio button when you could do this with ControlClick?

If I use the ControlClick function, I also have to speciy the Coords...

For instance, with my base resolution (1440 x 900), the ControlClick coordinates are 317,13

The equivalent user resolution (1366 x 768) ControlClick coordinates are 395,17...

The issue is the same unless there's something more to this.

Link to comment
Share on other sites

Read the help-file carefully and try this code:

msgbox(64, "", "Go to start menu and open Run Dialog, once it opens I will click OK button")
WinWaitActive("Run", "")
ControlClick("Run", "", "[TEXT:OK]", "Primary")

I didn't specify coordinates!!

Edited by MKISH

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Link to comment
Share on other sites

Thanks Spammer,

In your ControlClick you are able to specify "[TEXT:OK]" because you can see the text of the button with the Info Tool but the Powerbuilder form I am reading/scanning does not offer me the visible text for the radio button options. I can see the text for some of the other controls in the form but not for the options in the desired radio button. I will try to see if the script is able to detect the intended option by using your suggestion... perhaps that's all I needed to do.

Link to comment
Share on other sites

point the AutoIt Window Info tool to radio button and tell us the output.

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Link to comment
Share on other sites

>>>> Control <<<<

Class: pbdw90

Instance: 2

ClassnameNN: pbdw902

Name:

Advanced (Class): [CLASS:pbdw90; INSTANCE:2]

ID: 1007

Text:

Position: 17, 2

Size: 393, 33

ControlClick Coords: 317, 13

Style: 0x56000000

ExStyle: 0x00000000

Handle: 0x00010700

>>>> Mouse <<<<

Position: 334, 15

Cursor ID: 0

Color: 0xFFFFFF

Link to comment
Share on other sites

The code:

WinWaitActive("<Window Title>", "")
ControlClick("<Window Title>", "", "[Class:pbdw90; Instance:2]", "Primary")

Change <Window Title> according to your need

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Link to comment
Share on other sites

I am probably failing to explain... When you use the Info Tool on a form like the RUN form, the tool says text OK, text CANCEL and so forth... The control I need to click doesn't reveal that to the Info Tool... that's why I figure I am stuck having to hit whatever option I need via coordinates.

Link to comment
Share on other sites

NearMadness

$DW =@DesktopWidth
$DH = @DesktopHeight

Switch $DW&'x'&$DH
    Case '1280x1024'
        $x=15
        $y=35
    Case '1024x768'
        $x=25
        $y=45
    Case '1280x768'
        $x=15
        $y=45
    Case Else
        Exit
EndSwitch

MouseClick('left', $x, $y, 1, 0)

;i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!i!
Run('Calc.exe')

$hWnd = WinWait("[CLASS:SciCalc]", "", 5) ; без таймаута (5) ожидание бесконечно
If Not $hWnd Then
    MsgBox(4096, 'Error', 'Exit')
    Exit
EndIf

$WGP=WinGetPos($hWnd)
If Not @error Then
    MouseClick('left', $WGP[0] + 75, $WGP[1] + 153, 1, 0)
EndIf

; WinClose($hWnd)
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...