KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: Multiple Steps in If Then Statement
Topic Summary:
Created On: 11/28/2020 10:08 PM
Status: Post and Reply
Linear : Threading : Single : Branch
 Multiple Steps in If Then Statement   - Todachen - 11/28/2020 10:08 PM  
 Multiple Steps in If Then Statement   - Todachen - 11/28/2020 10:51 PM  
 Multiple Steps in If Then Statement   - Edgar - 11/29/2020 11:26 AM  
 Multiple Steps in If Then Statement   - Todachen - 12/24/2020 10:37 PM  
 Multiple Steps in If Then Statement   - Edgar - 12/25/2020 11:19 AM  
 Multiple Steps in If Then Statement   - Todachen - 12/29/2020 02:51 PM  
 Multiple Steps in If Then Statement   - Todachen - 11/29/2020 10:35 PM  
 Multiple Steps in If Then Statement   - Mav - 11/30/2020 02:17 AM  
 Multiple Steps in If Then Statement   - Todachen - 11/30/2020 05:07 PM  
 Multiple Steps in If Then Statement   - PG LTU - 12/29/2020 02:58 PM  
Keyword
 11/28/2020 10:08 PM
User is offline View Users Profile Print this message

Author Icon
Todachen
Junior Member

Posts: 37
Joined: 09/30/2020

Hi everybody,

So I have the following script which I use to insert SendKeys code into Dragon's command editor window for advanced scripting:

 

'#Language "WWB-COM"

Option Explicit

Sub Main
    
    SendKeys "{end}~"
    Wait 0.1
    SendKeys "SendKeys """
    Wait 0.1
    SendKeys """
    Wait 0.1
    SendKeys "~"
    Wait 0.1
    SendKeys "Wait .1"
    Wait 0.1
    SendKeys "{left}{up}{end}{left}"
    Wait 0.1
End Sub



What I would like to do is wrap this entire script up into an if then statement in a listing command. That would require that the multiple steps that are shown above get wrapped into one line inside if then statement that is associated with a list called "", which has as one of its items "insert SendKeys"

 

If ListVar1 = "insert SendKeys" Then SendKeys "{end}~" Wait 0.1 SendKeys "SendKeys """ Wait 0.1 SendKeys """ Wait 0.1 SendKeys "~" Wait 0.1 SendKeys "Wait .1" SendKeys "{Left}{up}{End}{Left}""

 

So as you can see I've tried to take the multiple steps above and put them onto one line in the if then statement above.


I believe I used to build to do this with listing commands in Windows speech recognition macros. However, when I try to save this command with the Dragon command editor or when I try in KnowBrainer command editor (after correcting for its own idiosyncraticies) ,it gives me a syntax error message.

 

I have a feeling that I need to figure out how to better use the multiple step recursive routines that we have discussed in this forum, in order to be able to make this work in a list. But I currently lack the experience and knowledge necessary to figure out how to wrap multiple steps into a listing command.

 

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/28/2020 10:51 PM
User is offline View Users Profile Print this message

Author Icon
Todachen
Junior Member

Posts: 37
Joined: 09/30/2020

I should also add that I have attempted to add in the wait code using the "wait" attribute (I think that's the correct word for it) of the SendKeys script as is described in the literature provided by Nuance at the following website:



https://www.nuance.com/products/help/dragon/dragon-for-pc/scriptref/Content/vbs/sendkeys_instruction.htm



As explained on this website there is a wait attribute to the SendSystemKeys script as shown below:



SendKeys Keys$[, Wait]



If you click on the link above describing this attribute it will show you that Nuance describes the attribute as a numerical value.



"Num definition

An expression that returns a numeric result. Use &O to express an octal number. Use &H to express a hex number"



I have been unable to to make this function. I've tried it with the comma, without it with and without brackets, with and without quotation marks, but I am unable to get it to work.

 

Has anybody played with this "wait" attribute, and does anybody know how to make it work. If I'm understanding, I think I should be able to pull off the multistep if then statement described in the previous message if there is a way I can figure out how to make the system wait using this attribute in between keystrokes. 



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

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/29/2020 11:26 AM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1041
Joined: 04/03/2009

      XXX = 0

      If XXX = 0 Then

         MsgBox "XXX = 0"

         Wait 0.1' superfluous statement

            ' just show you can see how

         SendKeys "{Home}", 1'SendKeys using the optional Wait parameter

      ElseIf XXX > 0 Then

         MsgBox "XXX > 0"

      ElseIf XXX < 0 Then

         MsgBox "XXX < 0"

      Else

         TTSPlayString "Unrecognized value!"

         Wait 2.5

         MsgBox "unrecognized value"

         Exit All

      End If



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

-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

 12/24/2020 10:37 PM
User is offline View Users Profile Print this message

Author Icon
Todachen
Junior Member

Posts: 37
Joined: 09/30/2020

Thanks again for this Edgar.

 

I'm wondering if you know of any disadvantages to using the wait parameter at the end of the SendKeys line. Seems to me that that's an easier way to do it then coding a separate Wait line below the SendKeys line, which seems to be the way that most people prefer to do it.

Is coding a separate Wait line just convention? I don't get why people don't just throw it in at the end of the SendKeys line.

 



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

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

 12/25/2020 11:19 AM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1041
Joined: 04/03/2009

Originally posted by: Todachen  I don't get why people don't just throw it in at the end of the SendKeys line.

I ALWAYS add the optional value; here is my macro for building an "empty" SendKeys line:
Sub
Main
   SendKeys "SendKeys """", 1", 1
   SendKeys "{Left 4}", 1
End Sub

However, I expect that, by this stage of the game, Nuance has probably made the default value "true"/"1" - and if not, why not? I can think of absolutely no situation (given the current state of hardware) where one might want to consider processing additional statements while SendKeys is outputting characters.



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

-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

 12/29/2020 02:51 PM
User is offline View Users Profile Print this message

Author Icon
Todachen
Junior Member

Posts: 37
Joined: 09/30/2020

Hello again Edgar,

So I've tried to test using the optional wait parameter, and it seems to ignore it completely.

For example:

Sub Main
         SendKeys "_", 3
         SendKeys "{BS}"
End Sub



If you test this in Notepad. I can see that the "_" key has been entered but then instantaneously deleted by the backspace key stroke without waiting for 3 seconds before deleting the "_". I have tried putting the weight parameter at the end of the SendKeys line in other commands and I cannot seem to get it to work. I also tried this as both "option explicit", and with the words "option explicit" deleted.

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/29/2020 10:35 PM
User is offline View Users Profile Print this message

Author Icon
Todachen
Junior Member

Posts: 37
Joined: 09/30/2020

Thank you Edgar. I will take a look at this and see if I can figure it out.

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

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/30/2020 02:17 AM
User is offline View Users Profile Print this message

Author Icon
Mav
Top-Tier Member

Posts: 319
Joined: 10/02/2008

Todachen, since you want to start writing your own scripts, I think it's really essential for you to learn the basics of VBA.

There's a myriad of tutorials out there making the process a lot less painful than asking in this forum for elementary language constructs.

For example, wikibooks has an overview of the commands and control structures:

BASIC Programming - Wikibooks, open books for an open world

 

hth,

mav

 11/30/2020 05:07 PM
User is offline View Users Profile Print this message

Author Icon
Todachen
Junior Member

Posts: 37
Joined: 09/30/2020

Thank you for the tip :-) I will check that out.



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

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

 12/29/2020 02:58 PM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2126
Joined: 03/21/2007

Sorry, you mis-understood. The value is not "seconds" (or even "milliseconds") but rather a Boolean, that is either: true (1) or false (0), value only. The period of time is until the cpu reports the "send" is done.

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




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

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