|
-
February 1st, 2005, 07:40 AM
#1
send shift alt ctrl to edit control
Hi All
i need to send various combination of keys like SHIFT+a, ALT+a, CTRL+c etc to edit control, but problem is that this edit control is inactive, hasnt got focus and mustn't receive focus so function keybd_event or sendinput i can't use, i try using following code for example for shift:
PostMessage(hEdit,WM_KEYDOWN,VK_SHIFT,MapVirtualKey(VK_SHIFT,0) | 0x00000001);
PostMessage(hEdit,WM_CHAR,'a',1);
PostMessage(hEdit,WM_KEYUP,VK_SHIFT,MapVirtualKey(VK_SHIFT,0) | 0xC0000001);
but i still have small a, but in this case i should get big one
i try also something like this
char a[256];
GetKeyboardState(a);
a[VK_SHIFT] |= 0x80;
SetKeyboardState(a);
SendMessage(hEdit,WM_CHAR,'a',1);
a[VK_SHIFT] &= 0x7F;
SetKeyboardState(a);
but it still doesn't work, i need solution which works like sendinput or keybd_event but can send keys to control which dont have focus and cant received it, any suggestion??? i will be gratefull
Greats
Michal
-
February 1st, 2005, 11:08 AM
#2
Re: send shift alt ctrl to edit control
Why not sending a big A? A big A indicitates that the shift key should be pressed. If the shift key is pressed and you receive a small a that only indicates that the capital lock is enabled.
Code:
PostMessage(hEdit,WM_KEYDOWN,VK_SHIFT,MapVirtualKey(VK_SHIFT,0) | 0x00000001);
PostMessage(hEdit,WM_CHAR,'A',1);
PostMessage(hEdit,WM_KEYUP,VK_SHIFT,MapVirtualKey(VK_SHIFT,0) | 0xC0000001);
-
February 1st, 2005, 02:23 PM
#3
Re: send shift alt ctrl to edit control
i cant do this in that way because i only know that which keys i must simulate in my example press of shift and letter 'a',but i have written that i need solution for SHIFT, ALT, CTRL, your solution is ostensibly "good" for shift but how do you solve press ALT key plus letter 'a'?? i cant obtain what characted we receive if user press this sequence of keys, because it cant be keyboard language dependent character, so your solution is not good for me, we can imagine edit control that for pressing keys SHIFT+'a' dont display 'A' but do 'xx' action and i want to get this 'xxx' action too, so someone else have any idea???
greats
michal
-
February 1st, 2005, 02:26 PM
#4
Re: send shift alt ctrl to edit control
 Originally Posted by michal_
i cant do this in that way because i only know that which keys i must simulate in my example press of shift and letter 'a',but i have written that i need solution for SHIFT, ALT, CTRL, your solution is ostensibly "good" for shift but how do you solve press ALT key plus letter 'a'?? i cant obtain what characted we receive if user press this sequence of keys, because it cant be keyboard language dependent character, so your solution is not good for me, we can imagine edit control that for pressing keys SHIFT+'a' dont display 'A' but do 'xx' action and i want to get this 'xxx' action too, so someone else have any idea??? 
This clarifies your need. In this case you should search the forums for 'SendInput()' and/or 'keybd_event' and I am sure you will find several threads refering and giving solution to this problem. Just take a look at the current page of the WinAPI forum thread overview, and you will find at least one.
-
February 1st, 2005, 06:55 PM
#5
Re: send shift alt ctrl to edit control
i know sendinput and keybd_event function, but this functions only works when you set focus to control which should receive keys, but i have written that my edit control haven't got focus and mustn't receive it ever, so i cant use it:|
greats
michal
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|