; Console.Open() ; Console.Write(s) ; Console.Print(s, end="`n")
手动党Debug的时候,可以选择tooltip, msgbox。不过如果要查看多个变量用这种方式还是不方便,如果有可以在控制台多次输出,会不好方便一点呢。
; Example =================================================
; Console.open()
; n := 15
; loop %n%
; {
; i := abs((n+1)/2 - A_Index)
; loop %i%
; {
; Console.Write(" ")
; }
; j := n - abs(n + 1 - A_Index * 2)
; loop %j%
; {
; Console.Print("*", end := "")
; }
; Console.print("")
; }
; =============================================================
class Console
{
; Functions ===============================================
; Console.Open()
; Console.Write(s)
; Console.Print(s, end="`n")
open()
{
Run, cmd.exe /k "echo off", , , NewPid
WinWait, ahk_pid %NewPid%
DllCall("AttachConsole", UInt, NewPid)
DllCall("SetConsoleTitle", str, A_ScriptName)
DllCall("GetConsoleWindow")
DllCall("SetConsoleCP", UInt, 65001)
return hwnd
}
getOutputHandle()
{
h := DllCall("GetStdHandle", UInt, -11)
return h
}
getInputHandle()
{
h := DllCall("GetStdHandle", UInt, -10)
return h
}
getErrorHandle()
{
h := DllCall("GetStdHandle", UInt, -12)
return h
}
Write(s)
{
if(s = "")
return
len := StrLen(s)
VarSetCapacity(written, len)
OutputHandle := this.getOutputHandle()
DllCall("WriteConsole", Int, OutputHandle, Str, s, UInt, len, Ptr, &written, Ptr, 0)
}
print(s, end := "`n")
{
s .= end
this.Write(s)
}
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
![[Lib] Console](https://www.autoahk.com/wp-content/uploads/2018/04/1.jpg)


这就是类库
感谢分享!!?
[…] Console […]
就是想尽可能减少变量数目。
vim用好了不错,对于新手不是很友好!