943,567 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Unsolved
  • Views: 1999
  • Python RSS
Jul 12th, 2009
0

Keyboard Hook or something similar

Expand Post »
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
Python Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
brandonhorst is offline Offline
4 posts
since Jul 2009
Jul 12th, 2009
0

Re: Keyboard Hook or something similar

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.
Reputation Points: 186
Solved Threads: 77
Posting Pro in Training
shadwickman is offline Offline
495 posts
since Jul 2007
Jul 12th, 2009
0

Re: Keyboard Hook or something similar

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

This site is freaking sweet.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
brandonhorst is offline Offline
4 posts
since Jul 2009
Jul 12th, 2009
0

Re: Keyboard Hook or something similar

Glad I could help
And welcome to DaniWeb haha.
Reputation Points: 186
Solved Threads: 77
Posting Pro in Training
shadwickman is offline Offline
495 posts
since Jul 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: Tkinter scrollbars
Next Thread in Python Forum Timeline: function that modifies global variable of my choice





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC