KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: Repeating a Routine
Topic Summary:
Created On: 11/15/2020 06:20 PM
Status: Post and Reply
Linear : Threading : Single : Branch
 Repeating a Routine   - Todachen - 11/15/2020 06:20 PM  
 Repeating a Routine   - Mav - 11/16/2020 02:16 AM  
 Repeating a Routine   - dilligence - 11/16/2020 11:35 AM  
 Repeating a Routine   - Lunis Orcutt - 11/16/2020 01:58 PM  
 Repeating a Routine   - Edgar - 11/16/2020 05:18 PM  
 Repeating a Routine   - Todachen - 11/16/2020 09:48 PM  
 Repeating a Routine   - Todachen - 11/27/2020 01:13 PM  
 Repeating a Routine   - PG LTU - 11/27/2020 01:57 PM  
 Repeating a Routine   - Todachen - 11/27/2020 05:35 PM  
 Repeating a Routine   - Todachen - 11/27/2020 05:53 PM  
 Repeating a Routine   - Todachen - 11/27/2020 06:18 PM  
 Repeating a Routine   - Todachen - 11/27/2020 06:34 PM  
 Repeating a Routine   - kkkwj - 11/28/2020 02:06 AM  
 Repeating a Routine   - monkey8 - 11/28/2020 04:47 AM  
 Repeating a Routine   - Todachen - 11/28/2020 08:49 PM  
 Repeating a Routine   - PG LTU - 11/28/2020 01:46 PM  
 Repeating a Routine   - kkkwj - 11/29/2020 04:07 AM  
 Repeating a Routine   - monkey8 - 11/29/2020 07:16 AM  
 Repeating a Routine   - Todachen - 11/29/2020 10:37 PM  
Keyword
 11/15/2020 06:20 PM
User is offline View Users Profile Print this message

Author Icon
Todachen
Junior Member

Posts: 37
Joined: 09/30/2020

Hi everybody,

This is my first post. So I hope I'm putting it in the right place and I hope this makes sense as I'm still learning.



So I know how to use a list to repeat one keystroke by inserting the variable for the number of key repetitions.

 

For example:

 

SendKeys "+%{ESC  "+ListVar1+"}"

The variable for the list is associated with a <1-5> list, allowing me to repeat the keystroke up to 5 times.

 

However, I want to repeat a series of multiple keystrokes. I think a computer programmer would call that a routine if I'm not mistaken.

 

So how do I get the routine to repeat itself multiple times?.

 

For example:

    SendKeys "%{F4}"
    Wait 0.1
    SendKeys "{y}"
    Wait 0.1
    SendKeys "{n}"
    Wait 0.1

I would like to be able to repeat the above keystrokes consecutively for whatever number of 
times I dictate according to the <1-5> list..


Any help that can be offered would be greatly appreciated. :-) 



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

My voice computer: W10/DPI 15.6/KB2017/VC 2020 on a Intel Core i7-8559U CPU @ 2.70GHz, 16gb DDR4, Sennheiser ME 3D 431 II / Roccat Juke – ROC-14-11-AM



 11/16/2020 02:16 AM
User is offline View Users Profile Print this message

Author Icon
Mav
Top-Tier Member

Posts: 265
Joined: 10/02/2008

Hi!
The language you use (by default) for your scripting commands is called BASIC and compatible to Microsoft Visual Basic for Applicatons.
Google it, there's a myriad of introductions and tutorials on the web.
The standard commands every BASIC interpreter knows are enhanced by Dragon-specific commands which will only work inside a macro called by a voice command.
These scripting language extensions are also well-documented. Just click "Help" from the script editor and - sorry - rtfm
hth,
mav
 11/16/2020 11:35 AM
User is offline View Users Profile Print this message

Author Icon
dilligence
Top-Tier Member

Posts: 1223
Joined: 08/16/2010

I think what you're looking for is a Do Until Loop.

 

I mostly use DVC scripting for these kind of commands (if you want to use Advanced Scripting the script will be similar):

 

if _arg1 > 1 then

c =_arg1

DO UNTIL c=0

SendKeys "{Alt+F4}"

Wait 10

SendKeys "y"

Wait 10

SendKeys "n"

Wait 10

          c=c-1

LOOP

end if

 

By the way if you are sending letters like "y" or "n" you won't need braces.

 

Loops are not 100% reliable particularly if you use a long list but with your 5 list it should work. 



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

www.speechproductivity.eu 


Auto Box - SP Editor - HyperNotes - Pause Reminder - Speaker - Quick Correct - Easy Guide to Dragon Scripting

 11/16/2020 01:58 PM
User is offline View Users Profile Print this message

Author Icon
Lunis Orcutt
Top-Tier Member

Posts: 38357
Joined: 10/01/2006

                    Welcome (See Mission Statement)

 

While there is nothing wrong with the Dilligence's legacy DVC Script we thought you might be more comfortable with a VB script, which you are probably more accustomed to. See following example:


Command Name: Kill <1to5> which is a variable that allows you to choose between 1 to 5 . Obviously you can change the name

Script:

 

Sub Main
For i = 1 To (ListVar1)
SendKeys "%{F4}"
Wait 0.1
SendKeys "y"
Wait 0.1
SendKeys "n"
Wait 0.1
Next
End Sub

 

 



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

Forum Mission Statement
Trial Downloads
Dragon/Sales@KnowBrainer.com 
(615) 884-4558 ext 1



 11/16/2020 05:18 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 985
Joined: 04/03/2009

Just to extend Lunis’ example and include the concept of (sub)routines called Functions in Basic…

Sub Main

For i = 1 To (ListVar1)

Something

Next

End Sub


Function Something

SendKeys "%{F4}"

Wait 0.1

SendKeys "y"

Wait 0.1

SendKeys "n"

Wait 0.1

End Function



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

-Edgar
DPI 15.3, 64-bit Windows 10 Pro, OpenOffice & Office 365, Norton Security, Shure X2U XLR to USB mic adapter with Audio Technica DB135 vocal mic, Asus X299-Deluxe Prime, Intel Core i9-7940X (14 core, 4.3 GHz overclocked to 4.9 GHz), G.SKILL TridentZ Series 64GB (4 x 16GB) DDR4 3333 (PC4 26600) F4-3333C16Q-64GTZ, NVIDIA GIGABYTE GeForce GTX 1060 GV-N1060G1 GAMING-6GD REV 2.0 6GB graphics card with 3 1920x1080 monitors

 11/16/2020 09:48 PM
User is offline View Users Profile Print this message

Author Icon
Todachen
Junior Member

Posts: 37
Joined: 09/30/2020

Thanks to everyone. Thanks especially for the examples. I will put them to good use in improving my knowledge. Looking forward to more posts in the future.

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

My voice computer: W10/DPI 15.6/KB2017/VC 2020 on a Intel Core i7-8559U CPU @ 2.70GHz, 16gb DDR4, Sennheiser ME 3D 431 II / Roccat Juke – ROC-14-11-AM

 11/27/2020 01:13 PM
User is offline View Users Profile Print this message

Author Icon
Todachen
Junior Member

Posts: 37
Joined: 09/30/2020

So I tried to make this work with a HeardWord looping command that calls another command: 

 

command name: 

"<direction> Window <2-5>"

 

command script: 

Option Explicit 

Sub Main 

For i = 1 To (ListVar2) 

HeardWord "Window","ListVar1" 

Next 

End Sub 

 

Command lists: 

"<direction>"

down 

left 

right 

up 

 

 

The idea here that it emulates from 2 to 5 times 1 of the 4 following other commands which I have scripted as advanced commands: 

 

"window left" 

"window right" 

"window up" 

"window down" 

 

I can even save the script because the Command Browser tells me that I've got an error in it. To my unexperienced eyes it doesn't look like there's any errors in it. It seems to conform to the examples in this forum. Is it the case that you cannot loop a HeardWord command? 

 

By the way, I'm using Dragon 15.6 on a Windows 10 machine. 

 

Any advice would be greatly appreciated :-) 

 



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

My voice computer: W10/DPI 15.6/KB2017/VC 2020 on a Intel Core i7-8559U CPU @ 2.70GHz, 16gb DDR4, Sennheiser ME 3D 431 II / Roccat Juke – ROC-14-11-AM



 11/27/2020 01:57 PM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2115
Joined: 03/21/2007

ListVar is a built-in token and is not to be quoted (unless you want a literal). Try it like so (but beware that HeardWords typically all execute after the script itself finishes - in this case, it shouldn't matter):

Option Explicit
Sub Main
    Dim i
    For i = 1 To ListVar2
        HeardWord "window", ListVar1
    Next
End Sub


EDIT: Per monkey8 below, note the added new first line which explicitily dimensions the variable i (made necessary by the default of "Option Explicit" - alternatively, one can remove or comment out that directive)

 

Hth, let us know



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




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.



 11/27/2020 05:35 PM
User is offline View Users Profile Print this message

Author Icon
Todachen
Junior Member

Posts: 37
Joined: 09/30/2020

Hey PG LTU,

Thanks for trying to help me figure this out.

I just tried that script but it's given me the "correct error in the script below" message as soon as I try to save it. So it still doesn't quite like the script.

Any suggestions?

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

My voice computer: W10/DPI 15.6/KB2017/VC 2020 on a Intel Core i7-8559U CPU @ 2.70GHz, 16gb DDR4, Sennheiser ME 3D 431 II / Roccat Juke – ROC-14-11-AM

 11/27/2020 05:53 PM
User is offline View Users Profile Print this message

Author Icon
Todachen
Junior Member

Posts: 37
Joined: 09/30/2020

I've also having trouble making this work with SendKeys. I guess there must be something I'm doing wrong here. Can anybody help me figure this out?

Based on the examples above I have designed the following script called "comment line <2-100>":

'#Language "WWB-COM"

Option Explicit

Sub Main
For i = 1 To (ListVar1)
SendKeys "{Home}"
Wait .1
SendKeys "{'}"
Wait .1
SendKeys "{Space}"
Wait .1
SendKeys "{Down}"
Wait .1
Next
End Sub

What I would like to do is put in' in front of each line inside of the command editor to disable those lines of code by commenting them out.

I've also tried this with "'" (apostrophe) inside of brackets , as seen above, AND without brackets.

I can't see any difference between this and the above posted by Lunis. I am definitely scratching my head. Anybody have any ideas?


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

My voice computer: W10/DPI 15.6/KB2017/VC 2020 on a Intel Core i7-8559U CPU @ 2.70GHz, 16gb DDR4, Sennheiser ME 3D 431 II / Roccat Juke – ROC-14-11-AM

 11/27/2020 06:18 PM
User is offline View Users Profile Print this message

Author Icon
Todachen
Junior Member

Posts: 37
Joined: 09/30/2020

I am definitely getting something wrong here.

I have just tried to replicate Lunis's "Kill <1to5>" by pasting exactly what Lunis has posted above into the editor. I'm getting the check your syntax error.

Does anybody have any suggestions?



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

My voice computer: W10/DPI 15.6/KB2017/VC 2020 on a Intel Core i7-8559U CPU @ 2.70GHz, 16gb DDR4, Sennheiser ME 3D 431 II / Roccat Juke – ROC-14-11-AM



 11/27/2020 06:34 PM
User is offline View Users Profile Print this message

Author Icon
Todachen
Junior Member

Posts: 37
Joined: 09/30/2020

Okay so I was attempting to script these in Dragon professional' s own command editor. I attempted to script them in KnowBrainer's command editor. It gives a more detailed error if you do it with KnowBrainer.

It really does not like line 3 ("For i = 1 …")  because it gives this error: 


"Description: Expecting an existing scalar var.
Line: 3
Additional information: Expecting an existing scalar var."

The same error occurs for these 2 different commands:

Option Explicit
Sub Main
For i = 1 To (ListVar1)
SendKeys "{Home}"
Wait .1
SendKeys "{'}"
Wait .1
SendKeys "{Space}"
Wait .1
SendKeys "{Down}"
Wait .1
Next
End Sub

_____

Option Explicit
Sub Main
For i = 1 To ListVar2
HeardWord "window", ListVar1
Next
End Sub



I think it needs the variable to be identified somehow before gets introduced online 3 as in the 2 examples above. Am I on the right track? If so, DOES anybody know what I should do?



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

My voice computer: W10/DPI 15.6/KB2017/VC 2020 on a Intel Core i7-8559U CPU @ 2.70GHz, 16gb DDR4, Sennheiser ME 3D 431 II / Roccat Juke – ROC-14-11-AM



 11/28/2020 02:06 AM
User is offline View Users Profile Print this message

Author Icon
kkkwj
Top-Tier Member

Posts: 565
Joined: 11/05/2015

Try removing the () around ListVar1 to give

for i = 1 to ListVar1



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

Win10/x64, AMD Ryzen 7 3700X, 64GB RAM, Dragon 15.3, SP 6 PRO, SpeechStart, Office 365, KB 2017, Dragon Capture, Samson Meteor USB Desk Mic, Klim and JUKSTG earbuds with microphones

 11/28/2020 04:47 AM
User is offline View Users Profile Print this message

Author Icon
monkey8
Top-Tier Member

Posts: 3642
Joined: 01/14/2008

Originally posted by: Todachen Hey PG LTU, Thanks for trying to help me figure this out. I just tried that script but it's given me the "correct error in the script below" message as soon as I try to save it. So it still doesn't quite like the script. Any suggestions?

 

The reason your scripts are failing is because you are using the term "Option Explicit" which means that with the script in question you are not able to use undeclared variables. However you are using undeclared variables. Therefore to get the script working in Dragon that PG gave you just remove the line saying Option Explicit or alternatively change the line to "Option Explicit Off". In the script immediately below I have just removed the line saying Option Explicit. You will also find that repeating HeardWord scripts will be painfully slow and you will be better using case statement for the different list variable options and within each case running the script itself for the appropriate window direction.

 

Sub Main
    For i = 1 To ListVar2
        HeardWord "window", ListVar1
    Next
End Sub

 

Originally posted by: Todachen Okay so I was attempting to script these in Dragon professional' s own command editor. I attempted to script them in KnowBrainer's command editor. It gives a more detailed error if you do it with KnowBrainer. It really does not like line 3 ("For i = 1 …")  because it gives this error: 

 

"Description: Expecting an existing scalar var. Line: 3  

 

 

Regarding the KnowBrainer script and the message expecting scalar var again you are using Option Explicit which requires all variables to be declared as Dim or ReDim which you are not doing but instead you're using undeclared variables. Therefore same remedy again as below. The issue has nothing to do with brackets around ListVar1.

 

Option Explicit Off
Sub Main
For i = 1 To (ListVar1)
SendKeys "{Home}"
Wait .1
SendKeys "{'}"
Wait .1
SendKeys "{Space}"
Wait .1
SendKeys "{Down}"
Wait .1
Next
End Sub


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



 11/28/2020 08:49 PM
User is offline View Users Profile Print this message

Author Icon
Todachen
Junior Member

Posts: 37
Joined: 09/30/2020

Thank you monkey8 4 explaining all this to me. This is very helpful.

"You will also find that repeating HeardWord scripts will be painfully slow and you will be better using case statement for the different list variable options and within each case running the script itself for the appropriate window direction."

I hear what you're saying here and understand what you're saying conceptually by trying to code it into each case. Or at least I think I understand what you're saying. But I don't know how I would actually write this. If you have the time to give me some examples illustrating what you're saying here I would really appreciate it.



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

My voice computer: W10/DPI 15.6/KB2017/VC 2020 on a Intel Core i7-8559U CPU @ 2.70GHz, 16gb DDR4, Sennheiser ME 3D 431 II / Roccat Juke – ROC-14-11-AM

 11/28/2020 01:46 PM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2115
Joined: 03/21/2007

Thx monkey8 - yes ever since that option directive was added as a default, I keep forgetting. I edited my response above to add dimming the variable i as the first line (which is another way of avoiding those errors - but this way while maintaining the option directive that is in place)

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




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.

 11/29/2020 04:07 AM
User is offline View Users Profile Print this message

Author Icon
kkkwj
Top-Tier Member

Posts: 565
Joined: 11/05/2015

Thanks from me too, Lindsay. I never thought of the Options Explicit setting at all.

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

Win10/x64, AMD Ryzen 7 3700X, 64GB RAM, Dragon 15.3, SP 6 PRO, SpeechStart, Office 365, KB 2017, Dragon Capture, Samson Meteor USB Desk Mic, Klim and JUKSTG earbuds with microphones

 11/29/2020 07:16 AM
User is offline View Users Profile Print this message

Author Icon
monkey8
Top-Tier Member

Posts: 3642
Joined: 01/14/2008

Originally posted by: Todachen Thank you monkey8 4 explaining all this to me. …  But I don't know how I would actually write this. If you have the time to give me some examples illustrating what you're saying here I would really appreciate it.

 

 

Sub Main

Select Case ListVar1

Case "down"

  For i = 1 To (ListVar2)

    'run the script contents for the windows down command here, 

  Next

Case "up"

  For i = 1 To (ListVar2)

    'run the script contents for the windows up command here, 

  Next

Case "right"

  For i = 1 To (ListVar2)

    'run the script contents for the windows right command here, 

  Next

Case "left"

  For i = 1 To (ListVar2)

    'run the script contents for the windows left command here, 

  Next

End Select

End Sub

 

 

Of course you may be able abbreviate the script further depending on the contents of your Windows direction scripts.



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



 11/29/2020 10:37 PM
User is offline View Users Profile Print this message

Author Icon
Todachen
Junior Member

Posts: 37
Joined: 09/30/2020

Awesome monkey8! Thank you so much for taking the time to show this to me. I'm going to take this and apply it to all kinds of other scripts that I'm planning. Thanks to everyone in this forum for being so helpful. This was really useful for me I'm in a take this and be able to apply this knowledge to lots of other scripts.



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

My voice computer: W10/DPI 15.6/KB2017/VC 2020 on a Intel Core i7-8559U CPU @ 2.70GHz, 16gb DDR4, Sennheiser ME 3D 431 II / Roccat Juke – ROC-14-11-AM



KnowBrainer Speech Recognition » KnowBrainer Software and Support » Repeating a Routine

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

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