Passing on Hardware key press on

  • Thread starter Thread starter farseer
  • Start date Start date
F

farseer

Hi,
i can detect hardware keys fine on my device. however, i have a
problem passing that key press on it seems. i'd like to give an
example.
i have my hardware key (code 196) assigned to Tasks. Once i use
registerHotkey for key 196, and i press that key, the tasks app does
not pop up. I tried using keybd_event to pass that key on, but even
doing that, the Tasks application does not pop up. This does not
happen for normal alpha-numeric characters (if i register them, i can
easily pass them on). Does anyone else have this problem? any advice
on how to work around?

thank you
 
i had to do the following to make this work. i'd like to understand
why...in the below case, key =196

keybd_event(key, 0, KeyUp, KeyDown);
keybd_event(key, 0, KeyDown, KeyDown);

the above works. before i was doing this:

keybd_event(key, 0, KeyDown, KeySilent);
keybd_event(key, 0, KeyUp, KeySilent);

why does one work and not the other?
 
Can you show KeyUp, KeyDown, KeySilent constants:- maybe you have
incorrect values? These constants should be something like this:

const int KEYEVENTF_KEYDOWN = 0;
const int KEYEVENTF_KEYUP = 2;
const int KEYEVENTF_SILENT = 4;

and here is a working example:

keybd_event(key, 0, KEYEVENTF_KEYDOWN, 0);
keybd_event(key, 0, KEYEVENTF_KEYUP, 0);
 
those are the values i have has well. i notice u are using a value of
0 for the last parameter, what is the significance/meaning of that?

Sergey said:
Can you show KeyUp, KeyDown, KeySilent constants:- maybe you have
incorrect values? These constants should be something like this:

const int KEYEVENTF_KEYDOWN = 0;
const int KEYEVENTF_KEYUP = 2;
const int KEYEVENTF_SILENT = 4;

and here is a working example:

keybd_event(key, 0, KEYEVENTF_KEYDOWN, 0);
keybd_event(key, 0, KEYEVENTF_KEYUP, 0);



--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com

i had to do the following to make this work. i'd like to understand
why...in the below case, key =196

keybd_event(key, 0, KeyUp, KeyDown);
keybd_event(key, 0, KeyDown, KeyDown);

the above works. before i was doing this:

keybd_event(key, 0, KeyDown, KeySilent);
keybd_event(key, 0, KeyUp, KeySilent);

why does one work and not the other?
 
See MSDN for parameters description:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceui40/html/cerefKeybd_event.asp


--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com

those are the values i have has well. i notice u are using a value of
0 for the last parameter, what is the significance/meaning of that?

Sergey said:
Can you show KeyUp, KeyDown, KeySilent constants:- maybe you have
incorrect values? These constants should be something like this:

const int KEYEVENTF_KEYDOWN = 0;
const int KEYEVENTF_KEYUP = 2;
const int KEYEVENTF_SILENT = 4;

and here is a working example:

keybd_event(key, 0, KEYEVENTF_KEYDOWN, 0);
keybd_event(key, 0, KEYEVENTF_KEYUP, 0);



--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com

i had to do the following to make this work. i'd like to understand
why...in the below case, key =196

keybd_event(key, 0, KeyUp, KeyDown);
keybd_event(key, 0, KeyDown, KeyDown);

the above works. before i was doing this:

keybd_event(key, 0, KeyDown, KeySilent);
keybd_event(key, 0, KeyUp, KeySilent);

why does one work and not the other?
 
Back
Top