Advertisement

detecting key presses in a process

Started by September 05, 2004 06:37 AM
12 comments, last by Jolle 20 years, 3 months ago
I have a c++ program with a window, then i destroy the window, but keep the program running, as a process. the standard method of key detection

if (keys['W'])
{
  ...
}
this doesn't work, how else can I detect key presses.
www.stickskate.com -> check it out, some gnarly stick skating movies
Just an idea... never tried it...


What if you move the key message detection routine (WM_KEY...)
next to the WM_QUIT detection in the main loop? because the key message will not be sent to the window anymore...
The world isn't unpredictable. It's CHAOTIC.
Advertisement
ill try, and let you know.
www.stickskate.com -> check it out, some gnarly stick skating movies
It didn't work, sorry but thanks for trying.

I am using the code from lesson one, what i want to do, is have some code that lets me detect key presses after the KillGLWindow command, and before the return in the WinMain function
www.stickskate.com -> check it out, some gnarly stick skating movies
You only get Key Messages as long as your window is present / your Window Message Loop runs. So after the HWND gets invalid, there is no possibility to get Key Messages the easy way. But you could use Direct Input, it doesn't need a window.

Quote: Original post by Wintermute2004
You only get Key Messages as long as your window is present / your Window Message Loop runs. So after the HWND gets invalid, there is no possibility to get Key Messages the easy way. But you could use Direct Input, it doesn't need a window.


DirectInput - does - need a window (SetCooperativeLevel()), but it doesn't need it to be on the foreground (aka in focus).
Advertisement
Quote: Original post by Pipo DeClown

DirectInput - does - need a window (SetCooperativeLevel()), but it doesn't need it to be on the foreground (aka in focus).


Are you sure ? Well, may be.
I need a program that can run in the background, and not be on the taskbar. Sortof Like how windows detects ctrl alt del and alt tab etc...

Can I destroy the Window but keep HWND valid?

There must be a way to do this?
www.stickskate.com -> check it out, some gnarly stick skating movies
I solved the problem, I was reading some stuff on msdn when i came across the GetKeyState() func, whic works perfectly
www.stickskate.com -> check it out, some gnarly stick skating movies
Great, just what we need. More trojan-horse programmers.

Take a look at his profile.

This topic is closed to new replies.

Advertisement