Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change window sizes/dimensions via Python

I want to write a program, preferably in Python, that will change the window size of any particular application I have open. E.g. say I have Notepad open and wish to make it 640x400 - my script would recognise the window and change its dimensions automatically.

Is there an available framework in Python for this or do I need to use another language?

like image 918
user1675111 Avatar asked Sep 05 '15 02:09

user1675111


People also ask

How do I resize a window to a specific size?

Press Alt + Space shortcut keys together on the keyboard to open the window menu. Now, press S. The mouse cursor will turn into a cross with arrows. Use the left, right, up and down arrow keys to resize your window.

Which method is used to change the size of window?

The resizeTo() method resizes a window to a new width and height.


1 Answers

import pygetwindow
win = pygetwindow.getWindowsWithTitle('Notepad')[0]
win.size = (640, 400)
like image 140
Mohsen Haddadi Avatar answered Sep 28 '22 03:09

Mohsen Haddadi