954,164 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Keyboard Hook or something similar

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

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.

brandonhorst
Newbie Poster
4 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

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 :D
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 :P).

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 ).

shadwickman
Posting Pro in Training
497 posts since Jul 2007
Reputation Points: 186
Solved Threads: 77
 

You are my hero.
Thanks so much, dude. You just made my life WAY easier.

This site is freaking sweet.

brandonhorst
Newbie Poster
4 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

Glad I could help :)
And welcome to DaniWeb haha.

shadwickman
Posting Pro in Training
497 posts since Jul 2007
Reputation Points: 186
Solved Threads: 77
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You