[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

change ascii character to extended ascii character system wide

Posted on 2003-10-30
14
Medium Priority
?
545 Views
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

0
Comment
Question by:vimalpercy
  • 6
  • 4
11 Comments
 
LVL 17

Expert Comment

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

Author Comment

by:vimalpercy
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
0
 
LVL 17

Accepted Solution

by:
rstaveley earned 1000 total points
ID: 9730793
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 9

Expert Comment

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

Tinchos
EE Cleanup Volunteer
0
 

Author Comment

by:vimalpercy
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
vimal
0
 
LVL 17

Expert Comment

by:rstaveley
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.
0
 

Author Comment

by:vimalpercy
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
vimal
0
 
LVL 17

Expert Comment

by:rstaveley
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.

--------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
 
LVL 17

Expert Comment

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

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

Expert Comment

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

Author Comment

by:vimalpercy
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
vimalpercy
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

872 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