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

x
?
Solved

Passing mouse and keyboard actions back to a window

Posted on 2004-04-04
10
Medium Priority
?
347 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
[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
  • 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
Industry Leaders: 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 2000 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

721 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