problem with pyHook module

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris Westbrook

    #1

    problem with pyHook module

    I want to use the pyHook module to capture all keyboard input and write it
    to a file. I have a script that works fine with the command prompt, but I
    have a few issues I need help with. First, I want to be able to set up an
    html page that has a link to this script and have it start running and
    collecting output, and then use some keystroke like alt+f4 to terminate the
    application. It seems when I run this script from internet explorer after
    placing it in cgi-bin, the log file gets created but nothing is written to
    it. i'm running xampp with python 24 and all the necessary stuff.
    Eventually I'd like to try to get the shift key with a letter to indicate an
    upper cased letter, but first I at least want to get all the keys written to
    a file. Can anyone help? The sscript I'm starting with is below.
    #!c:\Python24\p ython.exe
    print "Content-type:text/html\n\n";
    import pyHook
    f = open('file.log' ,'w')
    def onKeyboardEvent (event):

    f.write(event.K ey)

    return True
    hm = pyHook.HookMana ger()
    hm.KeyDown = onKeyboardEvent
    hm.HookKeyboard ()
    if __name__ == '__main__':
    import pythoncom
    pythoncom.PumpM essages()

Working...