[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


change ascii character to extended ascii character system wide

Posted on 2003-10-30
Medium Priority
Last Modified: 2012-08-13
Sir i need to develop a software where i have to change the ascii character into extended ascii character and send to the active application.

say if a user type A from the keyboard it should be converted to say € irrespective of whatever the application is running may be it is visual studio or word or notepad or photshop u name it.

i need the codings of intercepting that message and load that message with extended ascii character(system wide and not for any single application)

thanks in advance

Question by:vimalpercy
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
LVL 17

Expert Comment

ID: 9658392
This has got what you are looking for: http://www.codeproject.com/dll/keyboardhook.asp

Author Comment

ID: 9729579
Thank you Mr Rstavely
       Using this keyboard hook i just can get the keystrokes but what my requirement is to change that keystroke to extended ascii character and the application which is in focus should get the changed extended ascii character.

Thanks in advance
LVL 17

Accepted Solution

rstaveley earned 1000 total points
ID: 9730793
With reference to...


.... I've not played with this, but you might find it best to hook WH_KEYBOARD, trap and remove the WM_KEYUP and WM_KEYDOWN messages for the key you want to substitute and then to PostMessage WM_KEYUP and WM_KEYDOWN messages for the key you want it substituted with.

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.


Expert Comment

ID: 10546345
No comment has been added lately, so it's time to clean up this question.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: rstaveley {http:#9730793}

Please leave any comments here within the next four days.

EE Cleanup Volunteer

Author Comment

ID: 10547895
Hello mr rstaveley

  I tried the method which you have suggested long back but still the main problem is sending an extended ascii character using postmessage(wmKeydown,wmkeykup) messages.\

I can able to send normal ascii characters using postmessage but how about extended ones like õ

I was able to do with postmessge(Wmchar)
but it works differently for different applications.

so dont know what to do..

If you are very sure in helping me in this than we will continue with this question else i close the question for refund.

Thank you very much mate
with regards
LVL 17

Expert Comment

ID: 10548237
Bit 24 in the LPARAM of the WM_KEYUP/WM_KEYDOWN message tells you that the key is an extended one. The WPARAM only gives you the virtual key code.

See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/UserInput/KeyboardInput/KeyboardInputReference/KeyboardInputMessages/WM_KEYUP.asp

By all means close the question for a refund. Sorry I cannot be more helpful.

Author Comment

ID: 10567778
Thank you very much mr rstaveley
i tried as you have told but still the character send by that way not printing in the application

scanCode = VkKeyScan(õ);
SParam = (scanCode << 16) + 1;
PostMessage(msg->hwnd, WM_KEYDOWN, õ, SParam);
PostMessage(msg->hwnd, WM_UP, õ, SParam);

what am i doing wrong.

I just need this requirement

say if you type a   ,, by some means remove 'a' and put three extended ascii characters

so what i tried is send (backspace, 3 extended ascii characters) but they are not printing in the applicaiton ,
but if i send normal ascii characters they are printing in the application

please help me in this one

thanks in advance
with regards
LVL 17

Expert Comment

ID: 10572728
It may be that you need to discard the key and use SendInput to send the unicode key. Try hacking the following and replacing the 'a','b','c' to the unicode character(s) you want to send to see if it is acceptable to your application. You should toggle to your application during the sleep, when this executes. If this works, you could trap the key which you want to substitute, set the focus to your application [presumably unnecessary!] and then use SendInput as illustrated to push unicode.

// Compile and link:
// cl /EHsc sendinput.cpp user32.lib

#define      _WIN32_WINNT      0x0500 // Needs Windows 2000 or better
#define      _WINVER            0x0500

#include <windows.h>
#include <vector>

void add_press_and_release(const std::wstring str,std::vector<INPUT>& v);
void add_press_and_release(wchar_t c,std::vector<INPUT>& v);

int main()
      std::vector<INPUT> v;

      Sleep(2000); // During this sleep toggle to your application


void add_press_and_release(const std::wstring str,std::vector<INPUT>& v)
      for (std::wstring::const_iterator itr = str.begin();itr != str.end();++itr)

void add_press_and_release(wchar_t c,std::vector<INPUT>& v)
      INPUT event;
      event.type = INPUT_KEYBOARD;
      event.ki.wVk = 0;      // Using unicode
      event.ki.time = 0;      // Use system timestamp
      event.ki.dwExtraInfo = GetMessageExtraInfo();

      event.ki.wScan = c;      // Unicode character to be sent to the foreground application

      event.ki.dwFlags = KEYEVENTF_UNICODE; // KEYDOWN


This is my best shot. Hope it helps.
LVL 17

Expert Comment

ID: 10572784
This certainly works at the cmd.exe prompt with....

       add_press_and_release(L"echo à bientôt!\r",v);
LVL 17

Expert Comment

ID: 10572823
The wchar_t and wstring isn't necessary for characters 128..255, but it would be necessary for characters > 255.

Author Comment

ID: 10595115
Hello mr  rstaveley

  THank you very much for your help. I am working on your code.
But since my application is a system level hook and have to run on 98 also i cant go for unicode .
But anyway if i can first make a application which work in atleast 2000 then i can build from there , ]
Still i am trying out your codings
I come up with answer or question after working on that one

Thanks and regards

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question