Autohotkey:如何在 ahk 脚本中的 run 语句上使用嵌套双引号

问题描述 投票:0回答:2

我有一个问题。我正在运行 autohotkey 版本 v1.1.13.00。 我的脚本工作正常,除非我需要在其他双引号内运行带有双引号的内容。 我检查了 AHKscript 论坛,我看到的只是您只使用它们而不使用任何转义字符,但这对我不起作用。

我的热键组合没有被任何其他脚本、程序或任何其他内容劫持。我可以给它分配另一个功能并且它可以工作。

到目前为止我已经尝试过:

^+h::
run "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --window-size=300,300 --window-position=200,100 --app=http://hangouts.google.com/"
return

由于明显的原因(运行字符串中的空格)而不起作用

^+h::
run ""C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --window-size=300,300 --window-position=200,100 --app="http://hangouts.google.com/""
return

^+h::
run "`"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe`" --window-size=300,300 --window-position=200,100 --app=`"http://hangouts.google.com/`""
return

上面的两次迭代,打开autohotkey所在的文件夹并停止。

^+h::
run "{"}C:\Program Files (x86)\Google\Chrome\Application\chrome.exe{"} --window-size=300,300 --window-position=200,100 --app=http://hangouts.google.com/"
return

不喜欢大括号的错误

哦,顺便说一句,

run http://hangouts.google.com
后跟
winmove, x, y, width, height
将不起作用,因为我的默认浏览器不是chrome而是IE,而且我没有在IE上登录我的帐户。 (如果愿意,可以将工作和个人行为分开)

此时,我不知道该去哪里。如果有人知道如何继续,我洗耳恭听。

autohotkey
2个回答
3
投票

强制表达式并使用双引号来转义双引号:

""

run, % """C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"" --window-size=300,300 --window-position=200,100 --app=http://hangouts.google.com/"

0
投票

从 AHK v2.0 (12/2022) 开始,您可以使用

`
反引号来转义双引号:

Run "wordpad.exe `"C:\Program Files\AutoHotkey\license.txt`""

或将您的命令包装在

'
单引号中:

Run 'wordpad.exe "C:\Program Files\AutoHotkey\license.txt"'

参见:https://www.autohotkey.com/docs/v2/howto/RunPrograms.htm#Quote_Marks_and_Spaces

© www.soinside.com 2019 - 2024. All rights reserved.