![]() |
KnowBrainer Speech Recognition | ![]() |
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 |
|
![]() |
![]() |
- Twisted_Code | - 05/04/2020 04:45 PM |
![]() |
![]() |
- R. Wilke | - 05/04/2020 05:09 PM |
![]() |
![]() |
- Lunis Orcutt | - 05/04/2020 06:42 PM |
![]() |
![]() |
- Twisted_Code | - 05/05/2020 02:12 PM |
![]() |
![]() |
- PG LTU | - 05/05/2020 03:02 PM |
![]() |
![]() |
- Twisted_Code | - 07/21/2020 02:35 PM |
![]() |
![]() |
- PG LTU | - 07/22/2020 09:49 AM |
![]() |
![]() |
- Twisted_Code | - 07/23/2020 11:45 AM |
![]() |
![]() |
- Twisted_Code | - 07/23/2020 03:00 PM |
![]() |
![]() |
- Mav | - 07/24/2020 03:48 AM |
![]() |
![]() |
- Twisted_Code | - 07/29/2020 04:39 PM |
![]() |
![]() |
- Lunis Orcutt | - 07/30/2020 01:40 AM |
![]() |
![]() |
- Twisted_Code | - 07/31/2020 09:17 AM |
![]() |
![]() |
- Lunis Orcutt | - 07/31/2020 12:30 PM |
![]() |
![]() |
- Twisted_Code | - 08/07/2020 01:27 PM |
![]() |
![]() |
- Twisted_Code | - 08/12/2020 10:37 AM |
![]() |
![]() |
- Edgar | - 08/12/2020 11:58 AM |
![]() |
![]() |
- Twisted_Code | - 07/26/2020 04:37 PM |
![]() |
|
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)
|
|
|
|
![]() |
|
Have you tried using double quotes on the outside? ------------------------- The New Game in Town: DragonConnect |
|
|
|
![]() |
|
This is a bit of an odd duck but we suspect the following KnowBrainer and Dragon example has what you're looking for:
------------------------- Change "No" to "Know" w/KnowBrainer 2022 |
|
|
|
![]() |
|
yeah I tried that too, but it was treated like a syntax error (2 strings for a function that only accept one) 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)
|
|
|
|
![]() |
|
Just use two quotes ("") inside the surrounding quotes. Some good examples here: bit.ly\pgEmulate -------------------------
|
|
|
|
![]() |
|
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)
|
|
|
|
![]() |
|
It should work just sending the whole thing wrapped in quotes:
So try:
and let us know . . .
Hth, -------------------------
|
|
|
|
![]() |
|
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)
|
|
|
|
![]() |
|
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)
|
|
|
|
![]() |
|
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 |
|
|
|
![]() |
|
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!
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)
|
|
|
|
![]() |
|
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 |
|
|
|
![]() |
|
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. 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)
|
|
|
|
![]() |
|
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 |
|
|
|
![]() |
|
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)
|
|
|
|
![]() |
|
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)
|
|
|
|
![]() |
|
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 |
|
|
|
![]() |
|
that's possible. I'll give it a try. I didn't think about that!
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)
|
|
|
FuseTalk Standard Edition v4.0 - © 1999-2023 FuseTalk™ Inc. All rights reserved.