问题
I need to display the execution process in seperate .txt file while im executing the .AHK File , So Like If any Error occurs while executing the script it should show it in .txt File.
While running the script that script should append to new .txt File and in that new .txt file need to show log info (Execution Process).
Here is my code Below :
#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 MsiDialogCloseClass, &Next
ControlClick, &Next, ahk_class MsiDialogCloseClass
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
回答1:
This AutoHotkey script will log success/failure for each step of the process.
#SingleInstance force
#Persistent
Run, C:\Pangaea\Software\SVN\TortoiseSVN-1.8.8.25755-x64-svn-1.8.10.msi
vPath = %A_Desktop%\z log %A_Now%.txt
SetTimer, Check, 1000
return
Check:
SetControlDelay -1
vN := vRI := vR := vF := "success"
IfWinActive, ahk_class MsiDialogCloseClass, &Next
ControlClick, &Next, ahk_class MsiDialogCloseClass
else
vN := "ERROR"
IfWinActive, ahk_class MsiDialogCloseClass,Remove Installation
ControlClick, Remove Installation, ahk_class MsiDialogCloseClass
else
vRI := "ERROR"
IfWinActive, ahk_class MsiDialogCloseClass, &Remove
ControlClick, &Remove,ahk_class MsiDialogCloseClass
else
vR := "ERROR"
IfWinActive, ahk_class MsiDialogCloseClass, &Finish
ControlClick, &Finish,ahk_class MsiDialogCloseClass
else
vF := "ERROR"
vOutput := A_Now "`t" vN " " vRI " " vR " " vF "`r`n"
FileAppend, %vOutput%, *%vPath%, UTF-8
IfWinNotExist, ahk_class MsiDialogCloseClass
ExitApp
来源:https://stackoverflow.com/questions/41443610/generate-the-log-information-in-txt-file-when-executing-ahk-script-in-auto-hot