![]() |
KnowBrainer Speech Recognition | ![]() |
Topic Title: Repeating a Routine Topic Summary: Created On: 11/15/2020 06:20 PM Status: Post and Reply |
|
![]() |
![]() |
- Todachen | - 11/15/2020 06:20 PM |
![]() |
![]() |
- Mav | - 11/16/2020 02:16 AM |
![]() |
![]() |
- dilligence | - 11/16/2020 11:35 AM |
![]() |
![]() |
- Lunis Orcutt | - 11/16/2020 01:58 PM |
![]() |
![]() |
- Edgar | - 11/16/2020 05:18 PM |
![]() |
![]() |
- Todachen | - 11/16/2020 09:48 PM |
![]() |
![]() |
- Todachen | - 11/27/2020 01:13 PM |
![]() |
![]() |
- PG LTU | - 11/27/2020 01:57 PM |
![]() |
![]() |
- Todachen | - 11/27/2020 05:35 PM |
![]() |
![]() |
- Todachen | - 11/27/2020 05:53 PM |
![]() |
![]() |
- Todachen | - 11/27/2020 06:18 PM |
![]() |
![]() |
- Todachen | - 11/27/2020 06:34 PM |
![]() |
![]() |
- kkkwj | - 11/28/2020 02:06 AM |
![]() |
![]() |
- monkey8 | - 11/28/2020 04:47 AM |
![]() |
![]() |
- Todachen | - 11/28/2020 08:49 PM |
![]() |
![]() |
- PG LTU | - 11/28/2020 01:46 PM |
![]() |
![]() |
- kkkwj | - 11/29/2020 04:07 AM |
![]() |
![]() |
- monkey8 | - 11/29/2020 07:16 AM |
![]() |
![]() |
- Todachen | - 11/29/2020 10:37 PM |
![]() |
|
Hi everybody,
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..
------------------------- 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 |
|
|
|
![]() |
|
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 |
|
|
|
![]() |
|
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. ------------------------- Auto Box - SP Editor - HyperNotes - Pause Reminder - Speaker - Quick Correct - Easy Guide to Dragon Scripting |
|
|
|
![]() |
|
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:
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 |
|
|
|
![]() |
|
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 |
|
|
|
![]() |
|
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 |
|
|
|
![]() |
|
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 |
|
|
|
![]() |
|
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):
Hth, let us know -------------------------
|
|
|
|
![]() |
|
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 |
|
|
|
![]() |
|
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 |
|
|
|
![]() |
|
I am definitely getting something wrong here. ------------------------- 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 |
|
|
|
![]() |
|
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.
------------------------- 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 |
|
|
|
![]() |
|
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, 3 BenQ 2560x1440 monitors, Microsoft Sculpt Keyboard and fat mouse |
|
|
|
![]() |
|
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
"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 ------------------------- |
|
|
|
![]() |
|
Thank you monkey8 4 explaining all this to me. This is very helpful. ------------------------- 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 |
|
|
|
![]() |
|
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)
-------------------------
|
|
|
|
![]() |
|
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, 3 BenQ 2560x1440 monitors, Microsoft Sculpt Keyboard and fat mouse |
|
|
|
![]() |
|
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. ------------------------- |
|
|
|
![]() |
|
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 |
|
|
FuseTalk Standard Edition v4.0 - © 1999-2021 FuseTalk™ Inc. All rights reserved.