Hot keys detection

B

Boki

Hi All,

The program is background running, when user press a pre-define hot
key, ex: ctrl+g

It will fire some other event.

Problem:

When program is running at background, it can't receive the keyboard
event, right ?
How we to detect the hot keys?


Thank you!

Best regards,
Boki.
 
P

Peter Duniho

Problem:

When program is running at background, it can't receive the keyboard
event, right ?
How we to detect the hot keys?

The short answer is that you don't. The whole point of the concept of a
window being background or foreground is that only the foreground window
gets user input. That way, the user is not surprised that something they
did affected something they aren't actually looking at.

The longer answer is that there are ways, using the native Win32 API, to
hook into the keyboard input events and detect input even when you're not
the foreground window. But you should think very carefully before
deciding to do that. It is almost never the right thing to do.

Pete
 
B

Boki

The short answer is that you don't. The whole point of the concept of a
window being background or foreground is that only the foreground window
gets user input. That way, the user is not surprised that something they
did affected something they aren't actually looking at.

The longer answer is that there are ways, using the native Win32 API, to
hook into the keyboard input events and detect input even when you're not
the foreground window. But you should think very carefully before
deciding to do that. It is almost never the right thing to do.

Pete

Can you provide which API :D ?

Whatever, thanks!
Boki.
 
P

Peter Duniho

Can you provide which API :D ?

Can I tell you which API to use to do something that I recommend against
doing?

Are you kidding me?

Seriously though, there are enough related words in my post that you
should be able to just enter them in the search for MSDN and get a useful
result. Try "hook", "keyboard", and "event".

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top