views:

96

answers:

3

I have a homepage need to count the usage frequency of Notepad or Calc application. Is there any Windows API that I can know the usage frequency of windows application?

A: 

I don't know about one, but You could quite easily achieve that by:

ex: using

cmd.exe -> tasklist

apply each 10 sec. (that would not load the CPU) - one good solution is to use python scheduler.

import sched, time
from subprocess import *
s = sched.scheduler(time.time, time.sleep)
def get_task():
    f=open("log",'wt')
    p=Popen("tasklist",stdout=f)
    p.terminate()
    p.close()

def analise_logs():
    # do some analise here

def print_some_times():
    while(1):
        print time.time()
        s.enter(5, 1, get_tasks, ())
        analise_logs()
        s.run()

do some awk (if you have cygwin), or powershell awk like processing on that file.

Count processes which interest you. Write result to another file with updated infos.

bua
+2  A: 

No. But you can write a service that will check applications in memory and do appropriate calculations. Few links:

Also, shell variant from bua is quite ready solution. You just need some parsing and updating the counter (not necessary in the database).

Andrejs Cainikovs
A: 

Take a look at my answer to How Do I Stop An Application From Opening and use the same technique. In essence when the application is launched your program is run and you can log any information that you require and then open the app.

Stephen Nutt