Solved

Passing mouse and keyboard actions back to a window

Posted on 2004-04-04
10
335 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 39

Expert Comment

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

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

0
 

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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 39

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

705 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now