Open madsBR opened 6 years ago
@madsBR Could you tell me the Windows version you're using and the exact name of the language pack or keyboard layout in your language/keyboard settings? I'm working on a port of the Dragonfly actions to C# to enable interacting with admin processes and one of the things I would like to address is better handling of international keyboard layouts. This would be a good test case for me to add.
Also, @t4ngo hasn't been active on github or maintained this project in ages. You may want to check out one of the forks that's being more actively developed:
Wolfmanstout's Dragonfly, modded to add Google Speech API support.
Danesprite's Dragonfly, modded to add CMU Sphynx support and is under very active development. @Danesprite is also very active and attentive on the Gitter channel set up for the project here.
Monospark's Dragonfire also had quite a bit of activity last year, although not active as recently as the other two. Looks like it has a fix specifically to address keyboard layouts, so it might be worth taking a look at.
None of these forks worked for me (german keyboard). Monospark's fork doesn't even seem to work for my usecase (I'm using caster ontop of dragonfly). However 8327d756d15f3d7235fca5404e73ebc3e6efda2e from Monospark's fork seems to be the language fix and could be implemented in another fork.
Edit and Solution: Wrong commit. ebc094c69ad364b1c217b9e6d4af23aa97711314 did the trick. This enables different keyboard layouts.
Yep, that was the change set I was referring to. @pimp22 have you tried the above solution to see if it works for your issues?
Does this apply to the case where,
Text('σμ').execute()
would work? That is, does it get Text
to emit Unicode UTF-8 characters?
@reckoner No, unfortunately this doesn't work for all UTF-8 characters. Text
and Key
are dependent on the keyboard layout you use. The changes mentioned just allow some different layouts to work correctly.
@Danesprite Thanks! You just saved me a lot of research.
@reckoner No problem. I think the Windows API does allow for that, but it requires rewriting dragonfly's keyboard interface. One workaround for this is to use the Clipboard
class to copy the Unicode strings you want and paste them using Key
. E.g.:
from dragonfly import Clipboard, Key
Clipboard.set_system_text(u"σμ")
Key("c-v").execute()
I think you can also use the Paste
action.
You need to put # encoding=utf-8
(or similar) on the first line of the source file to make Python 2.7 use that encoding instead.
@reckoner No problem. I think the Windows API does allow for that, but it requires rewriting dragonfly's keyboard interface.
I have a mostly functional implementation of this I've been using for most of 2018. It didn't require rewriting nearly as much as I expected it to. I'm not sure that I've even bothered to push it to GitHub. I'm up for discussing the issues in Gitter when I've finally finished this SimCity binge I've been on.
Ah okay then, that's good to hear. Sounds good :+1:
@Danesprite Thanks for the Paste
idea. I will look into it. I also look forward to your @Versatilus keyboard implementation.
For the record, it looks like @Versatilus has merged his Unicode Text action PR into @Danesprite 's fork, so uninstalling original dragonfly then doing something like pip install dragonfly2==0.10 --upgrade
might do the trick for you now @reckoner .
Atm the Text action bugs with all chars which require alt+ctrl on the Keyboard. On a nordic keyboard this includes @£$€{[]}|
i fixed it by replacing "elif" by "if" in here https://github.com/t4ngo/dragonfly/blob/master/dragonfly/actions/keyboard.py at line 121,122,137,138
but i don't know if it will have bug -consequences later..