KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: Outputting parentheses in SendKeys
Topic Summary:
Created On: 12/28/2020 01:11 PM
Status: Post and Reply
Linear : Threading : Single : Branch
 Outputting parentheses in SendKeys   - Alan Cantor - 12/28/2020 01:11 PM  
 Outputting parentheses in SendKeys   - PG LTU - 12/28/2020 01:23 PM  
 Outputting parentheses in SendKeys   - Edgar - 12/28/2020 04:46 PM  
 Outputting parentheses in SendKeys   - Alan Cantor - 12/28/2020 08:35 PM  
 Outputting parentheses in SendKeys   - Lunis Orcutt - 12/28/2020 09:36 PM  
 Outputting parentheses in SendKeys   - Edgar - 12/29/2020 11:43 AM  
 Outputting parentheses in SendKeys   - jmcvay - 12/31/2020 12:41 PM  
 Outputting parentheses in SendKeys   - Lunis Orcutt - 12/31/2020 07:24 PM  
 Outputting parentheses in SendKeys   - Edgar - 01/01/2021 11:54 AM  
 Outputting parentheses in SendKeys   - jmcvay - 01/02/2021 03:36 PM  
 Outputting parentheses in SendKeys   - Edgar - 01/03/2021 11:02 AM  
 Outputting parentheses in SendKeys   - Edgar - 01/03/2021 11:16 AM  
 Outputting parentheses in SendKeys   - PG LTU - 12/31/2020 07:25 PM  
Keyword
 12/28/2020 01:11 PM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 4032
Joined: 12/08/2007

I'm writing a command that outputs several strings. Some strings are wrapped in parentheses:

Hello (World)

The Advanced Scripting code is this:

SendKeys "Hello " & "(" & "World" & ")"

But when I run the command, the parentheses are missing.

So I tried this instead:

SendKeys "Hello " & Chr$(40) & "World" & Chr$(41)

The result is the same: Hello World vs. Hello (World).

The command works if I substitute SendSystemKeys or SendDragonKeys for SendKeys. But shouldn't it work regardless?

I'm using DPI 15.61.

 12/28/2020 01:23 PM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2136
Joined: 03/21/2007

So strange. Ha ha ha. Escape them.

SendKeys "Hello " & "{(}" & "World" & "{)}"

or simply: SendKeys "Hello {(}World{)}"

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




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.

 12/28/2020 04:46 PM
User is online View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1115
Joined: 04/03/2009

Hi Alan!

This question comes up so often (in different flavors) that I decided to dedicate a post to it:
https://www.knowbrainer.com/forums/forum/messageview.cfm?catid=12&threadid=35260&enterthread=y



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

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


Alan Cantor
Top-Tier Member

Posts: 4032
Joined: 12/08/2007

Hi Philip and Edgar,

Thank you!!!
 12/28/2020 09:36 PM
User is offline View Users Profile Print this message

Author Icon
Lunis Orcutt
Top-Tier Member

Posts: 38677
Joined: 10/01/2006

We are not certain if the following approach will work but KnowBrainer 2017 includes a Paren <dictation> command which will allow you to say Paren <anything you want>. If this sounds good and you are not using KnowBrainer, consider naming your command Paren <dictation>. The script is:

 

Sub Main
out = " {(}" + ListVar1 + ")"
SendKeys out
End Sub


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

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

 12/29/2020 11:43 AM
User is online View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1115
Joined: 04/03/2009

Originally posted by: Lunis Orcutt   

 

Sub Main
out = " {(}" + ListVar1 + ")"
SendKeys out
End Sub

As I pointed out before, the variable "out" is unnecessary and it is probably a good habit to use the optional Wait parameter. Additionally, there is a serious problem with this command… What happens if ListVar1 contains one of the characters which need to be escaped (e.g. "You must escape the left square bracket.")? Usually, Dragon® will convert this into "You must escape the [." And this command will throw an error.

My version of this command looks like:

   Dim holdString As String

   holdString = ListVar1

   holdString = Replace (holdString, "(", "{(}")

   holdString = Replace (holdString, "open paren", "{(}")

   holdString = Replace (holdString, "left paren", "{(}")

   holdString = Replace (holdString, "{", "{{}")

   holdString = Replace (holdString, "open curly brace", "{{}")

   holdString = Replace (holdString, "left curly brace", "{{}")

   holdString = Replace (holdString, "[", "{[}")

   holdString = Replace (holdString, "open square bracket", "{[}")

   holdString = Replace (holdString, "left square bracket", "{[}")

   holdString = Replace (holdString, "<", "{<}")

   holdString = Replace (holdString, "open angle bracket", "{<}")

   holdString = Replace (holdString, "left angle bracket", "{<}")

   holdString = Replace (holdString, "\", "{\}")

   holdString = Replace (holdString, "back /", "{\}")

   holdString = Replace (holdString, "back slash", "{\}")

   SendKeys holdString, 1

 

   Clipboard (holdString)' optional

This code is public domain and open source, I encourage Lunis to freely use it.



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

-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/31/2020 12:41 PM
User is offline View Users Profile Print this message

Author Icon
jmcvay
Senior Member

Posts: 142
Joined: 01/02/2015

Edgar, I tried both Lewis' version and yours. Lunis' version does indeed throw an error. Yours didn't enclose the dictated text in parentheses and seemed to type the dictated text one letter at a time, rather than entering it as a chunk. 



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

James McVay



 12/31/2020 07:24 PM
User is offline View Users Profile Print this message

Author Icon
Lunis Orcutt
Top-Tier Member

Posts: 38677
Joined: 10/01/2006

We use the existing KnowBrainer Paren <dictation> and Angle <dictation> commands all the time without issue



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

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



 01/01/2021 11:54 AM
User is online View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1115
Joined: 04/03/2009

Originally posted by: jmcvay Edgar, I tried both […] yours didn't enclose the dictated text in parentheses and seemed to type the dictated text one letter at a time, rather than entering it as a chunk.

We will need to see your code.



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

-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

 01/02/2021 03:36 PM
User is offline View Users Profile Print this message

Author Icon
jmcvay
Senior Member

Posts: 142
Joined: 01/02/2015

Originally posted by: Edgar
Originally posted by: jmcvay Edgar, I tried both […] yours didn't enclose the dictated text in parentheses and seemed to type the dictated text one letter at a time, rather than entering it as a chunk.

 

We will need to see your code.

 

I just copied and pasted your code. But… Maybe you omitted something that should have been obvious to me and wasn't.



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

James McVay

 01/03/2021 11:02 AM
User is online View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1115
Joined: 04/03/2009

Originally posted by: jmcvay I just copied and pasted your code. But… Maybe you omitted something that should have been obvious to me and wasn't.

You are right, in my version, the opening parentheses seems to be failing for some reason. Will try to figure it out and post back here…



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

-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

 01/03/2021 11:16 AM
User is online View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1115
Joined: 04/03/2009

Okay, stupid logic error - because the opening curly brace is both a legitimate printable character and also part of the escapement they need to come first in the replacement order:

Sub Main
   Dim holdString As String
   holdString = ListVar1
   holdString = Replace (holdString, "open curly brace", "{{}")
   holdString = Replace (holdString, "left curly brace", "{{}")
   holdString = Replace (holdString, "{", "{{}")
   holdString = Replace (holdString, "(", "{(}")
   holdString = Replace (holdString, "open paren", "{(}")
   holdString = Replace (holdString, "left paren", "{(}")
   holdString = Replace (holdString, "[", "{[}")
   holdString = Replace (holdString, "open square bracket", "{[}")
   holdString = Replace (holdString, "left square bracket", "{[}")
   holdString = Replace (holdString, "<", "{<}")
   holdString = Replace (holdString, "open angle bracket", "{<}")
   holdString = Replace (holdString, "left angle bracket", "{<}")
   holdString = Replace (holdString, "\", "{\}")
   holdString = Replace (holdString, "back /", "{\}")
   holdString = Replace (holdString, "back slash", "{\}")
   SendKeys holdString, 1
   Clipboard (holdString)
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

 12/31/2020 07:25 PM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2136
Joined: 03/21/2007

This takes me back. Both versions here (DAS and DVC) allow for saying "paren that" to put the parentheses around an entire selected phrase or "paren xyz" to dictate a perenthesized phrase:

https://www.knowbrainer.com/forums/forum/messageview.cfm?catid=3&threadid=19005&discTab=true&messid=109508&parentid=108946&FTVAR_FORUMVIEWTMP=Single

And those thinking ahead will recognize that a complex list for paren will let you easily adapt the code to pull off the first preceding and second terminating characters from the written form of the paren list itself (for at sign and hash sign there is no terminating character):

@\at sign
{}\braces
[]\bracket
#\hash sign
()\paren
()\parentheses
""\quote
''\single quote



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




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

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