daveenguyen / atomacos

Automated Testing on macOS
https://daveenguyen.github.io/atomacos/
GNU General Public License v2.0
47 stars 13 forks source link

Setting the AXPosition or AXSize #17

Closed harveyf2801 closed 1 year ago

harveyf2801 commented 1 year ago

I've got a window that always loads up in my app at position x=780.0, y=222.0

I've been trying lots of different ways to change the window size and position however when I use component.setString("AXPosition", {0,0}) I keep getting the following error: atomacos.errors.AXErrorFailure: There is some sort of system memory failure.

If I use component.AXPosition = {0,0} I get no errors but the position is still not changed, however if I use component.AXPosition = 0 or any number at all it sets the position to x=0.0 y=1327.0 (the bottom left corner of my screen). ???

I must be doing something wrong but would be great to have some form of documentation for this.

harveyf2801 commented 1 year ago

after a bit of digging, for those with a similar issue setting window sizes / positions this is the code:

from ApplicationServices import AXValueCreate, kAXValueCGPointType
import Quartz.CoreGraphics as CG

x, y = 200, 300
point = CG.CGPoint(x=x, y=y)
component.AXPosition = AXValueCreate(kAXValueCGPointType, point)