ShowVarsToConsole
The auto execute section is something I set up for all my scripts... ignore some of the options.
Code: Select all
/*
=========================================================================
Title: ListVars To Console
=========================================================================
Descrition: Create a console to show your own
variables. To show an array or object
simply put Showvars(ArrayOrObj*)
The asterisk will show all the variables
in the array/object.
-------------------------------------------------------------------------
AutoHotkey Version: 1.1.26.01
Language: English
Used Platform(s): Win 10
Author: Delta
Contact information: [email protected]
|=======================================================================|
| Hotkeys: |
| None |
|=======================================================================|
=========================================================================
*/
#NoEnv
#SingleInstance Force
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#ErrorStdOut
Process, Priority,, H
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetWinDelay, -1
SetControlDelay, -1
SetDefaultMouseSpeed, 0
SendMode, Input
CoordMode, Mouse, Screen
SetWorkingDir, %A_ScriptDir%
Colors := ["Red", "Yellow", "Blue"]
Vars := {User: A_UserName, ScriptDir: A_ScriptDir, ScriptName: A_ScriptName}
; Do remember that each Console window must be closed before moving on in the scipt
ShowVarsToConsole(Colors*)
ShowVarsToConsole(Vars*)
ExitApp
; I couldn't have done this without the FileObj doc's second example!!
; https://autohotkey.com/docs/commands/FileOpen.htm#Examples
ShowVarsToConsole(Vars*) {
DllCall("AllocConsole")
stdin := FileOpen("*", "r `n")
stdout := FileOpen("*", "w `n")
; For older versions:
; stdin := FileOpen(DllCall("GetStdHandle", "int", -10, "ptr"), "h `n")
; stdout := FileOpen(DllCall("GetStdHandle", "int", -11, "ptr"), "h `n")
stdout.Write("=============================`n")
For Index, Out in Vars {
stdout.Write(A_Space Index " : " Out "`n")
stdout.Read(0)
}
stdout.Write("=============================`n")
stdout.Write("Press Enter To Close...`n")
stdout.Read(0)
query := RTrim(stdin.ReadLine(), "`n")
stdout.Read(0)
stdin.Close()
stdout.Close()
}
It works with variables the same way:
Code: Select all
#Include Console_Func.ahk ; This is if you have the function inside a file all by itself
ShowVarsToConsole(A_ScriptName, A_ScriptDir, A_UserName, A_GuiControl, A_Index) ; Works with any variable that has a value, it displays in appearence according to the parameters in the function.