Continuous Scrolling Log

Post your working scripts, libraries and tools for AHK v1.1 and older
blzrdphoto
Posts: 1
Joined: 20 Jul 2017, 22:33

Continuous Scrolling Log

20 Jul 2017, 23:05

I came across https://autohotkey.com/board/topic/4910 ... og-window/. The end example is a bit verbose and includes a bunch of extra stuff. I condensed everything into some simple to use functions that are very generic. This took me a few hours to make so I figured I would share it with everyone. Enjoy!!!

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

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 120 guests