我是Autoit的新手,并试图这样做:
Local $stest = "C:\Program Files (x86)\test\test.exe";
Local $sPath;
runS($stest);
Func runS(String $sPath) {
this.$sPath = $sPath;
If FileExists($stest) {
Run($stest , "", @SW_SHOWMAXIMIZED)
}
}
并收到此错误:
(6):==>格式不正确的变量或宏。:
我只是想把一个参数写成函数中的路径......
答案 0 :(得分:0)
以下是您的代码应该是什么样的:
;$g_sTest is global variable because it is being declared outside of a function.
Global $g_sTest = "C:\Program Files (x86)\test\test.exe"
runS($stest)
;$sPath will be a local variable because it is being declared inside of the fuction.
Func runS($sPath)
If FileExists($sPath) Then
Run($sPath, "", @SW_SHOWMAXIMIZED)
EndIf
EndFunc