2 keyboards in different languages

Announcements, questions
Post Reply
izosimovmp
Posts: 2
Joined: 28 Feb 2019, 06:01

2 keyboards in different languages

Post by izosimovmp » 28 Feb 2019, 06:04

Sorry, for version of Google translate. I don't speak English. I want to make 2 keyboards that type in two different languages. Russian and English. In LuaMacros I write the following code:

Code: Select all

lmc_device_set_name('Eng','188A0D20')
lmc_print_devices()

lmc_set_handler('Eng', function(button,direction)
  if (direction == 1) then return end
  if (button == 81) then lmc_send_keys('й')

  else print('Not yet assigned: ' .. button)
  end
end
)   

I wish that when you press the "q" output of the Russian " й ".
But nothing happens on the English layout. And in Russian when you click on " Й " is displayed " Р№"
If you do the opposite.

Code: Select all

lmc_device_set_name('Eng','188A0D20')
lmc_print_devices()

lmc_set_handler('Eng', function(button,direction)
  if (direction == 1) then return end
  if (button == 81) then lmc_send_keys('q')

  else print('Not yet assigned: ' .. button)
  end
end
)
Go to the Russian layout and press "й". I want to get a "q" but nothing happens.
It is necessary that one keyboard output "й" and the second " q"
PS button 81 = Russian " й "= English " q"

admin
Site Admin
Posts: 617
Joined: 01 Nov 2010, 13:00
Location: Prague, Czech republic
Contact:

Re: 2 keyboards in different languages

Post by admin » 01 Mar 2019, 17:16

Isn't it all described at the page in forum http://hidmacros.eu/forum/viewtopic.php?f=12&t=475 and in mentioned MSDN page https://docs.microsoft.com/en-us/window ... keybdinput

You have unicode key's e.g. here: https://unicode-table.com/en/

So if you want to send some unicode char you can do e.g.

Code: Select all

lmc_sleep(3000)
-- unicode char
lmc_send_input(0, 1080, 4) -- press и
lmc_send_input(0, 1080, 6) -- release и
-- regular char
lmc_send_input(65, 0, 0) -- press A
lmc_send_input(65, 0, 2) -- release A
This will produce output

иa
Petr Medek
LUAmacros author

un_pogaz
Posts: 9
Joined: 05 Feb 2019, 09:40

Re: 2 keyboards in different languages

Post by un_pogaz » 06 Mar 2019, 15:27

So, if I understand correctly:
The second argument uses the Unicode decimal value of the character?!
It's excelent!

To answer you, No, all are not them described in Simulate keyboard input.
Ex: I thinking the second argument was a "Delay send input".
Another thing: Why are the flags different in "Unicode" mode? 0 & 2 seems logical to me, but why 4 & 6?
And 1, 3 and 5 what are they doing?

Too many questions and answered its impossible to guess (and I don't want to take the risk to random experiment).

You redirected to the MSDN pages, unfortunately they are of no help, Microsoft has the gift of producing heavy and incomprehensible docs.
A detailed and specific LuaMacro doc would be a real plus.
I insist because this is the only flaw I find in LuaMacro: His documentation is incomplete. But, I understand that you don't have only that to do.

admin
Site Admin
Posts: 617
Joined: 01 Nov 2010, 13:00
Location: Prague, Czech republic
Contact:

Re: 2 keyboards in different languages

Post by admin » 07 Mar 2019, 09:20

Parameters of lmc_send_input are passed to KEYBDINPUT structure mentioned in the MSDN page.
First param is wVk, second wScan and third dwFlags. Values are described at that page.
It says that for unicode characters wVk (first param) must be 0, second (wScan) is unicode char code and third (dwFlags) is bitwise or (or sum if you want) of flags.
Value of 3rd for release is 2 and for press 0. And if you're sending unicode char you need to set (add) KEYEVENTF_UNICODE which is 4.
Thus for normal (non-unicode) chars you have press = 0, release = 2 and for unicode chars you need to do +4.
Petr Medek
LUAmacros author

Post Reply