KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: Can you include multiple argument statements that will execute my other saved commands via EmulateRecognition?
Topic Summary:
Created On: 08/31/2020 01:39 PM
Status: Post and Reply
Linear : Threading : Single : Branch
 08/31/2020 01:39 PM
User is offline View Users Profile Print this message

Author Icon
RSI_sucks
New Member

Posts: 9
Joined: 07/31/2019

I’m trying to create a command with multiple list variables, some of which would execute an already saved command via EmulateRecognition. I wrote the following, and everything works fine except for ListVar1 (highlighted in yellow). When I initially say the command, I'm on Google Chrome, but it switches to Excel and goes back to Chrome to click on specific mouse positions. Can somebody please help me? Thank you.

 

Command Name: <From> <With Which Word> <Where> <My Actions>

 

Sub Main
AppBringUp "C:\Users\soooer\OneDrive\Documents\Contacts.xlsx"
Wait 1.5
SendKeys "^{PgUp 30}^{PgDn 12}"
Wait .5
SendKeys "^G"
Wait .4
SendKeys "e9"
Wait .4
SendKeys "{Enter}"
Wait .5
SendKeys "%{Tab}"
Wait .5
If ListVar1 = "OS" Then EmulateRecognition "Open Strip"
If ListVar1 = "Copy" Then EmulateRecognition "Copy"
If ListVar1 = "Strip" Then EmulateRecognition "Strip Name"
Wait 10
SendKeys "^C"
Wait .5
SendKeys "%{Tab}"
Wait .5
SendKeys "^V"
Wait .5
If ListVar2 = "First Name" Then SendKeys "{Down 2}{Right}"
If ListVar2 = "Last Name" Then  SendKeys "{Down 2}{Right}"
Wait .5
SendKeys "^C"
Wait .5
If ListVar3 = "Co List" Then SendKeys "^{PgUp 15}"
If ListVar3 = "CNN" Then SendKeys "^{PgUp 8}"
If ListVar3 = "MC" Then SendKeys "^{PgUp 7}"
Wait 5
If ListVar4 = "DC" Then EmulateRecognition "Double Check"
If ListVar4 = "CS" Then EmulateRecognition "CS"
End Sub

For ListVar 1, when I say “OS” I see that “Open Strip” gets recognized, but it doesn’t perform the command (which by the way is saved as Global). It’s supposed to do some clicks on specific mouse positions on Google Chrome:

 

Command Name: Open Strip

 

SetMousePosition 1,381,223
Wait .5
ButtonClick 1,1
Wait .5
SetMousePosition 1,160,473
Wait .5
ButtonClick 1,3

The commands for ListVar4 work just fine… the Double Check command (also saved in Global) looks like this:

 

Command Name: Double Check

 

SendKeys "^F"
Wait .5
SendKeys "^V"
SendKeys "{Enter}"


 08/31/2020 02:09 PM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2077
Joined: 03/21/2007

Does a standalone script with "EmulateRecognition "Open Strip"" work as expected when you trigger it? You say the words are recognized, but are they recognized as a command name (blue line around results box if it shows preliminary results, or an "x" in the Recognition History next to the recognition)?

One thing you may be faced with is that the emulaterecognitions might get queued up to execute serially only after each prior recognition action completes. In that case, make the recognition the last step in your macro, but have the recognized command then emulaterecognition the next part of the macro you need.


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




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.

 08/31/2020 05:12 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 915
Joined: 04/03/2009

Another possible solution would be to create "Open Strip" as a separate function stored in a text file. As an example, create a text file: "GlobalFunctions.txt" and put it somewhere convenient (personally I put it in the same folder with my KnowBrainer commands file but it doesn't matter where just as long as Dragon/KnowBrainer has read permission). It's going to look something like this:

' GlobalFunctions.txt - this is a comment and unnecessary,

       'It tells the file's name

' efm5 30 November 2016 - this is a comment and unnecessary,

       'It tells who created the file and when


'OpenStrip () - this is a comment and unnecessary,

       'It would normally be a list of all the functions in the file

'ParseComplexList (ByVal pListItem As String) As String

       'I added a second function just FYI


Function OpenStrip ()

   SetMousePosition 1,381,223

   Wait .5

   ButtonClick 1,1

   Wait .5

   SetMousePosition 1,160,473

   Wait .5

   ButtonClick 1,3

End Function


Function ParseComplexList (ByVal pListItem As String) As String

   Dim returnValue As String

   If InStr(pListItem, "\") Then

      returnValue = Left(pListItem, InStr(pListItem, "\") - 1)

   Else

      returnValue = pListItem

   End If

   ParseComplexList = returnValue

End Function

______________________

Use that function in one of your other commands you would do something like:backspace…

Function name: Explore <MusicFolders> <ica_complex>

Code (note the first line of the code starts out with something that looks like a comment):

'#Uses "C:\Program Files (x86)\KnowBrainer\KnowBrainer Professional 2017\GlobalFunctions.txt"


Sub Main

   Dim folder As String

   folder = ParseComplexList(ListVar2)

   ' Just as an example…

   OpenStrip' executes the code you have written

End Sub

 



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

-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

Statistics
31795 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 563 guests browsing this forum, which makes a total of 564 users using this forum.

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