I made a script to record the active window using win32gui of Python

If you're a software developer, you're often asked to include in your daily report what work you've done and how many minutes you've done. Even if you say that, it is difficult to keep a record when you are busy, so I made a script to do that on the premise that "If you keep a record of the active window, you can understand what you were doing." It was. There are likely to be other people who would be happy to use it, so I will publish it. If you're a programmer using an editor that shows the name of the file you're editing in the title bar, you can look back at what you were doing with this script later.

The completed script

Below: https://github.com/aikige/homeBinWin/blob/master/dumpForegroundWindow.py

Basic concept

  1. Use win32gui.GetForegroundWindow and win32gui.GetWindowText included in pywin32 to get the title of the Window currently running on Foreground. To do.
  2. Dump the obtained one with a time stamp.
  3. Perform the above process periodically (the interval can be changed with an argument).
  4. The log is recorded in a file by date. For the time being, the log is currently output to both the file and standard output.

Preparation for running the script

If you don't have pywin32 yet, please install it.

pip install pywin32

Environment confirmed operation

Python 3.8.1
pywin32 Version 227

Referenced

Recommended Posts

I made a script to record the active window using win32gui of Python
I made a program to check the size of a file in Python
I made a function to see the movement of a two-dimensional array (Python)
I found out by making a python script to record radiko while reading the code of the predecessors
I made a function to check the model of DCGAN
I tried to make a regular expression of "amount" using Python
I tried to make a regular expression of "time" using Python
I tried to make a regular expression of "date" using Python
I made a script to display emoji
I made a function to crop the image of python openCV, so please use it.
[Kaggle] I made a collection of questions using the Titanic tutorial
I made a script in python to convert .md files to Scrapbox format
Python: I want to measure the processing time of a function neatly
I want to create a window in Python
[Python] I tried to judge the member image of the idol group using Keras
[Circuit x Python] How to find the transfer function of a circuit using Lcapy
I made an appdo command to execute a command in the context of the app
I made a tool to automatically back up the metadata of the Salesforce organization
Python script to get a list of input examples for the AtCoder contest
Convert the cURL API to a Python script (using IBM Cloud object storage)
I made a program to look up words on the window (previous development)
Template of python script to read the contents of the file
I made a login / logout process using Python Bottle.
Cut a part of the string using a Python slice
I made a script to put a snippet in README.md
I made a Python module to translate comment outs
I made a command to markdown the table clipboard
I made a python library to do rolling rank
I tried using Python (3) instead of a scientific calculator
Python Note: The mystery of assigning a variable to a variable
I tried to summarize the string operations of Python
I created a script to check if English is entered in the specified position of the JSON file in Python.
[Python] I made an app to practice the subtle voice distinction of English words.
I tried to notify the update of "Become a novelist" using "IFTTT" and "Become a novelist API"
[Python] I made a system to introduce "recipes I really want" from the recipe site!
Python practice 100 knocks I tried to visualize the decision tree of Chapter 5 using graphviz
I want to take a screenshot of the site on Docker using any font
I made a python text
[Python / C] I made a device that wirelessly scrolls the screen of a PC remotely.
Add a function to tell the weather of today to slack bot (made by python)
I tried to find the entropy of the image with python
I replaced the Windows PowerShell cookbook with a python script.
I just changed the sample source of Python a little.
I want to start a lot of processes from python
I made a quick feed reader using feedparser in Python
I made a dot picture of the image of Irasutoya. (part1)
[Python] I tried to visualize the follow relationship of Twitter
I made a VGG16 model using TensorFlow (on the way)
I wrote a script to combine the divided ts files
I want to know the features of Python and pip
[Python] I tried collecting data using the API of wikipedia
I tried to make a stopwatch using tkinter in python
I made a dot picture of the image of Irasutoya. (part2)
I tried changing the python script from 2.7.11 to 3.6.0 on windows10
I made a Chatbot using LINE Messaging API and Python
A Python script that compares the contents of two directories
I made a script to say hello at my Koshien
I made a script in Python to convert a text file for JSON (for vscode user snippet)
I tried to compare the accuracy of machine learning models using kaggle as a theme.
I wrote a Python script that exports all my posts using the Qiita API v2
[Python] I want to make a 3D scatter plot of the epicenter with Cartopy + Matplotlib!