Link to home
Start Free TrialLog in
Avatar of rossryan
rossryan

asked on

Passing mouse and keyboard actions back to a window

How can I pass mouse and keyboard commands (after some filtering) back to a window? Perhaps a hook?
Avatar of AlexFM
AlexFM

Please describe what you need exactly.
Hook allows to intercept mouse and keyboard commands before window handles them. It may stop the message or allow to continue message handling. If this is what you need, see SetWindowsHookEx with parameters:
WH_KEYBOARD, WH_MOUSE - for local hook (inside of current process)
WH_KEYBOARD_LL, WH_MOUSE_LL - for global hook (for all processes).


Avatar of rossryan

ASKER

Hmm. In reference to my earlier question, I am redirecting window creation inside an OpenGL window. After remapping OpenGL -> Windows commands, I want the window to react as though there is no OpenGL layer (i.e. it is transparent).
Avatar of Kyle Abrahams, PMP
You should use the openGL for the keyboard and mouse . . .

IE:
  glutKeyboardFunc(keyboard);
  glutMouseFunc(mouse);

You misunderstand. Open Notepad.exe. Now, try to open Notepad.exe inside an OpenGL window. You cannot. They are incompatible.

What I am trying to do, is open Notepad.exe inside an OpenGL Window. Trying get OpenGL to draw Notepad.exe inside OpenGL, instead of Windows.

In this case, and for this question: I know about GLUT. The question is, when a user clicks on Notepad.exe inside the OpenGL window, GLUT captures mouse and keyboard commands. How do I get GLUT to forward those commands to Notepad.exe?

Notepad.exe is draw as a texture inside OpenGL. My program continually captures frames of Notepad from outside the OpenGL window, and imports them. When a user clicks or selects the Notepad texture, inside the OpenGL window, I want all GLUT commands translated and rerouted to the actual program, which exists outside OpenGL.

Any of this making sense?
Is this real Notepad or emulation drawn inside of OpenGL window?
Why do you work with GLUT?  As I remember, GLUT is used to write primitive OpenGL programs for beginners, it can create OPenGL window and handle mouse and keyboard messages.
What about creating of Editbox in the OpenGL window?
Diagrams:

Typical Windows Environment (aka your Desktop):

WindowsProc.ShellExecute() --------> Notepad.exe //You double-click on Notepad
WindowsProc.Paint() <----------------- Notepad.exe //Notepad draws its window
WindowsProc.Mousecallback() ------> Notepad.exe //Windows listens for mouse
WindowsProc.Keyboardcallback() ---> Notepad.exe //and keyboard. It passes arguments (you typing on the keyboard) to Notepad



My program (think 3D Desktop):
OpenGLWindow ------> WindowsProc.ShellExecute() ------> Notepad.exe //You double-click on Notepad in OGL window
OpenGLWindow <------ WindowsProc.Paint() <--------------- Notepad.exe //Notepad draws its window. OGL captures window.
OpenGLWindow ------> WindowsProc.Mousecallback() ----> Notepad.exe //OGL listens for mouse and keyboard.
OpenGLWindow ------> WindowsProc.Keyboardcallback() -> Notepad.exe //OGL passes arguments to Windows, which passes it on.

Essentially, Windows is the middleman for the OGL shell. Like coordinates and everything else, you need to translate between systems (OGL and Windows).

You've seen MS TaskGallery and Sun's Project Looking Glass, right?

http://wwws.sun.com/software/looking_glass/
ASKER CERTIFIED SOLUTION
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hmm. WindowsProc.Keyboadcallback() is just my conception of Windows callback...I'll check back on it for a real name or if it is accessible.