[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Requesting a hand with a simple Death Counter



Here's the classic PyHook example, approximately:


import pythoncom, pyHook

def OnKeyboardEvent(event):

  print event.ScanCode, event.Key

  print 'MessageName:',event.MessageName
  print 'Message:',event.Message
  print 'Time:',event.Time
  print 'Window:',event.Window
  print 'WindowName:',event.WindowName
  print 'Ascii:', event.Ascii, chr(event.Ascii)
  print 'Key:', event.Key
  print 'KeyID:', event.KeyID
  print 'ScanCode:', event.ScanCode
  print 'Extended:', event.Extended
  print 'Injected:', event.Injected
  print 'Alt', event.Alt
  print 'Transition', event.Transition
  print '---'

  # return True to pass the event to other handlers
  return False

# create a hook manager
hm = pyHook.HookManager()
# watch for all mouse events
hm.KeyDown = OnKeyboardEvent
# set the hook for keyboard
hm.HookKeyboard()
# wait forever
pythoncom.PumpMessages()




On Mon, Oct 27, 2014 at 11:39 PM, Alec Bennett <wrybread@xxxxxxxxx> wrote:
For win32api, you need to install the Python Windows Extensions.Â

For Pyhook, there's lots of examples out there, but maybe someone wants to work on your code for you.



On Mon, Oct 27, 2014 at 11:33 PM, PBRGamer <PBRGamerSNES@xxxxxxxxx> wrote:
Oh, and I tried the easy way with the win32api Âbut I can't get the
library's to recognize on my system for some reason. So I'd really like to
figure this out using only pygame and pyHook



--
View this message in context: http://pygame-users.25799.x6.nabble.com/Requesting-a-hand-with-a-simple-Death-Counter-tp1481p1487.html
Sent from the pygame-users mailing list archive at Nabble.com.