我有一个这样的功能:
Seep(toSend){
Send, %toSend%
Sleep, 1000
}
我这样使用它:
Seep("Typing a new line{Enter}")
我想将 Windows 环境变量的值发送给该函数以便打印出来,如下所示:
Seep("This is the path: " %PATH% " ok now what?{Enter}")
我尝试了很多方法,但都无济于事。通常,它只是不打印 PATH 中的任何内容,如下所示:
This is the path: ok now what?
这是我尝试过的:
Seep("This is the path: %PATH% ok now what?{Enter}") ; prints literally %PATH%
我首先尝试将其放入变量中:
pathv:=PATH ; also tried %PATH%, $PATH with the same outcome
Seep("This is the path: " pathv " ok now what?{Enter}") ; prints an empty string
我甚至把它放在双变量中:
pathv:=PATH
toPrint:="This is the path: " pathv " ok now what?{Enter}"
再次,一个空字符串。
答案1
如果您有#NoEnv
[1] 指令,则脚本中的环境变量不可用。EnvGet
在这种情况下,您可以使用 [2] 命令,例如:
EnvGet, vPath, Path
MsgBox % vPath
Seep("This is the path: " vPath " ok now what?{Enter}")
[1]https://www.autohotkey.com/docs/commands/_NoEnv.htm
[2]https://www.autohotkey.com/docs/commands/EnvGet.htm