Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I maximize a specific window with Python?

Tags:

python

windows

I'm trying to maximize a specific window with python...

Here is the deal: I have a script that opens 2 firefox windows (selenium rc), and I need to maximize the second window, the last one that opens... How can I do it?

I'm using this command

window = win32gui.GetForegroundWindow()
win32gui.MoveWindow(window, 0, 0, 1440, 900, True)

that works perfectly, but only with the focus window... and the second window of firefox witch opens with the script doesnt get focused...

like image 206
Bruno 'Shady' Avatar asked May 07 '10 18:05

Bruno 'Shady'


1 Answers

This should work

import win32gui, win32con

hwnd = win32gui.GetForegroundWindow()
win32gui.ShowWindow(hwnd, win32con.SW_MAXIMIZE)
like image 108
ars Avatar answered Oct 13 '22 11:10

ars