Autohotkey IniRead 将部分名称作为 AHK 中的变量传递

Autohotkey IniRead pass section name as variable in AHK

我有以下微型 .ini 文件:

["General"]
"runs"="3"

当使用此代码读取文件时,我收到一个消息框,说明 runs

的正确数量
path := A_ScriptDir "\setup.ini"
IniRead, temp, % path, "General", "runs"
MsgBox, % temp

当我尝试将 General 作为变量传递时,消息框输出“ERROR”

path := A_ScriptDir "\setup.ini"
iniSection := "General"
IniRead, temp, % path, % iniSection, "runs"
MsgBox, % temp

我尝试将变量括在 % 符号中,而不是仅仅在它们前面加上前缀,但这并没有什么不同。

感谢任何帮助!

Variable names in an expression are not enclosed in percent signs. Consequently, literal strings must be enclosed in double quotes to distinguish them from variables.

To include an actual quote-character inside a literal string, specify two consecutive quotes:

iniSection := """General"""