Lamefif

im trying to send special characters to another application.
ive tried using:

keybd_event()

SendInput()

but is not working, i've gotten them to send normal char's, but not char's like E..e

thank you


Re: Visual C++ General Extended ascii char set

crescens2k

Could you explain the problems you are having more. It's not working isn't very helpful so more information is needed before anyone could help you more.
What is needed is a code sample of what you are doing and the problems you are experiencing.





Re: Visual C++ General Extended ascii char set

Lamefif

[code]
keybd_event(VkKeyScan('a'),1,0 , 0); // ¡®A¡¯ Press
keybd_event(VkKeyScan('a'),1, KEYEVENTF_KEYUP,0); // ¡®A¡¯ Release[/code]
this works, i.e the application (notepad) in focus gets an a typed.
[code]
keybd_event(VkKeyScan('e'),1,0 , 0); // ¡®A¡¯ Press
keybd_event(VkKeyScan('e'),1, KEYEVENTF_KEYUP,0); // ¡®A¡¯ Release[/code]
this does not, i dont get any errors or anything. nothing happens.

iv also tried:
[code]
INPUT input[2];
memset(input, 0, sizeof(input));
input[0].type = INPUT_KEYBOARD;

input[0].ki.wVk = -126; // ASCI value of A
input[0].ki.dwFlags = 0;
input[0].ki.time = 0;
input[0].ki.dwExtraInfo = 0;
input[1].ki.wVk = -126; // ASCI value of A
input[1].ki.dwFlags = KEYEVENTF_KEYUP;
input[1].ki.time = 0;
input[1].ki.dwExtraInfo = 0;
SendInput(2,input,sizeof(INPUT));
[/code]
negative numbers for the extended ascii char's, i've also tried hex equivalent of the ascii number.

now im looking up the SendMessage(), but i dont know what it can do. i have not written a win32 app before.

thank you




Re: Visual C++ General Extended ascii char set

crescens2k

Ah, I understand now. This function simulates keyboard input that means that the character must be represented by a keystroke on the keyboard. Most keyboard layouts don't have that key on the keyboard or they require modifiers to input them.
Two things you can do, first, run VkKeyScan on it's own and check the return value, if it returns -1 then it means that there is no scan code for the particular key in your current keyboard layout. If you are using a keyboard layout that has the ability to input this by the use of dead keys then you will need to do it seperatly, first will be the accent then the letter.
Otherwise you will have to find another method for inputting the text into another application.





Re: Visual C++ General Extended ascii char set

Lamefif

VkKeyScan is returning -1, is there a way around this. What methods classes should i be looking up. can you point me in the right direction please.
thank you




Re: Visual C++ General Extended ascii char set

Lamefif

hello anyone anything ... please.




Re: Visual C++ General Extended ascii char set

crescens2k

Please be a little more patient, I was looking into possible solutions for you.
Your best bet here would be the use of LoadKeyboardLayout to load layouts of keyboards that have these keys mapped and then send the input.

I assume you are creating a virtual keyboard type application. If not, what triggers input.





Re: Visual C++ General Extended ascii char set

Lamefif

thanks crescens2k

im trying to make it so when a user inputs a combination of keys Control+e for example
instead e they get e typed for them.

at the moment i have rigged it so that spacebar triggers the typing.

if(GetAsyncKeyState(32)){ ....

im playing around with PostMessage(), and im not getting consistent results.

this works PostMessage(mw, WM_CLOSE, 0, 0);
this does not PostMessage(mw, VK_F1, 0, 0);

F1 should bring up the help on notebad.

i've also came across this but is in MFC i think.

http://www.codeproject.com/string/sendcstring.asp df=100&forumid=2564&exp=0&select=982276

but i cant make heads or tails of it, MFC calls on win32 functions right

i'll look into LoadKeyboardLayout, and i have to figure out which layout supports what ..pfffff

Thank you




Re: Visual C++ General Extended ascii char set

crescens2k

If thats the case then you have an easier option. Use the WM_CHAR or WM_UNICHAR message and change the key code there.

Have a look at http://msdn2.microsoft.com/en-us/library/ms646276.aspx for a description of how this works. You can get the state from lparam and if the certain key combination is pressed then you can modify the value in wparam.





Re: Visual C++ General Extended ascii char set

Lamefif

case WM_CHAR:
switch (wParam)
{
case 0x05:
wParam = 0x04;

break;

case 0x0A:

// Process a linefeed.

break;

case 0x1B:

// Process an escape.

break;

case 0x09:

// Process a tab.

break;

case 0x0D:

// Process a carriage return.

break;

default:

// Process displayable characters.

break;
}
//--------------------

http://msdn2.microsoft.com/en-us/library/ms646268.aspx

i dont get what you mean, this would only work if someone is sending a message to my program

but im trying this with no success so far:
PostMessage(mw, WM_CHAR, 'a',0);
no error just nothing happens.

thanks





Re: Visual C++ General Extended ascii char set

crescens2k

WM_CHAR is sent to the application in question in response to key presses, you don't send it yourself.
Using a message hook you can grab any WM_CHAR or WM_UNICHAR messages, modify the character code and then let it carry on.





Re: Visual C++ General Extended ascii char set

Lamefif

thanks again crescens2k, im looking up these hook functions i'll let you know if i succeed .




Re: Visual C++ General Extended ascii char set

Lamefif

hi crescens2k i took a look at hooking and it seems like you have to have it in a dll for it to work for other processes.
i turned to changing keyboard layout and it turns out you can only do that for your app.
so im back to hooking and trying to get it to work for my app at the moment but i dont seem to get any WM_CHAR messages when i press a key,
but i do get a WM_KEYDOWN message using WH_GETMESSAGE hook.

i don't know im running out of steam on this, i have beaten more then i can chew i think Smile

thanks




Re: Visual C++ General Extended ascii char set

Simple Samples

Lamefif wrote:
hi crescens2k i took a look at hooking and it seems like you have to have it in a dll for it to work for other processes.
Maybe not, but this question is very off-topic for this forum. If you ask your questions in a newsgroup or forum for Windows programming then you might get easier solutions.