![]() |
KnowBrainer Speech Recognition | ![]() |
Topic Title: Sample Advanced Script Instructions for Dummies (Like Me) Topic Summary: Created On: 01/01/2022 09:42 PM Status: Post and Reply |
|
![]() |
![]() |
- Tomc | - 01/01/2022 09:42 PM |
![]() |
![]() |
- Alan Cantor | - 01/02/2022 12:18 PM |
![]() |
![]() |
- wristofdoom | - 01/02/2022 03:40 PM |
![]() |
![]() |
- Tomc | - 01/02/2022 04:15 PM |
![]() |
![]() |
- Matt_Chambers | - 01/02/2022 05:17 PM |
![]() |
![]() |
- wristofdoom | - 01/04/2022 07:22 PM |
![]() |
![]() |
- noblemd | - 01/04/2022 08:19 PM |
![]() |
![]() |
- noblemd | - 01/04/2022 10:17 PM |
![]() |
![]() |
- noblemd | - 01/04/2022 10:33 PM |
![]() |
![]() |
- noblemd | - 01/04/2022 10:40 PM |
![]() |
![]() |
- GarethR | - 01/02/2022 04:21 PM |
![]() |
![]() |
- Alan Cantor | - 01/02/2022 05:03 PM |
![]() |
![]() |
- Matt_Chambers | - 01/02/2022 05:21 PM |
![]() |
![]() |
- Alan Cantor | - 01/02/2022 06:53 PM |
![]() |
![]() |
- ax | - 01/03/2022 06:11 PM |
![]() |
![]() |
- ax | - 01/04/2022 08:52 PM |
![]() |
![]() |
- ax | - 01/04/2022 09:09 PM |
![]() |
![]() |
- Matt_Chambers | - 01/05/2022 12:07 PM |
![]() |
![]() |
- Alan Cantor | - 01/05/2022 12:41 PM |
![]() |
|
This is a post intended to help beginners write an Advance Script command called “Reproduce My ”.
I have very little experience writing commands for Dragon. When I was a rank newbie I found the instructions from those who know more to be a bit intimidating. Some steps that were very obvious to the old timers took a lot of trial and error for me to figure out. So, I thought I would post this in the hopes it might be helpful to someone just starting with code. Since my knowledge is limited, any helpful hints or comments from those with more experience is encouraged.
I had a lot of individual commands that would insert an address, phone number, card number, or whatever into a form or file. Managing too many of these became a bit cumbersome, so I wanted to combine them all into one file. I call it a Variable command, but that probably isn’t the proper term. Perhaps someone can correct me on that. Here are the instructions, as simple and straightforward as I was able to manage. Again, input or corrections from someone more experienced is welcome.
The [ ]s are for clarity, do not type or say them.
Say [Open Command Browser]
Say or select [New] from the Task Pane on the left. (Open the Task Pane from the menu if it isn’t visible.)
Say or type [Reproduce My] (without the square brackets, but with the sharp brackets) into the MyCommand Name box.
I have found the only way to change the command name, after the <>’s have been entered into the MyCommands Name box, is by using the box that pops up when you click the command title. Perhaps someone more knowledgeable could comment on this.
In the Description box, put whatever you like or leave it blank. This is just for your own future reference.
In the Group box, choose the group you’d like it to be in. This is not important until you start having so many commands that you can’t keep track. For now, it’s okay to put in the All category.
Select either Global, Application-specific, or Window-specific in the line below. If you want this command to be used in all programs then choose Global. If there’s only a single Application in which you want to use the command, choose Application-specific or Window-specific. Make sure the relevant application is open. Then, in the bar underneath (which isn’t visible if you have selected Global). click the down arrow and select that specific application or program.
In the Command Type box click the down arrow and select Advanced Scripting.
Select “Name Editor”. A box entitled MyCommands Name Editor will pop up.
Put your list name (in this case CardNumbers) in the white box below. Double click the list name you have just entered in order to open it. (The list below is mine. Make up your own list of things you want the command to say.)
This sample list has five variables, but add as many as you like.
library card complete address part address telephone number postal code
When you have your list complete, click OK. The box will disappear. Then you type or paste the following (amended to suit your particular needs) in the code box below, between the “Sub Main” and “End Sub” lines.
Select Case ListVar1 Case "library card" SendKeys “22361084", 1 Case "part address" SendKeys "any, whatever St.", 1 Case "complete address" SendKeys "any apartment, whatever St. city, country ZIP Code", 1 Case "telephone number" SendKeys "555-555-5555", 1 Case "postal code" SendKeys "A83 T13", 1 Case Else TTSPlayString "too many" Exit All End Select
To add extra variables, insert the following two lines in the appropriate position:
Case "" SendKeys “", 1
Add your own Command Variable name between the quotes in the first line, and the result you want between the quotes in the second line. Be sure to also add the name to your list in .
Press Save.
If it worked you can now say “Reproduce My [library card]”, or whatever other item on the list to get the desired print out. You can change the Reproduce My command name, CardNumbers list name, the terms in the list, or SendKeys phrases to suit your needs. That’s it. I hope I haven’t made any mistakes to mess you up. |
|
|
|
![]() |
|
That's a very good summary!
The line sandwiched between the first and third means this: Output the text that appears on the left side of the backslash. |
|
|
|
![]() |
|
The line sandwiched between the first and third means this:
Output the text that appears on the left side of the backslash.
Mind is blown ------------------------- Dragon Professional Individual v15.6. Windows 10. Knowbrainer 2017. |
|
|
|
![]() |
|
Wow. My mind is blown also. This is so much easier and tidier than my instructions above. I will definitely be changing my command to this format. Thanks. |
|
|
|
![]() |
|
Yes, this is the format I usually use. Easy and tidy and easier to update than adding a new Case instruction or an ElseIf. Edit: it is a particularly good method where you want to control an application by means of keystrokers. |
|
|
|
![]() |
|
Can somebody break down what exactly is going on in here and why it works?
What are the `Mid` and `Instr` functions?
What are the `1` and `-1` parameters?
------------------------- Dragon Professional Individual v15.6. Windows 10. Knowbrainer 2017. |
|
|
|
![]() |
|
Can somebody break down what exactly is going on in here and why it works? What are the `Mid` and `Instr` functions? What are the `1` and `-1` parameters?
You can find full instruction info for advanced scripting at: WinWrap® | Basic Documentation Click on the instruction link and an explanation page will load about that instruction.
and also see... Dragon scripting language extensions quick reference (nuance.com) ------------------------- Michael Noble
DPI 15.61.200.010 - Windows 11 Pro for Workstations Latest Update / MS Office 2021 LTSC |
|
|
|
![]() |
|
Specific explanation: Mid("Hello",2,1) = "e" = Return "1" one character starting at the 2nd ("2") character
Mid("Hello",2,3) = "ell" = Return "3" characters starting at the 2nd ("2") character
InStr("Hello","l") = 3 = In "Hello" return the position of the first occurrence of the letter "l" ------------------------- Michael Noble
DPI 15.61.200.010 - Windows 11 Pro for Workstations Latest Update / MS Office 2021 LTSC |
|
|
|
![]() |
|
SendKeys Mid(ListVar1, 1, Instr(ListVar1, "\")-1), 1 . explanation of this partial command... .
In ListVar1 find the characters at the position before ("-1") the first occurrence of "\" (backslash) in ListVar1 and send (SendKeys) the characters as if the key was pressed. . More things may be done in the complete command before sending the keys. This is only the explanation of this partial command. ------------------------- Michael Noble
DPI 15.61.200.010 - Windows 11 Pro for Workstations Latest Update / MS Office 2021 LTSC |
|
|
|
![]() |
|
When creating a new advanced scripting command in DNS the following is inserted in the command window
'#Language "WWB-COM" = WinWrap® Basic ' WinWrap® | Basic Documentation ------------------------- Michael Noble
DPI 15.61.200.010 - Windows 11 Pro for Workstations Latest Update / MS Office 2021 LTSC |
|
|
|
![]() |
|
Alan, that's awesome.
I assume that multi-line inserts would still need to use the following? (this may be of use to you Tomc): Dim CB As String CB = Clipboard 'store what is already on your clipboard Clipboard "multiple" & vbCrLf & _ "line" & vbCrLf & _ "inserts" SendDragonKeys "{Ctrl+v}" Clipboard CB 'restore your clipboard at the end of the Advanced Scripting Command ------------------------- DPI 15.61 | Plantronics D100 | Windows 10 Home | Intel(R) Core(TM) i5-10210U CPU 1.60GHz |
|
|
|
![]() |
|
Hi Gareth,
That's a good question... I'm not sure how to adapt this technique for multiline inserts. It would be convenient if the "written form" could contain text AND linebreaks. I have a vague recollection that this topic was discussed on this forum years ago, but I don't remember the solution. |
|
|
|
![]() |
|
Can't you just include "{Enter}" or "~", as needed, in the text string? |
|
|
|
![]() |
|
Hi Matt,
You're right, that's all that's needed! 123 Main Street,{Enter}Suite 567,{Enter}Anytown\Complete Address |
|
|
|
![]() |
|
That's a very good summary!
Here's a trick to simplify Dragon commands that use lists: when creating the list, combine the written form and the spoken form on one line, separated by a backslash:
123456-789\library card 444 Main Street, Suite 555, Never-never-land\Complete address 444 Main Street\part address 01-555-5555\telephone number M2V 2X9\postal code
Then the entire script only needs to be three lines long:
Sub Main SendKeys Mid(ListVar1, 1, Instr(ListVar1, "\")-1), 1 End Sub This thread is yet another example on how regulars of this forum (Alan, Matt, PG, etc.) help others, day in and day out, and over the years. On a separate note, I have had late Mr. Larry Allen's book since Jan, 2014, when it arrived from KB, along with DMPE 2.0. KB currently sells the book for the same price ($49) as it did back then. Factoring in inflation, that is discount. I read the book nearly from cover to cover, and directly as a result of it, decided to embark on learning AutoHotKey as my go-to RPA tool on Windows. The reasons had to do with applicability (outside of Dragon), portability, and supportability mainly. Anyhow, for desktop dragoneers, this book remains highly relevant. This thread is ALL THE PROOF you need. Mid(ListVar1, 1, Instr(ListVar1, "\")-1), including an analogous list to above, are available verbatim on Page 42, Chapter 5: List/Template Commands. |
|
|
|
![]() |
|
Can somebody break down what exactly is going on in here and why it works? What are the `Mid` and `Instr` functions? What are the `1` and `-1` parameters? You can find full instruction info for advanced scripting at: WinWrap® | Basic Documentation Click on the instruction link and an explanation page will load about that instruction. and also see... Dragon scripting language extensions quick reference (nuance.com) |
|
|
|
![]() |
|
To WOD:
If Advanced Scripting is what you want to grasp, getting his book is what I consider to be the beginning of "self-help".
in spite of the little that I know, I will say that if you are a "MS Word" person, or relies on automating MS Office family of apps for a living, learning VB/VBA is a nobrainer. |
|
|
|
![]() |
|
One of my favorite macros for Microsoft Word uses the Mid instruction. I create a list that includes my custom macros for Word and some built-in Word commands, and give each entry my own spoken form (or multiple spoken forms.) Here's an excerpt from the list that will give you an idea: |
|
|
|
![]() |
|
For many if not all of the examples in this thread, a slight simplification is possible:
Instead of this: Mid(ListVar1, 1, Instr(ListVar1, "\")-1) Use this: Left(ListVar1, Instr(ListVar1,"\")-1) I find the "Left" function a little easier to understand than the "Mid" function because the first character in the string is always its leftmost character. It's okay to use code without thoroughly understanding it! |
|
|
FuseTalk Standard Edition v4.0 - © 1999-2022 FuseTalk™ Inc. All rights reserved.