Unicode support?

Announcements, questions
Post Reply
un_pogaz
Posts: 6
Joined: 05 Feb 2019, 09:40

Unicode support?

Post by un_pogaz » 05 Feb 2019, 11:06

LuaMacro is powerful, and I'm sure I could do a lot with it, but I have to give him one big blame:
It does not support Unicode.

Unicode and especially UTF-8 are now so common that there is no excuse for not supporting it (see this article from 2003, the idea and the problem can be applied everywhere).
Well, I want conceded that modifying "lmc_send_keys()" will be too complicated and impossible with all the systems of Keystroke sequence, Key Names, Special characters (which don't have an escape, so if you want to write'(', that's no).
So, it would be best to create a new function "lmc_write_text()". In addition to being Unicode compatible, this function would only be used to write/paste a plain text, so no special characters (other the classics '\n', '\r', '\t'...).
Thus, we will be able to separate the execution of the keys "lmc_send_keys()" from the writing of a text "lmc_write_text()" (One is a verbose and has its own vocabulary, the other is readable, simple and that would solve any accentuated character problem).

Thank for reading and this software.

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

Re: Unicode support?

Post by admin » 05 Feb 2019, 21:03

Yes, lmc_send_keys implementation is quite old and has bugs.
If you need more control use lmc_send_input (viewtopic.php?f=12&t=475) which is more complicated to use (more code is required) but has more features and should support unicode.
I don't plan to extend lmc_send_keys currently
Petr Medek
LUAmacros author

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

Re: Unicode support?

Post by un_pogaz » 06 Feb 2019, 10:38

Unfortunately, this does not work.

The problem is that you want to simulate keyboard writing, and I think that's not the right solution.
What happens if we remapped our keyboard (not the default mapping)? or if we want to write characters that are not present on the keyboard?
Many variables and unknowns that give as an answer: nothing and anything, and a lots of bugs.

Really, I think that creating a new function dedicated to text writing would be "simpler" and would solve all its problems more easily.
lmc_write_text() would not be an extension of lmc_send_keys(), who pastes the assigned text directly (like Ctrl+V). No keyboard writing simulation.
(you could probably try using the clipboard)

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

Re: Unicode support?

Post by admin » 06 Feb 2019, 11:00

I don't see (technically) solution how to "paste" or "inject" text to some application.

And no, I don't plan to investigate possibilities and extend luamacros with this functionality.
Petr Medek
LUAmacros author

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

Re: Unicode support?

Post by un_pogaz » 11 Feb 2019, 16:39

Okay, I found a parade.
A large amount of character can be written using the "Alt Code".
Not all Unicode, but enough to stop being a big problem.

Code: Select all

function write_altcode(altcode)
	lmc_send_input(18, 0, 0);            -- press ALT
	lmc_send_keys(altcode, 10);          -- typing AltCode 
	lmc_sleep(string.len(altcode) * 10); -- wait until all caracters the AltCode has been send/typing
	lmc_send_input(18, 0, 2);            -- release ALT
end;

Post Reply