Jmgr / actiona

Cross-platform automation tool
https://actiona.tools
GNU General Public License v3.0
511 stars 64 forks source link

Non english text write? #125

Open dnezamaev opened 4 years ago

dnezamaev commented 4 years ago

Hi! I am trying to input russian word "тест" with Action "Write text", but nothing happens. When I change string to "test тест test" it types "test test". Seems that non english characters are ignored.

prudowicz commented 4 years ago

I've actually discovered this bug but I think it's not necessary to fix it because it can be bypassed by set of actions like put your non-english string to clipboard by using "Write clipboard" and then use "Key" action with CTRL + V on your text input. I've tested it on ubuntu with polish characters string and with your "test тест test" and it works, should also work under Windows platform.

dnezamaev commented 4 years ago

Thanks for answer. This workaround may really work in many cases, but application i want to automate does not support clipboard in text fields, so it is impossible to use CTRL-V there. Any other options?

prudowicz commented 4 years ago

Usually, when I achieved a lack of feature of this program I was writing a simple python3 script that workaround my problem. And I've found a solution to break this problem too. Firstly, you need to install additional package that allows writing with keyboard from python in easy way.

pip3 install pynput

Then, you can use this script which allows to put from keyboard each char given from arg.

from pynput.keyboard import Key, Controller
import sys
import platform

keyboard = Controller()

text_to_write = " ".join(sys.argv[1:])

if platform.system() == "Linux":
    hexs = []
    for ch in text_to_write:
        hexs.append(hex(ord(ch)))

    for h in hexs:
        keyboard.press(Key.shift_l)
        keyboard.press(Key.ctrl_l)
        keyboard.press("u")
        keyboard.release(Key.shift_l)
        keyboard.release(Key.ctrl_l)
        keyboard.release("u")
        keyboard.type(h[2:])
        keyboard.type(" ")

elif platform.system() == "Windows":
    keyboard.type(text_to_write)

If you want to use it in actiona script set a variable with your string, put text cursor in your input and execute python3 using "Command". In parameters field you should put name of this script and name of var with $ before, and working directory as where you save the script. This sequence shift + ctrl + u may be different on your system, but I hope it will work for you.

To the end, if this program which doesn't allow you using clipboard is a web browser on some page I think it's possible to force using clipboard by some extension.

dnezamaev commented 4 years ago

Thanks again for so extended answer! I will try. The applications are old Windows games - Heroes of might and magic 3 and Warcraft 3, i run them on Ubuntu with Wine. There are some standard phrases about rules i tell before starting, so i tried to automate it.