Is there a way I can use Python to control the size and position of a Mac Window?

Generally I want to write a program to run in the background on Mac and when I push a keyboard shortcut, the current active window would be resized and positioned to the way I have set.

Something similar to the tool called SizeUp on Mac.  I think this shouldn't be difficult to implement and would be fun to take a try.

I would appreciate any resources you could point me to.  Thanks.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The problem is that the window is represented as a data structure controled by its program, owned by its process. What you want to do is to manipulate with the data of another process. This what OS generally wants to prevent -- the running processes should be as much separated as possible and should not be allowed to interfere with other processes (unless the other process know).
If you have the right privileges, then you might use some programs to control other windows.

For X-windows for example there are tools like

There are probably similiar tools for Mac.

Normally these programs are rather simple to call from the command line and you can use.

subprocess.Popen() of python in order to start the apropriate commands.
Eoin OSullivanConsultantCommented:
Do you have a reason you want to use Python?  As pepr explains python is not a good option to manipulate other applications.

I'd recommend you look at AppleScript - as this does allow you certain access to application window parameters

Alternatively you have a selection of utilities that can perform window resizes or manipulate programs such as
QuickKeys -
iKey -
Keyboard Maestro -

You've probably looked at other window layout tools
Optimal Layout -
Divvy -
ShiftIt -
Moom -

I like BetterTouchTool as it has some nice window snapping and incremental resizing and its FREE -

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
thomaszhwangAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.