Solved

Passing mouse and keyboard actions back to a window

Posted on 2004-04-04
10
341 Views
Last Modified: 2010-04-15
How can I pass mouse and keyboard commands (after some filtering) back to a window? Perhaps a hook?
0
Comment
Question by:rossryan
  • 5
  • 3
  • 2
10 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 10753192
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
 

Author Comment

by:rossryan
ID: 10754189
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
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 10754558
You should use the openGL for the keyboard and mouse . . .

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

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: 10754933
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
 
LVL 48

Expert Comment

by:AlexFM
ID: 10755023
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
 
LVL 48

Expert Comment

by:AlexFM
ID: 10755025
What about creating of Editbox in the OpenGL window?
0
 

Author Comment

by:rossryan
ID: 10755198
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
 

Author Comment

by:rossryan
ID: 10755209
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
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 500 total points
ID: 10759503
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
 

Author Comment

by:rossryan
ID: 10762390
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

756 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