Solved

Keyboard Hooking (adding a few of my own)

Posted on 2004-04-27
15
207 Views
Last Modified: 2010-04-01
Is it possible to rewrite the keyboard callback so that I can add my own keyboard messages? The problem I am faced with is as follows: I need to send keystrokes to another window (non-active). Every piece of code I have come across needs the window to be active...perhaps I can get around this by installing a callback. How exactly do I send keystrokes (say, the letter "n") to an app?

I've figured I'll use SendMessage with a user-defined lparam to active the code, hWnd for the window, and...
0
Comment
Question by:rossryan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
15 Comments
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 10936424
could you re-route through a file?

IE: send everything to a file and then Sendmessage from that?

Just a thought, I'm not really sure though.
0
 
LVL 8

Expert Comment

by:_corey_
ID: 10940333
I don't see why you couldn't catch teh WM_KEYUP messages in your default window proc/event handler.  I'm not sure you'll need a custom keyboard hook because your control will be active, right? And you just don't want the target window to have to be active.  Am I wrong?

Then send commands via PostMessage or SendMessage.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:rossryan
ID: 10942346
Aright...here's the scenario: I have a large OpenGL window. That completely covers the desktop.

I have code from Feng Yuan [MSFT] which allows me to hook into the windows, on that desktop.

So even when the windows are completely covered by my large window, I can get a snapshot of them. And create texture equivalents inside OpenGL.

These windows do not have focus. They are not active. They cannot be active or have focus.

These windows are regular windows such as "Word" or "Notepad". They are not controls.

I need only the code to send a keyboard command to one of those windows. The general idea is that when someone selects the "Notepad" texture in the OpenGL window, all keyboard output will be redirected to the "Notepad" window. I am interested in only the redirection part, I already know how to get keyboard output from inside OpenGL.
0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 10944692
You have to give a window the focus, and then initiate a callback like:

//notepad has focus.

GlutKeybFunc(Windows_Callback_forNotepad());


Just make sure you re-initialize GlutKeybFunc to your own handler after you are done with notepad or said application.

0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 10944697
0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 10944698
Oh, wait.  LOL.  That didn't work for you?
0
 

Author Comment

by:rossryan
ID: 10945565
;) True enough. What I am trying to accomplish ranks up there in difficulty.

Why can't I push my own keyboard messages through the keyboard callback? I do know the syntax, or if it is possible.


Keep this in mind.->These windows do not have focus. They are not active. They cannot be active or have focus.

Goto http://workspaces.gotdotnet.com/4DDesktop. Download the latest screenshot (under releases), and you may understand what I have to contend with...
0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 10952648
Why can't they have focus like a normal OS?

What if you used a sendmessage function to send it that way?  

The only other think I could think of would be overwriting the buffer to add in what you want.
0
 

Author Comment

by:rossryan
ID: 10965089
Becuase 1.) It runs on Windows. 2.) The texture window is not the real window.

Window's creates the real window, and my program copies the image of that window into OpenGL. If the real window has focus, then my program does not...
0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 10981853
try send message(hwnd, wm_char, ascii char of letter, 20003);




0
 

Author Comment

by:rossryan
ID: 11020242
Interesting. No dice though. Characters simply do not show up.
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 11293886
PAQed, with points refunded (500)

Netminder
EE Admin
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question