KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: Escaping quotation marks in strings (e.g. for shellexecute instructions)
Topic Summary: how can I put quotation marks in a string without it being treated as the end of the string?
Created On: 05/04/2020 04:45 PM
Status: Post and Reply
Linear : Threading : Single : Branch
 Escaping quotation marks in strings (e.g. for shellexecute instructions)   - Twisted_Code - 05/04/2020 04:45 PM  
 Escaping quotation marks in strings (e.g. for shellexecute instructions)   - R. Wilke - 05/04/2020 05:09 PM  
 Escaping quotation marks in strings (e.g. for shellexecute instructions)   - Lunis Orcutt - 05/04/2020 06:42 PM  
 Escaping quotation marks in strings (e.g. for shellexecute instructions)   - Twisted_Code - 05/05/2020 02:12 PM  
 Escaping quotation marks in strings (e.g. for shellexecute instructions)   - PG LTU - 05/05/2020 03:02 PM  
 Escaping quotation marks in strings (e.g. for shellexecute instructions)   - Twisted_Code - 07/21/2020 02:35 PM  
 Escaping quotation marks in strings (e.g. for shellexecute instructions)   - PG LTU - 07/22/2020 09:49 AM  
 Escaping quotation marks in strings (e.g. for shellexecute instructions)   - Twisted_Code - 07/23/2020 11:45 AM  
 Escaping quotation marks in strings (e.g. for shellexecute instructions)   - Twisted_Code - 07/23/2020 03:00 PM  
 Escaping quotation marks in strings (e.g. for shellexecute instructions)   - Mav - 07/24/2020 03:48 AM  
 Escaping quotation marks in strings (e.g. for shellexecute instructions)   - Twisted_Code - 07/29/2020 04:39 PM  
 Escaping quotation marks in strings (e.g. for shellexecute instructions)   - Lunis Orcutt - 07/30/2020 01:40 AM  
 Escaping quotation marks in strings (e.g. for shellexecute instructions)   - Twisted_Code - 07/31/2020 09:17 AM  
 Escaping quotation marks in strings (e.g. for shellexecute instructions)   - Lunis Orcutt - 07/31/2020 12:30 PM  
 Escaping quotation marks in strings (e.g. for shellexecute instructions)   - Twisted_Code - 08/07/2020 01:27 PM  
 Escaping quotation marks in strings (e.g. for shellexecute instructions)   - Twisted_Code - 08/12/2020 10:37 AM  
 Escaping quotation marks in strings (e.g. for shellexecute instructions)   - Edgar - 08/12/2020 11:58 AM  
 Escaping quotation marks in strings (e.g. for shellexecute instructions)   - Twisted_Code - 07/26/2020 04:37 PM  
Keyword
 05/04/2020 04:45 PM
User is offline View Users Profile Print this message

Author Icon
Twisted_Code
Senior Member

Posts: 99
Joined: 04/01/2015

how can I put double quotation marks in a string without it being treated as the end of the string? I tried a few ways I know from other scripting language syntaxes, such as using single quotes on the outside or putting a \ before the double quotes inside the string, but neither of those work. I also tried using single quotes inside the string, but the command I'm trying to use, taskkill, doesn't treat those the same way, and fails.

I tried to figure it out from the scripting help in the application's help file, but the help file's index is not very, well, helpful and the few articles I found in the document that seemed vaguely relevant were VERY short. I don't suppose you have a more organized documentation resource somewhere?



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

“Talk is cheap. Show me the code.” ~ Linus Torvalds


 


"It is good to have empathy.  But it is not essential.  What is essential is that one displays empathy, however one musters it." ~ ax (in a post on this very forums)


 


more favorite quotes

 05/04/2020 05:09 PM
User is offline View Users Profile Print this message

Author Icon
R. Wilke
Top-Tier Member

Posts: 8116
Joined: 03/04/2007

such as using single quotes on the outside


Have you tried using double quotes on the outside?

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


The New Game in Town: DragonConnect

 05/04/2020 06:42 PM
User is offline View Users Profile Print this message

Author Icon
Lunis Orcutt
Top-Tier Member

Posts: 40984
Joined: 10/01/2006

This is a bit of an odd duck but we suspect the following KnowBrainer and Dragon example has what you're looking for:


Example: SendKeys "{""} Stump the Trump{""}" = “Stump the Trump”

PS: We we appreciate Dragon's  command which applies formatting to random text, in Dragon friendly applications, without having to select it. Of course this just made us want more and with some help from Lindsay Adams, we just released a few new formatting (for lack of a better term) commands including  which uses the previous example and released on May 3, 2020 (now ancient history)



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

Change "No" to "Know" w/KnowBrainer 2022
Trial Downloads
Dragon/Sales@KnowBrainer.com 
(615) 884-4558 ex 1



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

Author Icon
Twisted_Code
Senior Member

Posts: 99
Joined: 04/01/2015

Originally posted by: R. Wilke
such as using single quotes on the outside
Have you tried using double quotes on the outside?

yeah I tried that too, but it was treated like a syntax error (2 strings for a function that only accept one)

Originally posted by: Lunis Orcutt This is a bit of an odd duck but we suspect the following KnowBrainer and Dragon example has what you're looking for:


Example: SendKeys "{""} Stump the Trump{""}" = “Stump the Trump” PS: We we appreciate Dragon's  command which applies formatting to random text, in Dragon friendly applications, without having to select it. Of course this just made us want more and with some help from Lindsay Adams, we just released a few new formatting (for lack of a better term) commands including  which uses the previous example and released on May 3, 2020 (now ancient history)


 

 

that doesn't seem to have worked. I just tried

ShellExecute "taskkill /IM {""}7+ Taskbar Tweaker.exe{""} /F"

but the command still failed to terminate the intended process. Wish I knew what CMD ends up seeing but the window is only visible for a few frames...

my goal with this command, by the way, is to kill a few programs that I suspect might be the cause of the NT user interface partially-freezing, as well as restarting explorer.exe. Don't know if closing said applications will actually help with my problem, but it's always helpful to know what the user (me) is trying to do, right?



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

“Talk is cheap. Show me the code.” ~ Linus Torvalds


 


"It is good to have empathy.  But it is not essential.  What is essential is that one displays empathy, however one musters it." ~ ax (in a post on this very forums)


 


more favorite quotes

 05/05/2020 03:02 PM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2274
Joined: 03/21/2007

Just use two quotes ("") inside the surrounding quotes. Some good examples here: bit.ly\pgEmulate

For example, ShellExecute Environ("USERPROFILE") & "\..\pgEmulate.vbs ""list all windows""", 6 is equivalent to pgEmulate "list all windows" and so passes list all windows as a single (first) parameter into pgEmulate.

And commonly, MsgBox """" & result & """" which puts the result in quotes when displayed by the MsgBox. It can be read as the message box first displaying a single " (the """" - see, the quoted string is "" which becomes ") followed by result, followed by another " (from the """" part).

Hth,



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




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.



 07/21/2020 02:35 PM
User is offline View Users Profile Print this message

Author Icon
Twisted_Code
Senior Member

Posts: 99
Joined: 04/01/2015

still having trouble with this. I tried two double quotes as PG just suggested for another command I just tried to make, but got "The system could not find the file specified", even though I gave it the exact path
ShellExecute """D:\OneDrive\Documents\AutoHotkey_scripts\KnowBrainer-invoked\Hold or Release Keys.ahk"" HoldLeft"
I don't know why it wouldn't be able to find the file, unless the above was interpreted as "D:\OneDrive\Documents\AutoHotkey_scripts\KnowBrainer-invoked\Hold", which makes me think I'm still somehow having quotation mark problems
in fact, just now, I tried renaming the target file to "D:\OneDrive\Documents\AutoHotkey_scripts\KnowBrainer-invoked\HoldorReleaseKeys.ahk" and using
ShellExecute "D:\OneDrive\Documents\AutoHotkey_scripts\KnowBrainer-invoked\HoldorReleaseKeys.ahk HoldLeft"
and it works... but that's missing the point. Any idea what's going on here?

TBH, issues like this are exactly why I'm trying to call an AutoHotkey script (.AHK) to finish the job of the original command. To me, WinWrap has always been temperamental at best. I don't know why but I just seem to have better luck with, well, any other scripting language...

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

“Talk is cheap. Show me the code.” ~ Linus Torvalds


 


"It is good to have empathy.  But it is not essential.  What is essential is that one displays empathy, however one musters it." ~ ax (in a post on this very forums)


 


more favorite quotes

 07/22/2020 09:49 AM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2274
Joined: 03/21/2007

It should work just sending the whole thing wrapped in quotes:

shellexecute "D:\OneDrive\Documents\AutoHotkey_scripts\KnowBrainer-invoked\Hold or Release Keys.ahk HoldLeft"

because "HoldLeft" is the single first param

If the param had a space in it, "Hold Left" it would be treated as two parameter unless it was quoted as passed in, such as:

shellexecute "D:\OneDrive\Documents\AutoHotkey_scripts\KnowBrainer-invoked\Hold or Release Keys.ahk ""Hold Left"""

 

So try:

 

ShellExecute "taskkill /IM ""7+ Taskbar Tweaker.exe"" /F"

 

and let us know . . .

 

Hth,



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




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.



 07/23/2020 11:45 AM
User is offline View Users Profile Print this message

Author Icon
Twisted_Code
Senior Member

Posts: 99
Joined: 04/01/2015

okay the taskkill worked, so maybe I had some sort of almost-static semantic error. Looking back on what I claim to that I tried though, I'm really not sure what? do you see any issues with the "taskkill [blah blah blah]" string (with or without the curly brackets) I provided a few months ago?

 

Let me also try the line you suggested for the other shell command (though I'll have to copy/rename the script back to what it was with the space)



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

“Talk is cheap. Show me the code.” ~ Linus Torvalds


 


"It is good to have empathy.  But it is not essential.  What is essential is that one displays empathy, however one musters it." ~ ax (in a post on this very forums)


 


more favorite quotes



 07/23/2020 03:00 PM
User is offline View Users Profile Print this message

Author Icon
Twisted_Code
Senior Member

Posts: 99
Joined: 04/01/2015

Originally posted by: Twisted_Code okay the taskkill worked, so maybe I had some sort of almost-static semantic error. Looking back on what I claim to that I tried though, I'm really not sure what? do you see any issues with the "taskkill [blah blah blah]" string (with or without the curly brackets) I provided a few months ago?

 

 

 

Let me also try the line you suggested for the other shell command (though I'll have to copy/rename the script back to what it was with the space)

 

As expected, it says it can't find the file specified. I think the file path needs to be wrapped in quotes so that CMD sees it as a single parameter, which is what I was trying to do when I tried """D:\OneDrive\Documents\AutoHotkey_scripts\KnowBrainer-invoked\Hold or Release Keys.ahk"" HoldLeft", but for some reason that yields "the system cannot find the file specified" and I don't know why. I tried the exact same (or at least, the expected. In other words, single quotes: "D:\OneDrive\Documents\AutoHotkey_scripts\KnowBrainer-invoked\Hold or Release Keys.ahk" HoldLeft) command string in  RUN & CMD directly, and in both cases it finds the file just fine, so something is somehow wrong with my shellexecute instruction.



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

“Talk is cheap. Show me the code.” ~ Linus Torvalds


 


"It is good to have empathy.  But it is not essential.  What is essential is that one displays empathy, however one musters it." ~ ax (in a post on this very forums)


 


more favorite quotes

 07/24/2020 03:48 AM
User is offline View Users Profile Print this message

Author Icon
Mav
Top-Tier Member

Posts: 741
Joined: 10/02/2008

Hi!

I guess ShellExecute has a problem with not being given an executable as commandline.

 

Please try something like this (sorry, don't know the exact paths, but I hope you get the idea):

 

ShellExecute """C:\Program Files (x86)\AutoHotKey\ahk.exe"" ""D:\path to my file with blanks\script.ahk"" KeyDown"

 

hth,

mav

 07/29/2020 04:39 PM
User is offline View Users Profile Print this message

Author Icon
Twisted_Code
Senior Member

Posts: 99
Joined: 04/01/2015

Originally posted by: Mav Hi!

 

I guess ShellExecute has a problem with not being given an executable as commandline.

 

 

 

Please try something like this (sorry, don't know the exact paths, but I hope you get the idea):

 

 

 

ShellExecute """C:\Program Files (x86)\AutoHotKey\ahk.exe"" ""D:\path to my file with blanks\script.ahk"" KeyDown"

 

 

 

hth,

 

mav

 

that's possible. I'll give it a try. I didn't think about that!
Will let you know if it works out


edit:

Didn't work.

Maybe this should've been asked sooner, but what version of KB is everyone running? I'm beginning to suspect it's a version inconsistency or something. I'm running KB Pro 2017 on my desktop and I think 2016 on my laptop (By the way, what's the easiest way to update my laptop without risking my custom commands?)



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

“Talk is cheap. Show me the code.” ~ Linus Torvalds


 


"It is good to have empathy.  But it is not essential.  What is essential is that one displays empathy, however one musters it." ~ ax (in a post on this very forums)


 


more favorite quotes



 07/30/2020 01:40 AM
User is offline View Users Profile Print this message

Author Icon
Lunis Orcutt
Top-Tier Member

Posts: 40984
Joined: 10/01/2006

Exporting and importing your personal commands are outlined in KnowBrainer 2017 but KnowBrainer 2016 is 6 or 7 years old and we don't remember. We are definitely not going to install it to find out. If the KnowBrainer 2017 instructions don't work on KnowBrainer 2016, you will have to manually copy your commands, one at a time, to a document. At least you'll never have to do it again



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

Change "No" to "Know" w/KnowBrainer 2022
Trial Downloads
Dragon/Sales@KnowBrainer.com 
(615) 884-4558 ex 1



 07/31/2020 09:17 AM
User is offline View Users Profile Print this message

Author Icon
Twisted_Code
Senior Member

Posts: 99
Joined: 04/01/2015

Thinking about it a bit more, I don't think it will be an issue anyway. I generally use the commands I have on my desktop (which is running 2017) as a "master copy" of sorts, so I'll just copy the whole command file from that.

It still leaves the question though, as to why what you're all telling me isn't working on KB 2017 on my desktop. That is the latest edition isn't it?

Unless... could there have been updates to 2017 that I'm missing? I don't remember an auto updater ever popping up and I don't often think to install updates manually, so it's worth a try at least...



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

“Talk is cheap. Show me the code.” ~ Linus Torvalds


 


"It is good to have empathy.  But it is not essential.  What is essential is that one displays empathy, however one musters it." ~ ax (in a post on this very forums)


 


more favorite quotes



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

Author Icon
Lunis Orcutt
Top-Tier Member

Posts: 40984
Joined: 10/01/2006

KnowBrainer 2017 was released on September 1, 2016 and is now about as up-to-date as bellbottoms. Fortunately, Rüdiger Wilke's KBCommandsUpdater will always keep you up-to-date. You can run it every few months, few weeks, few minutes or even few seconds. KnowBrainer literally gets updated every few days. We will soon be releasing VB II (VerbalBasic II) and will be working 7 days a week from 9 AM to midnight, when time permits, until this project is completed. We should have done this months ago. Manuals will take a little longer and while we are now including Dragon support, it will be far more limited 



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

Change "No" to "Know" w/KnowBrainer 2022
Trial Downloads
Dragon/Sales@KnowBrainer.com 
(615) 884-4558 ex 1

 08/07/2020 01:27 PM
User is offline View Users Profile Print this message

Author Icon
Twisted_Code
Senior Member

Posts: 99
Joined: 04/01/2015

I'm talking about the syntax/engine though, not the commands. I'm still trying to figure out why the syntax everyone else is giving me in this thread isn't doing what I expect when I try it on my copy of the application.



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

“Talk is cheap. Show me the code.” ~ Linus Torvalds


 


"It is good to have empathy.  But it is not essential.  What is essential is that one displays empathy, however one musters it." ~ ax (in a post on this very forums)


 


more favorite quotes

 08/12/2020 10:37 AM
User is offline View Users Profile Print this message

Author Icon
Twisted_Code
Senior Member

Posts: 99
Joined: 04/01/2015

Seriously guys, I'm out of hypotheses here. Why is this syntax so janky? I'm doing the exact same thing in two different commands and it's acting differently, and I legitimately cannot figure out for the life of me why.

For now, I've settled for the workaround of "just don't use spaces in paths" so I don't have to worry about quotation marks acting weird, but if I ever have to work with a path for which I can't do that (for instance, "C:\Windows\Program Files\"), I'm probably going to resurrect this thread again if no one can answer me what the hell is going on. Either that or I'll just create a new thread since this one is starting to get kind of confusing with all the different solutions being passed around, none of which seem to work (or at least not consistently...)

Thanks for all the effort at helping, but I'm still where I started... :-/



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

“Talk is cheap. Show me the code.” ~ Linus Torvalds


 


"It is good to have empathy.  But it is not essential.  What is essential is that one displays empathy, however one musters it." ~ ax (in a post on this very forums)


 


more favorite quotes



 08/12/2020 11:58 AM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1416
Joined: 04/03/2009

Originally posted by: Twisted_Code  Why is this syntax so janky?

I too struggle with this and have also developed the "no spaces in folder/file names" habit (but this can't be avoided in "Program Files" and "Program Files (x86)" unless you create a shortcut to said folder/file which does not have spaces).

Another possible solution would be to use an outside scripting engine (AutoIT3 etc.) which might have a less inscrutable syntax.



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

-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 & Shokz OpenComm UC version 1 wireless headset, 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

 07/26/2020 04:37 PM
User is offline View Users Profile Print this message

Author Icon
Twisted_Code
Senior Member

Posts: 99
Joined: 04/01/2015

that's possible. I'll give it a try. I didn't think about that!
Will let you know if it works out

 

edit: follow-up above (the post on 07/29/2020 04:39 PM... Why does this forum handle topic replies so weirdly? I neglected to specify who I was replying to and now I can't move this). It didn't work.

 



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

“Talk is cheap. Show me the code.” ~ Linus Torvalds


 


"It is good to have empathy.  But it is not essential.  What is essential is that one displays empathy, however one musters it." ~ ax (in a post on this very forums)


 


more favorite quotes



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

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