KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: pgEmulate - create keyboard shortcuts for Dragon commands
Topic Summary: Using native Windows features (no hacks)
Created On: 03/29/2019 02:38 PM
Status: Post and Reply
Linear : Threading : Single : Branch
 pgEmulate - create keyboard shortcuts for Dragon commands   - PG LTU - 03/29/2019 02:38 PM  
 pgEmulate - create keyboard shortcuts for Dragon commands   - framage-ccplab - 05/22/2019 03:06 PM  
 pgEmulate - create keyboard shortcuts for Dragon commands   - monkey8 - 05/22/2019 04:32 PM  
 pgEmulate - create keyboard shortcuts for Dragon commands   - PG LTU - 05/23/2019 03:17 PM  
 pgEmulate - create keyboard shortcuts for Dragon commands   - kkkwj - 12/04/2019 01:36 AM  
 pgEmulate - create keyboard shortcuts for Dragon commands   - PG LTU - 12/04/2019 10:23 AM  
 pgEmulate - create keyboard shortcuts for Dragon commands   - PG LTU - 01/22/2020 05:47 PM  
Keyword
 03/29/2019 02:38 PM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2189
Joined: 03/21/2007

There is an easy way to create a shortcut for any (or an arbitrary) Dragon command.

 

First create a tiny pgEmulate.vbs script and put it somewhere accessible. This script, when run directly, presents an input box that lets you type or dictate some text for Dragon to recognize. So if you type in or dictate a command name (careful of capitalization, which counts here), Dragon will treat that input as if you said it. The script also lets you optionally pass in a parameter for what you want to say, so skips the input box and goes right to recognizing that text.

 

For the first version, create a shortcut on your desktop to the vbs script. Assign it a shortcut key (apparently you can only use Ctrl + Alt + Letter combos in the Shortcut properties) or use AHK or ME to assign any hotkey or hotstring combo of your choice. For the second version, just edit the target property to add the command to be recognized in quotes, such as:

 

C:\pgEmulate.vbs "what can I say"

 

and give it a shortcut key, too.

 

Here is pgEmulate.vbs (create in any text editor, just make sure to change the extension from .txt to .vbs).


if WScript.Arguments.Count > 0 then x = WScript.Arguments(0)
if x = "" then x = InputBox("Enter your command or text:")
Set Dgn = GetObject("","Dragon.DgnEngineControl")
Dgn.Register
if x <> "" then Dgn.RecognitionMimic(x)
Dgn.UnRegister(0)
Set Dgn = Nothing


 

If you put this in a convenient spot, you can use it in your scripts to asynchronously run a recogniton:

ShellExecute "D:\path to\pgEmulate.vbs ""phrase to be recognized""", 6

 

Or, with a variable expression:

x = "phrase to be recognized"
ShellExecute "D:\path to\pgEmulate.vbs """ & x & """", 6

 

More about ShellExecute and that 6 at the end: here.  (Hint, it's supposed to run in a minimized background window - ymmv.)

 

Hth,



-------------------------




PG





Remember folks, my comments and this forum are for entertainment value only, please, no wagering or other reliance on the contents herein.  I permit no commercial use of my ideas (whether expressions or embodiments) without my written consent.



 05/22/2019 03:06 PM
User is offline View Users Profile Print this message

Author Icon
framage-ccplab
Power Member

Posts: 41
Joined: 03/27/2018

Thanks, PG

-------------------------

Frank Ramage

 05/22/2019 04:32 PM
User is offline View Users Profile Print this message

Author Icon
monkey8
Top-Tier Member

Posts: 3852
Joined: 01/14/2008

+1 as you would say or maybe +more



-------------------------

 05/23/2019 03:17 PM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2189
Joined: 03/21/2007

Here's more: Using pgEmulate on an arbitrary selection

 

In short, naturally pgEmulate can send the "select that" or "bold that" Dragon dictation commands, but it can also be used to select or bold (or change the case of) an arbitrary phrase, "select <xyz>" using the <dictation> list.



-------------------------




PG





Remember folks, my comments and this forum are for entertainment value only, please, no wagering or other reliance on the contents herein.  I permit no commercial use of my ideas (whether expressions or embodiments) without my written consent.



 12/04/2019 01:36 AM
User is offline View Users Profile Print this message

Author Icon
kkkwj
Top-Tier Member

Posts: 850
Joined: 11/05/2015

I'm curious what the trailing 6 is for. Is it something required by Dragon or is it something for pgemulate?  

Thank you for posting that script. It's quite clever!



-------------------------

Win10/11/x64, AMD Ryzen 7 3700X/3950X, 64/128GB RAM, Dragon 15.3, SP 7 Standard, SpeechStart, Office 365, KB 2017, Dragon Capture, Samson Meteor USB Desk Mic, Amazon YUWAKAYI headset, Klim and JUKSTG earbuds with microphones, 3 BenQ 2560x1440 monitors, Microsoft Sculpt Keyboard and fat mouse

 12/04/2019 10:23 AM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2189
Joined: 03/21/2007

Check out the help for ShellExecute: it is the windowStyle parameter keeping the window minimized and not active. Well, perhaps the window would only flash so briefly anyway, but I got used to using it while frequently shell-executing to any script outside Dragon (usually ahk, but more often, a vbs, as above).



-------------------------




PG





Remember folks, my comments and this forum are for entertainment value only, please, no wagering or other reliance on the contents herein.  I permit no commercial use of my ideas (whether expressions or embodiments) without my written consent.



 01/22/2020 05:47 PM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2189
Joined: 03/21/2007

Here's a neat trick if you use the same commands on different computers. Store your utility files in the Windows "User" directory (one above your user name), so typically:

C:\Users

Then access those utilities as follows:

ShellExecute Environ("USERPROFILE") & "\..\pgEmulate.vbs ""list all windows""", 6

 

More info on the useful <switcher> command including optionally saying the number of the window to switch to, is here.  Just say "switcher" to get the "list programs" window, or "switch <number>" to follow with choosing that number from the list.

 

Note, while this works in the Advanced Scripting language, the Environ function is not available in DVC legacy scripting. So, if you want to use this in your System.DVC file under the "Asleep" mode (I call it "switcher" and consider it essential) you will have to hard code the path.



-------------------------




PG





Remember folks, my comments and this forum are for entertainment value only, please, no wagering or other reliance on the contents herein.  I permit no commercial use of my ideas (whether expressions or embodiments) without my written consent.



Statistics
32210 users are registered to the KnowBrainer Speech Recognition forum.
There are currently 0 users logged in.
The most users ever online was 12124 on 09/09/2020 at 04:59 AM.
There are currently 467 guests browsing this forum, which makes a total of 467 users using this forum.

FuseTalk Standard Edition v4.0 - © 1999-2022 FuseTalk™ Inc. All rights reserved.