例如,我想将任何 ahk 命令文本(例如“Click, 50, 50”或“MsgBox test”)传递到函数中并执行该命令。可以吗?
这可能对你有帮助。
#SingleInstance, Force
var := "example"
new_instance( "msgbox " var " 1`nexitapp" )
new_instance( "msgbox % ""another " var " 2"""
. "`nexitapp" )
new_instance( "msgbox another example 3`nexitapp" )
new_instance( "msgbox passing var`n"
. "var := """ var " 4""`n"
. "Msgbox % var `n"
. "exitapp" )
ExitApp, 0
new_instance( Script ) {
OutputDebug, % script ; for debug purpose
shell := ComObjCreate( "WScript.Shell" )
exec := shell.Exec( A_AhkPath " /ErrorStdOut *")
exec.StdIn.Write( script )
exec.StdIn.Close()
}