Recent

Author Topic: Send accented letters to other programs: á or Alt+0225 (numlock pad, numlock on)  (Read 4916 times)

seier

  • New Member
  • *
  • Posts: 11
Hi Gang,

I'm trying to write a simple always on top toolbar of Spanish accented characters.   Clicking one of the buttons is supposed send that character to the window just below.  I also made sure to utilize the multi-platform package shown in "C:\lazarus\components\mouseandkeyinput\example\project1.lpi".  After considerable effort I got the package to work, but it doesn't work with special characters.   Right now, I just want this to work properly on Windows.  I'll worry about the other platforms later.  I've tried a number of methods, but don't seem to be hitting my mark.  I feel like using the Windows API call SendMessage() is the right way to go, but with which command? 
  • WM_CHAR = $00000102; 
  • WM_SYSCHAR = $00000106; 
  • WM_KEYDOWN = $00000100; 
  • WM_KEYUP = $00000101; 
  • WM_KEYFIRST = $00000100; 
  • WM_KEYLAST = $00000108; 

Does anyone know a better way than SendMessage?

Thanks,
Christian Blackburn

taazz

  • Hero Member
  • *****
  • Posts: 5368
m_char is the message that handles characters a single character generates the following messages
wm_keydown, wm_keyup, wm_char with wm_char used to add the characters in focused window, an edit box for example.

there is no better ay than post/send message in windows since it is the native way that windows handles key board events. Just make sure that you use the function that makes more sense for you eg one of those will add the message to the window's message stack and return immediately while send message will wait until the window you send the message to handles that message before returning.

If I was doing something like that I would use the one that returns immediately to avoid any application locks in case of the selected window is otherwise occupied, at the same sending the last message waiting to be handled is a good way to debug problems.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

seier

  • New Member
  • *
  • Posts: 11
Hi Taaz,

Thanks for your help.  I remembered the name of the command that will keep my application responsive: PostMessage(), then my program won't be stuck waiting for the receiving program to process my simulated keystrokes.  I suppose WM_SysKeyDown is another possibility.  My real question is does anyone know which one to use and how exactly to simulate Alt+0225 (where the numbers are VK_NUMLOCK0,VKNUMLOCK2....). 

Thanks,
Christian

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Have you read this thread which might be applicable to your program?
http://lazarus.freepascal.org/index.php/topic,19766.msg113064.html#msg113064
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

 

TinyPortal © 2005-2018