change ascii character to extended ascii character system wide

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

vimalpercyAsked:
Who is Participating?
 
rstaveleyConnect With a Mentor Commented:
With reference to...

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwui/html/msdn_hooks32.asp

.... 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.
0
 
rstaveleyCommented:
This has got what you are looking for: http://www.codeproject.com/dll/keyboardhook.asp
0
 
vimalpercyAuthor Commented:
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
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
tinchosCommented:
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.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Tinchos
EE Cleanup Volunteer
0
 
vimalpercyAuthor Commented:
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
vimal
0
 
rstaveleyCommented:
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.
0
 
vimalpercyAuthor Commented:
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
vimal
0
 
rstaveleyCommented:
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.

--------8<--------
// 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

      add_press_and_release(L"abc",v);
      SendInput(v.size(),&v[0],sizeof(INPUT));
}

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)
            add_press_and_release(*itr,v);
}

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
      v.push_back(event);

      event.ki.dwFlags = KEYEVENTF_KEYUP | KEYEVENTF_UNICODE; // KEYUP
      v.push_back(event);
}
--------8<--------

This is my best shot. Hope it helps.
0
 
rstaveleyCommented:
This certainly works at the cmd.exe prompt with....

       add_press_and_release(L"echo à bientôt!\r",v);
0
 
rstaveleyCommented:
The wchar_t and wstring isn't necessary for characters 128..255, but it would be necessary for characters > 255.
0
 
vimalpercyAuthor Commented:
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
vimalpercy
0
All Courses

From novice to tech pro — start learning today.