dragonfly icon indicating copy to clipboard operation
dragonfly copied to clipboard

Make dragonfly "Text" action work with nordic keyboards

Open madsBR opened this issue 7 years ago • 11 comments

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..

madsBR avatar Mar 07 '18 01:03 madsBR

@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:

chilimangoes avatar Apr 08 '18 03:04 chilimangoes

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.

Shoggomo avatar May 08 '18 08:05 Shoggomo

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?

chilimangoes avatar May 08 '18 19:05 chilimangoes

Does this apply to the case where,

Text('σμ').execute()

would work? That is, does it get Text to emit Unicode UTF-8 characters?

reckoner avatar Sep 11 '18 14:09 reckoner

@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.

drmfinlay avatar Sep 12 '18 04:09 drmfinlay

@Danesprite Thanks! You just saved me a lot of research.

reckoner avatar Sep 19 '18 17:09 reckoner

@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.

drmfinlay avatar Sep 20 '18 05:09 drmfinlay

@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.

Versatilus avatar Sep 20 '18 07:09 Versatilus

Ah okay then, that's good to hear. Sounds good :+1:

drmfinlay avatar Sep 20 '18 10:09 drmfinlay

@Danesprite Thanks for the Paste idea. I will look into it. I also look forward to your @Versatilus keyboard implementation.

reckoner avatar Sep 20 '18 22:09 reckoner

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 .

caspark avatar Dec 31 '18 21:12 caspark