Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process Win32 input events through Natlink when possible #372

Open
drmfinlay opened this issue Sep 29, 2022 · 6 comments
Open

Process Win32 input events through Natlink when possible #372

drmfinlay opened this issue Sep 29, 2022 · 6 comments
Assignees
Labels
Dragon NaturallySpeaking Issue related to Dragon NaturallySpeaking engine Enhancement Enhancement existing feature NatLink Issues related to NatLink Windows Issues regarding Microsoft Windows OS

Comments

@drmfinlay
Copy link
Member

drmfinlay commented Sep 29, 2022

Re: #11.

It occurs to me that most Dragonfly Key, Text and Mouse actions could be processed using the special natlink playEvents() function. Because DNS itself would "play" the events, this would allow indirect interaction with applications running in elevated mode.

This feature could either be optional or always used if the natlink module is available and DNS is running.

Assuming the documentation for playEvents() is complete, the following events can not be processed:

  • Scroll wheel events
  • Mouse 4 and 5 buttons events
  • Unicode keystroke events

Dragonfly can will have to fallback on its own SendInput implementation for these. I do have hope, however, that the function may be used to type these events anyway; the accepted tuples are simply window message pairs (wParam and lParam) defined by Windows.

As is the case with DNS itself, this won't allow interaction with the UAC box.

@drmfinlay drmfinlay added Enhancement Enhancement existing feature NatLink Issues related to NatLink Dragon NaturallySpeaking Issue related to Dragon NaturallySpeaking engine Windows Issues regarding Microsoft Windows OS labels Sep 29, 2022
@drmfinlay drmfinlay self-assigned this Sep 29, 2022
@drmfinlay
Copy link
Member Author

drmfinlay commented Oct 1, 2022

I have got the Key and Text actions to work as above. (Haven't committed the changes yet.) I am able to use these actions to interact with applications running in elevated mode. However, due to certain limitations of the interface, I think the feature should be disabled by default. It will be enableable like the Unicode keyboard.

Incidentally, this interface may be used in conjunction with WSR, or sphinx, as long as Natlink is available and DNS is running; it is not tied to the Natlink engine. Since 32-bit Python is required for Natlink, it can't be used directly with Kaldi.

@drmfinlay
Copy link
Member Author

This interface doesn't work well with modifier keys and is therefore unsuitable as an alternative to SendInput. I'll mention the Natlink playEvents() and playString() functions in the FAQ answer for controlling administrative applications and leave it at that.

@drmfinlay
Copy link
Member Author

drmfinlay commented Dec 9, 2022

Since the work on this is complete, I might just add it as a disabled feature with caveats mentioned in the docs. Better to include my implementation than to refer to the hard-to-use Natlink function. Some may find this feature useful despite the caveats.

@drmfinlay drmfinlay reopened this Dec 9, 2022
drmfinlay added a commit that referenced this issue Dec 10, 2022
Re: #372.

Natlink's `playEvents' function can be used to simulate keystrokes
and mouse events with Dragon NaturallySpeaking.  Dragonfly's Key,
Text and Mouse action objects are now able to send events this way,
allowing Dragonfly commands to interact with administrative applic-
ations on Windows.

This feature is disabled by default because the `playEvents' inter-
face is not a perfect substitute for the Windows `SendInput' funct-
ion.  Dragonfly falls back on the default implementation if Natlink
cannot be used.

Documentation on this feature has been added in the relevant files.
@drmfinlay
Copy link
Member Author

This feature is now ready on the master branch.

@quintijn, you may find this interesting.

@quintijn
Copy link

Thanks Dane, good to know. I agree that your Keys and Text (and also Mark Lillibridges sendkeys functions, which are now in the dtactions repository) are more easy, and can also be used when Dragon is not running, so also for other applications (as I happen to have).

@drmfinlay
Copy link
Member Author

No worries, Quintijn. I can't take credit for the Key and Text actions though. Christo Butcher wrote those.

BTW, this feature uses a sort of replacement sendinput module: natlinkinput.py. It is not dependent on Dragonfly. I have no objection to it being used in dtactions, if that is desirable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dragon NaturallySpeaking Issue related to Dragon NaturallySpeaking engine Enhancement Enhancement existing feature NatLink Issues related to NatLink Windows Issues regarding Microsoft Windows OS
Projects
None yet
Development

No branches or pull requests

2 participants