Code: Select all
;;;;;;Read Me;;;;;;
; To begin, run function - startLogging()
; You can optionally include parameters with the function
; startLogging(WindowX, WindowY, WindowWidth, WindowHeight, "Window Name")
; If parameters are not included, it will use the default parameters
; To write to the log run function - log("Message to write to log")
; To end logging run function - endLogging() or simply close the window
;;;;;;Read Me;;;;;;
; Testing examples:
; Control+F1 - Start a log with default settings
; Control+F2 - Start a log with custom settings
; Control+F3 - Push text to the log
; Control+F4 - Force log to end
;;;;;;Remove after testing;;;;;;;
;;;;;;Remove after testing;;;;;;;
;;;;;;Remove after testing;;;;;;;
^F1::
startLogging()
return
^F2::
startLogging(100,100,400,400,"logging")
return
^F3::
log("test text")
return
^F4::
endLogging()
return
;;;;;;Remove after testing;;;;;;;
;;;;;;Remove after testing;;;;;;;
;;;;;;Remove after testing;;;;;;;
startLogging(x:=100,y:=100,w:=400,h:=240,title:="AutoHotKey Log"){
global
If (logging!=1){
logging:=1
local innerW, innerH
innerW:=w-20
innerH:=h-20
Gui +AlwaysOnTop ;Keeps the log on top
Gui, Add, Edit, x10 y10 w%innerW% h%innerH% vConsole ; Adds inner box
Gui, Show, x%x% y%y% w%w% h%h%, %title% ; Displays window
log("Logging has begun") ; This line can be removed if wanted
} else {
Msgbox, Log is already running
}
return
}
log(msg)
{
FormatTime, TimeString, A_Now, yyyyMMdd HH:mm:ss ; Generates a time stamp
GuiControlGet, Console ;Gets current GUI text
GuiControl, , Console, %TimeString% - %msg%`r`n%Console% ; Appends new msg to the GUI
return
}
endLogging(){
global
Gui, Destroy
logging:=""
Return
}
GuiClose:
Gui, Destroy
logging:=""
Return