|
-
June 4th, 2003, 06:40 AM
#1
keybd_event and unicode
guys
i am using keybd_event() to send keystrokes to any active editor(notepad or wordpad) .
instead of normal keystrokes, how do i send unicode values using the same function.
i.e if 'a' is typed i want to send some unicode value of an indian language to the editor.
can anybody help me?
naveen
-
June 4th, 2003, 06:48 AM
#2
In general, using keybd_event will not work for Unicode strings. The simple reason is that there are a lot more steps involved in changing a keystroke into a glyph (a displayed character). You could try sending a WM_CHAR (or WM_UNICHAR if you are using Windows XP) to the active window. This would have a higher chance of succeeding. There can be other problems though, if for example the application is using a code-page conversion, using a non-standard system locale etc.
Get this small utility to do basic syntax highlighting in vBulletin forums (like Codeguru) easily.
Supports C++ and VB out of the box, but can be configured for other languages.
-
June 4th, 2003, 06:49 AM
#3
Maybe you can use ToUnicode()
"The ToUnicode function translates the specified virtual-key code and keyboard state to the corresponding Unicode character or characters. "
-
June 4th, 2003, 06:54 AM
#4
Interesting, I hadn't thought about that. But what you probably need is VkKeyScanExW rather than ToUnicode.
Get this small utility to do basic syntax highlighting in vBulletin forums (like Codeguru) easily.
Supports C++ and VB out of the box, but can be configured for other languages.
-
June 5th, 2003, 03:52 AM
#5
hi guys
can u give few lines of code or any example on this
thanks
naveen
-
June 5th, 2003, 04:06 AM
#6
Originally posted by naveenkn1977
can u give few lines of code or any example on this
Sorry, but I have no experience yet with these keyboard conversions. I've only used the SendInput function so far (to simulate some key input). And I will not have the time to develop a sample project now.
Maybe you can find some sample in the MSDN (which also has a lot of stuff to read about keyboard input).
Sorry again.
Last edited by Matthias Kring; June 5th, 2003 at 04:11 AM.
-
June 5th, 2003, 05:38 AM
#7
hi
actually my code works both with sendInput() and keybd_event()
my code ---------------
INPUT Input[2];
KEYBDINPUT ki;
ki.wVk = wKeyCode;
ki.dwFlags = KEYEVENTF_EXTENDEDKEY | 0;
ki.time = 0;
ki.wScan = 0;
Input[0].type = INPUT_KEYBOARD;
Input[0].ki = ki;
SendInput( 1, Input, sizeof(INPUT) );
-----------------------
in msdn i found that if i replace KEYEVENTF_EXTENDEDKEY with
KEYEVENTF_UNICODE | KEYEVENTF_KEYUP
then i can send unicode characters
but when i compile it says KEYEVENTF_UNICODE undeclared variable. also i cannot find an entry for it in winuser.h
can u help me
thanks
naveen
-
June 6th, 2003, 12:42 AM
#8
KEYEVENTF_UNICODE is in winuser.h, and it is only available #if(_WIN32_WINNT >= 0x0500) (that is, at least Windows 2000 is needed)
-
June 6th, 2003, 08:19 AM
#9
hai,
I am working on Windows XP and VC++ 6.0
In my winuser.h file i see only following lines
#define KEYEVENTF_EXTENDEDKEY 0x0001
#define KEYEVENTF_KEYUP 0x0002
There is no reference for KEYEVENTF_UNICODE
what should i do ?
naveen
-
June 10th, 2003, 04:20 AM
#10
Originally posted by naveenkn1977
hai,
I am working on Windows XP and VC++ 6.0
In my winuser.h file i see only following lines
#define KEYEVENTF_EXTENDEDKEY 0x0001
#define KEYEVENTF_KEYUP 0x0002
There is no reference for KEYEVENTF_UNICODE
what should i do ?
naveen
Oops. You're right. It's not in the normal WINUSER.H.
I've additionally installed the "Platform SDK" which comes first in path.
Look here to get the platform SDK
http://www.microsoft.com/msdownload/...sdk/sdkupdate/
Matthias
-
June 10th, 2003, 08:53 AM
#11
hi
which SDK do i have to install ? should i install all the sdks ?
-
June 11th, 2003, 03:02 AM
#12
Originally posted by naveenkn1977
hi
which SDK do i have to install ? should i install all the sdks ?
The "core" should be sufficient.
But it's a rather huge download....
The Platform SDK is also part of the MSDN subscription.
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
|