t4ngo / dragonfly

ARCHIVED! - Speech recognition framework allowing powerful Python-based scripting and extension of Dragon NaturallySpeaking (DNS) and Windows Speech Recognition (WSR)
GNU Lesser General Public License v3.0
364 stars 82 forks source link

Make dragonfly "Text" action work with nordic keyboards #67

Open madsBR opened 6 years ago

madsBR commented 6 years ago

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

chilimangoes commented 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:

Shoggomo commented 6 years ago

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.

chilimangoes commented 6 years ago

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?

reckoner commented 5 years ago

Does this apply to the case where,

Text('σμ').execute()

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

drmfinlay commented 5 years ago

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

reckoner commented 5 years ago

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

drmfinlay commented 5 years ago

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

Versatilus commented 5 years ago

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

drmfinlay commented 5 years ago

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

reckoner commented 5 years ago

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

caspark commented 5 years ago

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 .