在自动热键中执行.AHK脚本时,在.txt文件中生成日志信息 [英] Generate the Log information in .txt file when executing .AHK Script in Auto Hot Key

查看:409
本文介绍了在自动热键中执行.AHK脚本时,在.txt文件中生成日志信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 我在执行.AHK文件时需要在单独的.txt文件中显示执行过程,因此就像执行脚本时发生任何错误一样,它应该在.txt文件中显示.

  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.

在运行脚本时,脚本应附加到新的.txt文件中,并且在该新的.txt文件中需要显示日志信息(执行过程).

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

这是我的下面的代码:

#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

推荐答案

此AutoHotkey脚本将记录每个脚本的成功/失败 该过程的步骤.

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

这篇关于在自动热键中执行.AHK脚本时,在.txt文件中生成日志信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆