Click to See Complete Forum and Search --> : Detecting the Alt state
shree
April 4th, 2001, 01:30 PM
In my application, I would like to change the icon when the user presses Alt (Alt only, no other character, so i cannot use the KeyDown Event). How do I do it?
I plan to use a global boolean variable AltPressed and a timer that ticks every 100 ms, and use GetKeyState in each timer tick to detect the Alt State.
Is there a neater solution?
Nanderson
April 4th, 2001, 03:16 PM
Another choice would be to make a keyboard hook, so that all key events are seen by the hook. That way you can ignore all non-Alt key events and then toggle your global variable on the Alt events. I have recently been looking into keyboard hooks for another project and I have a couple of good sites to check out depending on what you want to do.
If you want a local hook [only recieves keystrokes from within your application], take a look here:
http://vbaccelerator.com/codelib/hook/vbalhook.htm
If you need a system wide hook, I found a neat control that will do it:
http://www.scottandmichelle.net/scott/code/index2.mv?codenum=082
Hope this helps.
Nathan
http://jsprod.odigo.com/share/servlets/OnLineR?userId=2986792&pId=odigo&design=3&tool=signature
shree
April 4th, 2001, 10:56 PM
Thanks,
And I got hooked onto something else there - the Cool Menu. I was looking for a method to make my menus better.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.