Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the name of the active window

Tags:

python

windows

I want to write a python script on Windows that saves the title of the program that the user uses at a given time like the http://www.rescuetime.com . I don't want to use rescuetime because of privacy consideration but instead write a script that does something similar myself to capture data about how much I use my computer.

Is there some easy command that I can use to read that information?

like image 486
Christian Avatar asked Mar 04 '09 00:03

Christian


People also ask

What is the active window called?

The window in front (foreground) of all other open windows, on a graphical user interface. For example, the Internet browser window you are using to read this web page is considered the active program or active window.

How is an active window display?

Active glass or window display is the most advanced automobile technology in cars. The devices-based on this technology can be tuned for drivers. For example, turn-on speed and turn by turn directions display when you receive a phone call.

Which is located at the top of the active window?

The title bar shows the name of the application, map, or table. If more than one window is open, the title bar of the active window has a color and intensity different from other title bars. The menu bar contains available menus from which you can choose commands.


1 Answers

It might already be too late, but here's what should work on most operating systems:

import pyautogui
window_title = pyautogui.getActiveWindowTitle()

(I'm not sure if it works for Ubuntu, but Mac Os, Linux and Windows are normally supported)

like image 97
Daveloper Avatar answered Sep 21 '22 02:09

Daveloper