PDA

View Full Version : Change position of another app's window




vadym.hulakov
Oct 22, 2010, 11:41 AM
I am using python and pyobjc. I need to change position of another app's window.

Information I have is title of window. Also I can get window number by using Quartz.CGWindowListCopyWindowInfo().



ulbador
Oct 22, 2010, 02:25 PM
As the "quick and dirty way", I would probably just call a shell script. You just would execute the command "osascript". You can make osascript tell the application or even the Finder to close or move windows.

vadym.hulakov
Oct 23, 2010, 05:25 AM
As the "quick and dirty way", I would probably just call a shell script. You just would execute the command "osascript". You can make osascript tell the application or even the Finder to close or move windows.

I think that "quick and dirty way" is ok for this case. But I have problems with osascript. I use command:

osascript -e 'tell application "FooApp" set bounds of window 1 to {100, 100, 500, 500}'

I get error "execution error: FooApp got an error: Can't set bounds of window 1 to {100, 100, 500, 500}. (-10006).

Interesting that this command work fine for TextEdit

osascript -e 'tell application "TextEdit" set bounds of window 1 to {100, 100, 500, 500}'

What do I need to do make my application compatible with osascript?