0

Goal: Arrange window/app to a specific position and size on macOS screen

I've tried to achieve it using Apple-script, here is an example

tell application "System Events" to tell application process "Google Chrome"
    activate
    set frontmost to true
    tell window 1 to set {size, position} to {{1920 / 3, 996 / 2}, {0, 0}}
end tell

Since, I use Apple-script I have to uncheck sandbox from Xcode project settings which I hate it. I want my app to be part of Appstore, I assume to do that I should be able to mimic the above apple-script using Accessibility APIs but I am not quite sure where to start as it is very unclear where to start.

Tech goal: Able to arrange app on the screen using Accessibility APIs

Any guidance or working example would be great.

user4150758
  • 384
  • 4
  • 17
  • Does this answer your question? [Window move and resize APIs in OS X](https://stackoverflow.com/questions/614185/window-move-and-resize-apis-in-os-x) – Willeke Sep 30 '22 at 16:25
  • Or [Move other windows on Mac OS X using Accessibility API](https://stackoverflow.com/questions/21069066/move-other-windows-on-mac-os-x-using-accessibility-api) – Willeke Sep 30 '22 at 16:26
  • Or [set the size and position of all windows on the screen in swift](https://stackoverflow.com/questions/47480873/set-the-size-and-position-of-all-windows-on-the-screen-in-swift?noredirect=1&lq=1) – Willeke Sep 30 '22 at 16:28
  • You can also try 'Scripting Bridge' (Google it). In short, you can ask any (or most) macOS Apps to create an ObjC header file. This includes the Finder. Using the header, you can control many elements of a given App. I'd try that also – bauerMusic Oct 01 '22 at 17:29
  • @Willeke unfortunately the first link is using depreceated API and rest of the links doesn't have a usecase to specify the app. – user4150758 Oct 04 '22 at 09:35
  • @bauerMusic unfortunately no luck around to create an ObjC header file. Do you have an example to share? – user4150758 Oct 04 '22 at 09:36
  • Try this: `sdef /System/Library/CoreServices/Finder.app | sdp -fh --basename Finder`. Should create a `Finder.h` in current location (which is home by default) – bauerMusic Oct 04 '22 at 11:57

0 Answers0