Solved

Keyboard Hooking (adding a few of my own)

Posted on 2004-04-27
15
198 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
15 Comments
 
LVL 39

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 7

Expert Comment

by:vijay_visana
ID: 10938138
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
 

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 39

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 39

Expert Comment

by:Kyle Abrahams
ID: 10944697
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 39

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 39

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 39

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
maze travler 6 47
Fully specialized class template function 21 118
I could not build boost code, 10 55
Add values of each row in an array 3 35
Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

759 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now