Maxzor

GetControlPos problem

5 posts in this topic

Hello,

I am trying to automate a job on an app that I think tries to prevent it : my app refuses to make some action with Controlclick, however with MouseClick it is fine.

So I am trying to get absolute pos of my control, followed code from this thread :

My problem is that AutoIt Window info gives me this :

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>>>> Window <<<<
Title: xx
Class: WinDevObject
Position: -9, -9
Size: 1698, 1018
Style: 0x17CF0000
ExStyle: 0x00000300
Handle: 0x00000000000902F4

>>>> Control <<<<
Class: Button
Instance: 129
ClassnameNN: Button129
Name: 
Advanced (Class): [CLASS:Button; INSTANCE:129]
ID: 
Text: 
Position: 1268, 54
Size: 32, 40
ControlClick Coords: 0, 0
Style: 0x50000000
ExStyle: 0x00000000
Handle: 0x0000000000071098

>>>> Mouse <<<<
Position: 1270, 85
Cursor ID: 0
Color: 0x9F4517
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

Mouse is here at exact upper-left-hand corner of button129, but there is a significant discrepancy between control pos and mous pos. When on value returned by ControlPos method, mouse is actually not hovering anymore onto control.
How is this happening?
 

Best regards ( I admit I did not browse forum carefully, please bear with my noobing...)

Share this post


Link to post
Share on other sites



You can use relative coords to the client area. For example MouseClick to center of button

Opt("MouseCoordMode", 2)

WinActivate("[Class:WinDevObject]")
$aPos = ControlGetPos("[Class:WinDevObject]", "", "Button129")
If IsArray($aPos) Then
  $iX = $aPos[0] + $aPos[2] / 2
  $iY = $aPos[1] + $aPos[3] / 2
  MouseClick("", $iX, $iY)
EndIf

 

Share this post


Link to post
Share on other sites

Maxzor,

I imagine it is the DPI setting - as explained here.

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

Thank you for your inputs,

I checked and my problem is not related to DPI settings, I believe it is more of a "window docking" issue.

My windows when max expanded are all placed at -8,-8,
and sub-tiles compounds only make things worse adding discrepancies.

Share this post


Link to post
Share on other sites

What I meant is that wether im with 100, 125 or 150% dpi, the problem is here : the controls are mostly not where they say they are :)

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