Saturday, August 16, 2008

Print active application and title using pywinauto

Code snippet below shows how to get the window title and application name of the active application. That is the application on top of the z-order. Need to install pywinauto to get this to work.

import pywinauto.application
import pywinauto.handleprops as _handleprops
import pywinauto.win32functions as _win32functions
import time

while 1:
    hwnd = _win32functions.GetForegroundWindow()
    print "Active Window title is %s"%(_handleprops.text(hwnd))
    print "Application name is %s"%(pywinauto.application.process_module(_handleprops.processid(hwnd)))
    time.sleep(2)    

~ts

No comments:

Installing TigerVNC in Ubuntu 24.04

Installing TigerVNC in Ubuntu 24.04 Ubuntu 24.04 supports RPD protocol but it behaves in a way that is not fit for my needs. The Desktop Sh...