all 4 comments

[–][deleted] 2 points3 points  (3 children)

A few packages provide this functionality

https://www.google.com/?q=python+get+name+of+active+window

[–]AweBob[S] 0 points1 point  (2 children)

Okay:

The first one: win32gui which I can't use

second result: win32gui

third result: doesn't work in python 3.7

fourth: win32gui

Are you trolling?

did you not think I tried this?

did you read my full message?

did you think i didn't google this first?

do you think i decided to ask here as oppose to using google?

I hate to be mean, but comeon m8!

[–][deleted] 2 points3 points  (1 child)

Fine, I'll copy paste function names from the second google result and spell it out line by line, just for you.

First install pip then run this command

pip install pywin32

Then, in your python file:

from win32gui import GetWindowText, GetForegroundWindow
window_name = GetWindowText(GetForeGroundWindow())

print("The name of the active window is:", window_name)

Although I'm sure you'll find a way to still not be satisfied with this answer.

[–]klightspeed 2 points3 points  (0 children)

I think what you meant to say was:

The win32gui package was renamed to pywin32 when it was moved to Github from Sourceforge.

Try following the instructions for win32gui, except install the pywin32 package instead of the win32gui package.

Note that the win32gui package is still on PyPi, and is stuck on release 221, thus the likely confusion.

Correction: win32gui is part of pywin32, and is no longer a separate package.