Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting 'KeyUP' event from other applications.

Status
Not open for further replies.

Siberd

Technical User
Jun 24, 2001
35
0
0
US
Hello,

I would like to trigger an event in an application when the user releases a key. I want the trigger to happen, even if they do not currently have the application in focus.

I have no idea how this may be acheived, and have done a quick search of the forum already.

Many thanks,



/Sib
Thar ain't nuttin a good can o' raid won't fix!
 
Should have searched harder ... ;-)

Have a look at my code in thread222-118564. Obviously instead of WM_KEYDOWN (which that example uses) you'll want to check for WM_KEYUP instead
 
Many thanks for your reply.
After reading through the code you posted there, and making a few changes for it to work in my application, (mainly, changing WM_KEYDOWN to WM_KEYUP and then calling my sub from the Function LowLevelKeyboardProc thusly:

check_and_send (HookStruct)

I've been unable to trigger a response. While the application is in focus, the old methods I had used to capture the keyup function normally, however, when the app is running, and I have another window in focus, nothing happens.

Have I called my sub improperly?

/Sib
Thar ain't nuttin a good can o' raid won't fix!
 
Scratch that. I found the problem.

Although, now, on a keyup the application, and VB both crash, sadly, I don't get to see the error message.

/Sib
Thar ain't nuttin a good can o' raid won't fix!
 
another quck search of this forum would indicate that you should run your program from within VB when you are subclassing...
 
Subclassing and hooking are not quite the same thing.

However, they do have two major similarities: you should never debug a live hook or subclass procedure (whether the debugging is deliberate - e.g. a break or watch point - or not - e.g. a runtime error - try and clear those up first without the hook/subclass in place), nor should you let the program exit whilst the hook or subclass is in place; the IDE will very likely explode in both cases (sometimes you are lucky and it appears to work, but you are just storing up trouble for later)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top