Created
September 13, 2022 05:31
-
-
Save alpgul/3f6ae4c6aeb99ebc408b08a4a05a3c4c to your computer and use it in GitHub Desktop.
AHK Debug Message
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DebugMessage(str) | |
{ | |
global h_stdout | |
DebugConsoleInitialize() ; start console window if not yet started | |
str .= "`n" ; add line feed | |
DllCall("WriteFile", "uint", h_Stdout, "uint", &str, "uint", StrLen(str), "uint*", BytesWritten, "uint", NULL) ; write into the console | |
WinSet, Bottom,, ahk_id %h_stout% ; keep console on bottom | |
} | |
DebugConsoleInitialize() | |
{ | |
global h_Stdout ; Handle for console | |
static is_open = 0 ; toogle whether opened before | |
if (is_open = 1) ; yes, so don't open again | |
return | |
is_open := 1 | |
; two calls to open, no error check (it's debug, so you know what you are doing) | |
DllCall("AttachConsole", int, -1, int) | |
DllCall("AllocConsole", int) | |
dllcall("SetConsoleTitle", "str","Paddy Debug Console") ; Set the name. Example. Probably could use a_scriptname here | |
h_Stdout := DllCall("GetStdHandle", "int", -11) ; get the handle | |
WinSet, Bottom,, ahk_id %h_stout% ; make sure it's on the bottom | |
WinActivate,Lightroom ; Application specific; I need to make sure this application is running in the foreground. YMMV | |
return | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment