Generate the Log information in .txt file when executing .AHK Script in Auto Hot Key

。_饼干妹妹 提交于 2020-01-07 04:35:06

问题


  1. 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.

  2. 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!