Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 349
  • Last Modified:

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?
0
rossryan
Asked:
rossryan
  • 5
  • 3
  • 2
1 Solution
 
AlexFMCommented:
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).


0
 
rossryanAuthor Commented:
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).
0
 
Kyle AbrahamsSenior .Net DeveloperCommented:
You should use the openGL for the keyboard and mouse . . .

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

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
rossryanAuthor Commented:
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?
0
 
AlexFMCommented:
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.
0
 
AlexFMCommented:
What about creating of Editbox in the OpenGL window?
0
 
rossryanAuthor Commented:
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.

0
 
rossryanAuthor Commented:
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/
0
 
Kyle AbrahamsSenior .Net DeveloperCommented:
So what if you say when you call a notepad:

GlutMouseFunc(WindowsProc.Mousecallback());
GlutKeyboardFunc(WindowsProc.Keyboadcallback());

Just be sure reset the function when you go out of the notepad.txt area and/or when the program closes.
0
 
rossryanAuthor Commented:
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.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 5
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now