Loading [MathJax]/jax/output/HTML-CSS/jax.js

Ярлыки

среда, 20 марта 2013 г.

Python: your time to each program Windows

Script that write how many time each program used in Windows bytitleofshowwindow.


import sys

#module for work with windows 32bit
import win32gui

txt=''
time1=time.time
#times dictionary
appdict=dict
while True:
#pause (it's influence to accuracy)
    time.sleep5
#title of the current window
    newtxt = win32gui.GetWindowText(win32gui.GetForegroundWindow)
#if window was changed than update time of beginning work with other window
    if txt!=newtxt:
        time2=time.time
#add previous time to dict
        if appdict.gettxt!=None:
            appdicttxt=appdicttxt+roundtime2,0-roundtime1,0
        else:
            appdicttxt=roundtime2,0-roundtime1,0
        txt=newtxt
        time1=time.time
    f=opentimerep.csv,w
    csvwr = csv.writer(f, delimiter=';',lineterminator='\n')
#We write only window that summary time over 5 minutes (Other window is non-influential).
    for i in appdict.items:
        if i1>=300:
            csvwr.writerowi
    f.close

Комментариев нет:

Отправить комментарий