Keyboard Hook or something similar

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jul 2009
Posts: 3
Reputation: brandonhorst is an unknown quantity at this point 
Solved Threads: 0
brandonhorst brandonhorst is offline Offline
Newbie Poster

Keyboard Hook or something similar

 
0
  #1
Jul 12th, 2009
Hey Folks.

I'm writing a Python app using wx and I'd really like the ability to block the Capslock key at certain times. My current system has some unfortunate toggling of Hotkey Bindings and uses SendKeys, which results in some ugly keyboard light flashing and some seemingly random infinite loops. I'd really just like to disable the Capslock mode entirely.

I don't know if any of you are familiar with Autohotkey, but I'm essentially looking for
  1. SetCapsLockMode, AlwaysOff

PyHook has what I'm looking for, but I'd really rather not switch back to Python 2.5 if that was at all possible. So is there any behavior like a hook built into wx, or is there some other library that I could use? I've searched quite a bit and I'm at a loss.

It only needs to work on Windows. Thanks alot, folks.
Last edited by brandonhorst; Jul 12th, 2009 at 2:00 am.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 489
Reputation: shadwickman will become famous soon enough shadwickman will become famous soon enough 
Solved Threads: 76
shadwickman's Avatar
shadwickman shadwickman is offline Offline
Posting Pro in Training

Re: Keyboard Hook or something similar

 
0
  #2
Jul 12th, 2009
Hooray! I got pyHook working with Python 2.6 for Windows. I just downloaded the source and edited a few things, hacked it together and built. As far as I know, it all works with 2.6
You'd just need to manually install it to your Python's site-packages directory if you want it to be available like any other module.

You can do this on your own, or you can grab the zipped build that I have uploaded here (a much easier method ).

If you want to install it into your site-packages folder, navigate to it (C:\Python26\Lib\site-packages) and copy the pyHook folder into it. Then create a file in the site-packages folder named "pyHook.pth" and in it, type "pyHook". That's all. Now you should be able to pop-up IDLE and type "import pyHook" without any errors. Good luck!

EDIT:
This is tested and worked without error for me
And note, you'll need the win32 modules for Python 2.6 by Mark Hammond (here).
Last edited by shadwickman; Jul 12th, 2009 at 4:07 am.
"Two good old boys in a fire-apple red convertible. Stoned. Ripped. Twisted. Good people."
- Hunter S. Thompson

my photography
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 3
Reputation: brandonhorst is an unknown quantity at this point 
Solved Threads: 0
brandonhorst brandonhorst is offline Offline
Newbie Poster

Re: Keyboard Hook or something similar

 
0
  #3
Jul 12th, 2009
You are my hero.
Thanks so much, dude. You just made my life WAY easier.

This site is freaking sweet.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 489
Reputation: shadwickman will become famous soon enough shadwickman will become famous soon enough 
Solved Threads: 76
shadwickman's Avatar
shadwickman shadwickman is offline Offline
Posting Pro in Training

Re: Keyboard Hook or something similar

 
0
  #4
Jul 12th, 2009
Glad I could help
And welcome to DaniWeb haha.
"Two good old boys in a fire-apple red convertible. Stoned. Ripped. Twisted. Good people."
- Hunter S. Thompson

my photography
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for Python
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC