Tech Support > Microsoft Windows > Development Resources > Sendinput () - sending '{' and '}'
Sendinput () - sending '{' and '}'
Posted by mandatory on February 7th, 2005


Hi,

Ive just run into a problem with sendinput() i need to send '{' and '}' -
and to my horror, i cant do that the same way as i send normal characters, i
can send normal strings and numbers and stuff.

I guess its because i am using ALT_GR to access that key - and to my
knowledge the ALT+GR is the VK_RMENU.

I try the same approach as when i use VK_SHIFT - which is like this:

inputblock[j].type = INPUT_KEYBOARD;
inputblock[j].ki.wVk = VK_RMENU;
j++;

res = VkKeyScan('8'); // the key its placed on
virk = LOBYTE(res);

inputblock[j].type = INPUT_KEYBOARD;
inputblock[j].ki.wVk = MapVirtualKey(virk, 0);;
inputblock[j].ki.wScan = 0;
j++;

inputblock[j].type = INPUT_KEYBOARD;
inputblock[j].ki.wVk = VK_RMENU;
inputblock[j].ki.dwFlags = KEYEVENTF_KEYUP;
j++;

But it doesnt work at all - ive tried also with ALT_LMENU, ALT_RCONTROL (to
emulate CTRL+ALT+key) but it doesnt work either.

Im wondering about the syntax i have to use ? and im wondering what key that
is going to be reffered in "res" ?

can anybody help me ?


Posted by Tony Nelson on February 7th, 2005


In article <42077bdb$0$145$edfadb0f@dread11.news.tele.dk>,
"mandatory" <okllsam@nptklooohs.ru> wrote:

On my keyboard, the curly braces {} are shifted, and I would pass
VK_SHIFT instead of VK_RMENU.

I'm surprised that you send '8' to VkKeyScan(), instead of '{' or '}'.


Is the value of wVK here VK_OEM_4 (0xDB for [{) or VK_OEM_6 (0xDD for
]})? It seems to me that you are sending an 8* key, not a curly brace
key.


Again, on my keyboard I would need to send VK_SHIFT.


Spy++ is your friend. It can show you the normal messge stream for what
you want to do, and it can show you the message stream that results from
what you did.
__________________________________________________ ______________________
TonyN.:' <mailto:tonynlsn@shore.net>
' <http://www3.primushost.com/~tonynlsn/>


Posted by mandatory on February 7th, 2005


hi tony !

on my PC (danish keyboard) it is placed on key '7' (not on '8') - and i get
it by pressing ALT+GR and '7'.

I have tested with keybd_event () and this is working ok, but i cant really
combine keybd_event() with sendinput() due to the buffering in sendinput.

I havent seen theese two keys, i will try right away and report back if this
is the holy grail !



Posted by mandatory on February 7th, 2005


well 0xDB and 0xDD didnt work as the VK key

Do anybody of you know if this is impossible to do with sendinput () ? if
not, anyone who has an example of doing a ALT+GR + some key - so i can see
what im doing wrong ?

"mandatory" <okllsam@nptklooohs.ru> skrev i en meddelelse
news:4207ee51$0$200$edfadb0f@dread11.news.tele.dk. ..


Posted by Tony Nelson on February 8th, 2005


In article <4207f9f0$0$200$edfadb0f@dread11.news.tele.dk>,
"mandatory" <okllsam@nptklooohs.ru> wrote:

I'd say it is finally time to break out Spy++.


I didn't see you sending ALT or GR (unless GR is VK_RMENU) in your code.
I'd expect to see one inputblock with an ALT press, then one with a GR
(?), then a 7, then inputblocks releasing them in reverse order. Also,
I'd expect that you'd set the 7 directly into wVk, as 7 is the virtual
key code for 7.
__________________________________________________ ______________________
TonyN.:' <mailto:tonynlsn@shore.net>
' <http://www3.primushost.com/~tonynlsn/>


Posted by mandatory on February 8th, 2005


well i think the ALT+GR is RMENU.

Ive using a spytool now - can you tell me how i convert lparam and wparam
correctly into the INPUT structure of sendinput() ??

i get this when i make '{' (on my keyboard ALTGR+'7'):

WM_KEYDOWN:
wparam: 0x00000011
lparam: 0x001d001

WM_KEYDOWN:
wparam: 0x00000012
lparam: 0x21380001

WM_KEYDOWN:
wparam: 0x00000037
lparam: 0x20080001

WM_KEYUP:
wparam: 0x00000037
lparam: 0x00080001

WM_SYSKEYUP:
wparam: 0x00000011
lparam: 0xe01d0001

WM_KEYUP:
wparam: 0x00000012
lparam: 0xc138001


"Tony Nelson" <tonynlsn@shore.net> skrev i en meddelelse
news:tonynlsn-99F0E8.20503207022005@news.primus.ca...


Posted by Tony Nelson on February 8th, 2005


In article <4208dca6$0$172$edfadb0f@dread11.news.tele.dk>,
"mandatory" <okllsam@nptklooohs.ru> wrote:

That's why I suggested Spy++: it unpacks and decodes the params. The
following messages show pressing CONTROL+right MENU+7. The
inconsistently set context code indicates that the destination window
has the keyboard focus.


wparam: VK_CONTROL
lparam: scan code 1d, repeat count 1 (correct value is 0x001d0001)


wparam: VK_MENU
lparam: context code on (?), extended key, scan code 38, repeat count 1


wparam: '7'
lparam: context code on (?), scan code 8, repeat count 1


wparam: '7'
lparam: scan code 8, repeat count 1


wparam: VK_CONTROL
lparam: transition up, previously down, context code on (?), scan code
1d, repeat count 1


wparam: VK_MENU
lparam: transition up, previously down, scan code 38, repeat count 1
__________________________________________________ ______________________
TonyN.:' <mailto:tonynlsn@shore.net>
' <http://www3.primushost.com/~tonynlsn/>


Posted by mandatory on February 9th, 2005


thanks alot tony for sticking up with me here

I didnt have spy++ on my machine, but i can see what you mean on my other
PC - and finally with your help ive been able to do it with SendInput().

Thanks alot for your help here !


Posted by Tony Nelson on February 9th, 2005


In article <420960b2$0$152$edfadb0f@dread11.news.tele.dk>,
"mandatory" <okllsam@nptklooohs.ru> wrote:

You're welcome. Glad to be of assitance.
__________________________________________________ ______________________
TonyN.:' <mailto:tonynlsn@shore.net>
' <http://www3.primushost.com/~tonynlsn/>



Similar Posts