Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Keyboard layout #38

Open
haltuf opened this issue Mar 5, 2015 · 5 comments
Open

Keyboard layout #38

haltuf opened this issue Mar 5, 2015 · 5 comments

Comments

@haltuf
Copy link

haltuf commented Mar 5, 2015

Is there a specific Keyboard layout in Windows, that has to be active, for Dragonfly to work? If yes, didn't find any information in docs.

Example of script:

from dragonfly import Text
a2 = Text("Hello world ( ) { }")
a2.execute()

leads to this output:

Hello world } ] ^B ^N

which causes funny behaviour of IDE, when trying to code by voice...
(Windows 7, Python 2.7, active keyboard layout: U.S. English)

@tylercal
Copy link

tylercal commented Mar 5, 2015

What IDE are you using? What happens when you try the command in notepad?

@haltuf
Copy link
Author

haltuf commented Mar 5, 2015

The problem is not IDE-specific ... same output goes into command line or notepad (except in notepad, ^N is interpreted as CTRL+N and it tries to create new file in the end)

@tylercal
Copy link

tylercal commented Mar 5, 2015

I'm also using Windows 7, Python 2.7, and the en_us keyboard layout, but that code executes fine for me. Do you get similar results using

(Text("Hello world ") + Key("leftparen,rightparen,space,leftbrace,rightbrace")).execute()

@haltuf
Copy link
Author

haltuf commented Mar 5, 2015

Yes. Same result with your code.

@haltuf
Copy link
Author

haltuf commented Mar 6, 2015

I solved the issue - looks like the problem lies in Natlink in the end. Since it can affect anyone, who does not use US keyboard as a primary one, I post a solution here:

The problem lies in the fact, that Natlink detects keyboard layout not based on the CURRENTLY ACTIVE keyboard layout, but using the "Default input language" (Windows 7: Control Panel -> Region and language -> Change keyboard or other input methods -> Change keyboard... and here you can set the Default input language, which has to be en_us)

The other way, how to solve this issue for international (non-US) Windows users, is to add this code to your dragonfly grammar scripts:

import win32api
win32api.LoadKeyboardLayout('00000409',1)

The code must be on the very top of your script (ABOVE dragonfly import).

daanzu pushed a commit to daanzu/dragonfly-old that referenced this issue Nov 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants