Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Keyboard Hooking (adding a few of my own)

Posted on 2004-04-27
15
Medium Priority
?
209 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

722 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