Escaping characters for a Command Line Statement Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
picklepissjar
Posts: 20
Joined: 22 Oct 2022, 10:03

Escaping characters for a Command Line Statement

Post by picklepissjar » 09 Nov 2022, 11:54

Hi,
I'm probably getting the quotation marks wrong, but I can't figure out how to get it right.
I'm trying to prevent "clipboard" from being understood as A_Clipboard and also have quotations around the 4 numbers stored in variables. Which is proving to be quite a headache
This is what I have so far.

Code: Select all

x1 := 0, x2 :=100, y1 := 0, y2 := 100
cmd := """D:\Program Files 2\Capture2Text (OCR)\Capture2Text_CLI.exe""" "--clipboard -s """%x1% %y1% %x2% %y2% ""
RunWait, %cmd%
MsgBox % Clipboard "`n\\\\\\\\\\\\\\\`n" cmd
A correct statement in the Command prompt looks like one of the 2 below:
"D:\Program Files 2\Capture2Text (OCR)\Capture2Text_CLI.exe" --clipboard -s "0 0 100 100"
"D:\Program Files 2\Capture2Text (OCR)\Capture2Text_CLI.exe" "--clipboard" -s "0 0 100 100"

User avatar
Smile_
Posts: 859
Joined: 03 May 2020, 00:51

Re: Escaping characters for a Command Line Statement  Topic is solved

Post by Smile_ » 09 Nov 2022, 12:15

Try:

Code: Select all

cmd := """D:\Program Files 2\Capture2Text (OCR)\Capture2Text_CLI.exe"" --clipboard -s """ x1 " " y1 " " x2 " " y2 """"

picklepissjar
Posts: 20
Joined: 22 Oct 2022, 10:03

Re: Escaping characters for a Command Line Statement

Post by picklepissjar » 09 Nov 2022, 12:21

I added 2 escaped quotation marks and it worked perfectly! :dance:

Code: Select all

cmd := """D:\Program Files 2\Capture2Text (OCR)\Capture2Text_CLI.exe"" --clipboard -s " x1 " " y1 " " x2 " " y2
Final:

Code: Select all

cmd := """D:\Program Files 2\Capture2Text (OCR)\Capture2Text_CLI.exe"" --clipboard -s "" " x1 " " y1 " " x2 " " y2 ""
TYVM :D

garry
Posts: 3795
Joined: 22 Dec 2013, 12:50

Re: Escaping characters for a Command Line Statement

Post by garry » 09 Nov 2022, 13:43

see ahk-script examples also in google search > capture2text_cli site:autohotkey.com

Post Reply

Return to “Ask for Help (v1)”