我的要求是当我执行我的脚本时,我希望将日志信息附加到单独的txt文件中,但问题是当我将日志信息附加到附加文件循环多次发生而不是仅附加日志信息一次。以下是我的AHK脚本代码
#SingleInstance force
#Persistent
Run, C:\Pangaea\Software\SVN\TortoiseSVN-1.8.8.25755-x64-svn-1.8.10.msi
SetTimer, Check, 1000
return
Check:
SetControlDelay -1
IfWinActive, ("ahk_class MsiDialogCloseClasses,&Next")
ControlClick, &Next, ahk_class MsiDialogCloseClass
FileAppend,
(
Hello World
), C:\Users\sk185462\Desktop\SVN TASK\New folder\My File.txt
IfWinActive, ahk_class MsiDialogCloseClass,Remove Installation
ControlClick, Remove Installation, ahk_class MsiDialogCloseClass
IfWinActive, ahk_class MsiDialogCloseClass, &Remove
ControlClick, &Remove,ahk_class MsiDialogCloseClass
IfWinActive, ahk_class MsiDialogCloseClass, &Finish
ControlClick, &Finish,ahk_class MsiDialogCloseClass
IfWinNotExist, ahk_class MsiDialogCloseClass
ExitApp
这是我的附加文本文件:
Hello WorldHello WorldHello WorldHello WorldHello WorldHello WorldHello WorldHello World
循环发生多次而不是只追加一次但在文件附加中我只给出了单个文本“Hello World”
答案 0 :(得分:0)
始终使用适当的缩进:
IfWinActive, ("ahk_class MsiDialogCloseClasses,&Next")
ControlClick, &Next, ahk_class MsiDialogCloseClass
FileAppend,
(
Hello World
), C:\Users\sk185462\Desktop\SVN TASK\New folder\My File.txt
IfWinActive, ahk_class MsiDialogCloseClass,Remove Installation
ControlClick, Remove Installation, ahk_class MsiDialogCloseClass
IfWinActive, ahk_class MsiDialogCloseClass, &Remove
ControlClick, &Remove,ahk_class MsiDialogCloseClass
等。现在,更容易理解为什么FileAppend
被多次调用:它不是上述if语句的一部分。
澄清:if
- 语句(if()
,ifWinActive
,...)仅考虑下一步。如果要根据if
创建多个语句,请使用大括号:
IfWinActive, ("ahk_class MsiDialogCloseClasses,&Next")
{
FileAppend,
(
Hello World
), C:\Users\sk185462\Desktop\SVN TASK\New folder\My File.txt
ControlClick, &Next, ahk_class MsiDialogCloseClass
}