Jump to content

controlgetpos and true position within an app - problem


Go to solution Solved by jguinch,

Recommended Posts

When using ControlGetPos to determine control location in app window - I'm getting coordinates, that start not from the external borders of an app, but from internal guts. Which means, that header (the thing with app name) and left border is excluded.

This generates certain problem, because from what I can say - win8 and win7 have different container layouts. So my question. How to get control position in relation to complete gui of the app, or just absolute coordinates?

functional testing. multimedia recording. flowstone. mouseclick, hotkeys and modularity in general.

Link to comment
Share on other sites

There are ways to get the exact 'absolute' coords with the _winapi functions.

What are you actually attempting to do, though?  If you want to click it, use ControlClick...coords don't matter then.

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

It looks that after weekend forum update, my post disappeared.

The problem is, that this internal window of the app has it's own screen handles, so there is no way to use ControlClick on them. The only way is to use regular screen clicking and dragging. If I run the script on different win7/8 machine/layout, then everything is shifted, and the mouse no longer hits the item area. Header and border sizes also change when using windowed/maximized mode. So I need to get the position of a subwindow in relation to (0,0) coordinates of the screen or of the outer borderline of win aplication. Having true location (and size) of that control - I can scale parameters to hit proper positions.
 

I'm designing test scenarios, why the question?

functional testing. multimedia recording. flowstone. mouseclick, hotkeys and modularity in general.

Link to comment
Share on other sites

  • Solution

You can use WinGetPos with a control handle, so you will have its position/dimensions relative to the screen :

Run("notepad.exe")

$hWnd = WinWait("[CLASS:Notepad]")
$hEdit = ControlGetHandle($hWnd, "", "[CLASS:Edit; INSTANCE:1]")

$aEditPos = WinGetPos($hEdit)
ConsoleWrite("LEFT   : " & $aEditPos[0] & @CRLF & _
             "TOP    : " & $aEditPos[1] & @CRLF & _
             "WIDTH  : " & $aEditPos[2] & @CRLF & _
             "HEIGHT : " & $aEditPos[3] & @CRLF )
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...