KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: Sample Advanced Script Instructions for Dummies (Like Me)
Topic Summary:
Created On: 01/01/2022 09:42 PM
Status: Post and Reply
Linear : Threading : Single : Branch
 Sample Advanced Script Instructions for Dummies (Like Me)   - Tomc - 01/01/2022 09:42 PM  
 Sample Advanced Script Instructions for Dummies (Like Me)   - Alan Cantor - 01/02/2022 12:18 PM  
 Sample Aduanced Script Instructions for Dummies (Like Me)   - wristofdoom - 01/02/2022 03:40 PM  
 Sample Aduanced Script Instructions for Dummies (Like Me)   - Tomc - 01/02/2022 04:15 PM  
 Sample Aduanced Script Instructions for Dummies (Like Me)   - Matt_Chambers - 01/02/2022 05:17 PM  
 Sample Advanced Script Instructions for Dummies (Like Me)   - wristofdoom - 01/04/2022 07:22 PM  
 Sample Advanced Script Instructions for Dummies (Like Me)   - noblemd - 01/04/2022 08:19 PM  
 Sample Advanced Script Instructions for Dummies (Like Me)   - noblemd - 01/04/2022 10:17 PM  
 Sample Advanced Script Instructions for Dummies (Like Me)   - noblemd - 01/04/2022 10:33 PM  
 Sample Advanced Script Instructions for Dummies (Like Me)   - noblemd - 01/04/2022 10:40 PM  
 Sample Advanced Script Instructions for Dummies (Like Me)   - GarethR - 01/02/2022 04:21 PM  
 Sample Advanced Script Instructions for Dummies (Like Me)   - Alan Cantor - 01/02/2022 05:03 PM  
 Sample Advanced Script Instructions for Dummies (Like Me)   - Matt_Chambers - 01/02/2022 05:21 PM  
 Sample Advanced Script Instructions for Dummies (Like Me)   - Alan Cantor - 01/02/2022 06:53 PM  
 Sample Advanced Script Instructions for Dummies (Like Me)   - ax - 01/03/2022 06:11 PM  
 Sample Advanced Script Instructions for Dummies (Like Me)   - ax - 01/04/2022 08:52 PM  
 Sample Advanced Script Instructions for Dummies (Like Me)   - ax - 01/04/2022 09:09 PM  
 Sample Advanced Script Instructions for Dummies (Like Me)   - Matt_Chambers - 01/05/2022 12:07 PM  
 Sample Advanced Script Instructions for Dummies (Like Me)   - Alan Cantor - 01/05/2022 12:41 PM  
Keyword
 01/01/2022 09:42 PM
User is offline View Users Profile Print this message

Author Icon
Tomc
Junior Member

Posts: 37
Joined: 10/14/2019

 

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"

      SendKeys22361084", 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.



 01/02/2022 12:18 PM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 4280
Joined: 12/08/2007

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

 

The line sandwiched between the first and third means this:

Output the text that appears on the left side of the backslash.



 01/02/2022 03:40 PM
User is offline View Users Profile Print this message

Author Icon
wristofdoom
Top-Tier Member

Posts: 320
Joined: 09/03/2020

Originally posted by: Alan Cantor 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

 

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.

 01/02/2022 04:15 PM
User is offline View Users Profile Print this message

Author Icon
Tomc
Junior Member

Posts: 37
Joined: 10/14/2019

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.

 01/02/2022 05:17 PM
User is offline View Users Profile Print this message

Author Icon
Matt_Chambers
Top-Tier Member

Posts: 550
Joined: 08/09/2018

Originally posted by: Tomc 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.



 01/04/2022 07:22 PM
User is offline View Users Profile Print this message

Author Icon
wristofdoom
Top-Tier Member

Posts: 320
Joined: 09/03/2020

SendKeys Mid(ListVar1, 1, Instr(ListVar1, "\")-1), 1

 

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.

 01/04/2022 08:19 PM
User is offline View Users Profile Print this message

Author Icon
noblemd
Junior Member

Posts: 35
Joined: 08/09/2019

Originally posted by: wristofdoom
SendKeys Mid(ListVar1, 1, Instr(ListVar1, "\")-1), 1

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
-------------------------
Using $20 USB Mic on adjustable arm ($30 total cost - 99.9% recognition). 


 


DPI 15.61.200.010 - Windows 11 Pro for Workstations Latest Update / MS Office 2021 LTSC



 01/04/2022 10:17 PM
User is offline View Users Profile Print this message

Author Icon
noblemd
Junior Member

Posts: 35
Joined: 08/09/2019

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
-------------------------
Using $20 USB Mic on adjustable arm ($30 total cost - 99.9% recognition). 


 


DPI 15.61.200.010 - Windows 11 Pro for Workstations Latest Update / MS Office 2021 LTSC



 01/04/2022 10:33 PM
User is offline View Users Profile Print this message

Author Icon
noblemd
Junior Member

Posts: 35
Joined: 08/09/2019

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
-------------------------
Using $20 USB Mic on adjustable arm ($30 total cost - 99.9% recognition). 


 


DPI 15.61.200.010 - Windows 11 Pro for Workstations Latest Update / MS Office 2021 LTSC



 01/04/2022 10:40 PM
User is offline View Users Profile Print this message

Author Icon
noblemd
Junior Member

Posts: 35
Joined: 08/09/2019

When creating a new advanced scripting command in DNS the following is inserted in the command window

'#Language "WWB-COM"   =  WinWrap® Basic
' Option Explicit ' Sub Main ' End Sub
'
WinWrap® | Basic Documentation


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

Michael Noble
-------------------------
Using $20 USB Mic on adjustable arm ($30 total cost - 99.9% recognition). 


 


DPI 15.61.200.010 - Windows 11 Pro for Workstations Latest Update / MS Office 2021 LTSC



 01/02/2022 04:21 PM
User is offline View Users Profile Print this message

Author Icon
GarethR
New Member

Posts: 11
Joined: 05/27/2021

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

"Confidence isn't walking into a room thinking you are better than everyone; it's walking in not having to compare yourself at all."

 01/02/2022 05:03 PM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 4280
Joined: 12/08/2007

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.


 01/02/2022 05:21 PM
User is offline View Users Profile Print this message

Author Icon
Matt_Chambers
Top-Tier Member

Posts: 550
Joined: 08/09/2018

Originally posted by: Alan Cantor 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?

 01/02/2022 06:53 PM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 4280
Joined: 12/08/2007

Hi Matt,

You're right, that's all that's needed!

123 Main Street,{Enter}Suite 567,{Enter}Anytown\Complete Address
 01/03/2022 06:11 PM
User is offline View Users Profile Print this message

Author Icon
ax
Top-Tier Member

Posts: 386
Joined: 03/22/2012

Originally posted by: wristofdoom
Originally posted by: Alan Cantor

 

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

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



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.



 01/04/2022 08:52 PM
User is offline View Users Profile Print this message

Author Icon
ax
Top-Tier Member

Posts: 386
Joined: 03/22/2012

Originally posted by: noblemd
Originally posted by: wristofdoom
SendKeys Mid(ListVar1, 1, Instr(ListVar1, "\")-1), 1


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)




 01/04/2022 09:09 PM
User is offline View Users Profile Print this message

Author Icon
ax
Top-Tier Member

Posts: 386
Joined: 03/22/2012

To WOD:

I must confess that I agonized a bit as to whether I should have uploaded the above page from Larry Allen's book.  You joined this forum almost 11 months after Mr. Allen's passing.  Somehow I feel that had he been here to witness your zeal for knowledge, he would at least have liked to answer you himself.


Make absolutely no mistake: above is the only page I will put up from his book.  I don't feel too out-of-line because Google Books routinely post entire pages from books as "advertisement".  But should his Estate object to having the page up there, I (or Lunis) will surely without any qualm take it down.

 

If Advanced Scripting is what you want to grasp, getting his book is what I consider to be the beginning of "self-help".

In the middle of the page above you will find answers to your question in print.

My understanding is that "Mid" is a VB string-operation function.

What is the relationship between Advanced Scripting and "VB" then?

Darned if I know.

But I will quote you the experts:

https://knowbrainer.com/forums/forum/messageview.cfm?catid=12&threadid=24506

Unfortunately, if you are anything like me, you will be more confused AFTER reading the thread above than BEFORE reading it.  But no one has to my knowledge accused Dragon programming of being super "easy". 

 

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.



 01/05/2022 12:07 PM
User is offline View Users Profile Print this message

Author Icon
Matt_Chambers
Top-Tier Member

Posts: 550
Joined: 08/09/2018

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:


ViewZoomPageWidth\page width
ViewZoomWholePage\view whole page
mAcceptAll\accept all changes
mAcceptAll\accept all
mAcceptAndNext\accept and next

The entries with the letter "m" are my custom macros; the others are built into Word do not require me to do a custom macro.

In other words, when I am reviewing a copy marked to show changes, I can simply say "accept all changes" and Dragon will trigger a Microsoft Word macro I have created that accepts all the changes.

The text of the command is pretty simple:

Option Explicit
Dim Extract As String
Sub Main
Extract = Mid(ListVar1,1,InStr(ListVar1,"\")-1)
Application.Run(Extract)
End Sub

Because the Application.Run instruction is from Word's VBA code, and is not native to Advance Scripting, you need to include a reference to the Microsoft Word Object library. The specific reference will depend on which version of Word you have. To include the reference, you need to have the cursor in the body of the command and say "alt plus enter". You will be presented with a lengthy list of possible object references to all sorts of applications on your computer. You will need to scroll down until you find Microsoft Word. Or say "spell November, to get a press of "n", and then scroll up a little ways until you find Microsoft Word.

With this command, I can trigger all sorts of Microsoft Word macros and built-in commands. To find what built-in commands are available in Word, use this article:

https://www.lifewire.com/listing-all-commands-available-in-word-3539743

Have fun!



 01/05/2022 12:41 PM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 4280
Joined: 12/08/2007

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!
Statistics
32285 users are registered to the KnowBrainer Speech Recognition forum.
There are currently 1 users logged in.
The most users ever online was 12124 on 09/09/2020 at 04:59 AM.
There are currently 386 guests browsing this forum, which makes a total of 387 users using this forum.

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