[Lib] Console

; Console.Open() ; Console.Write(s) ; Console.Print(s, end="`n")

手动党Debug的时候,可以选择tooltip, msgbox。不过如果要查看多个变量用这种方式还是不方便,如果有可以在控制台多次输出,会不好方便一点呢。

[Lib] Console

; 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)
}
}

给TA捐赠
共{{data.count}}人
人已捐赠
其他案例

AHK源码 继CapsLock+之后,功能更完善的CapsLockPlus

2018-3-29 16:17:00

其他

[VIP]AHK高级字符串函数,新人勿进

2018-4-12 16:31:34

5 条回复 A文章作者 M管理员
  1. AHK中文社区

    vim用好了不错,对于新手不是很友好!

  2. redoceans

    就是想尽可能减少变量数目。

  3. […] Console […]

  4. 火冷

    感谢分享!!?

  5. surefly

    这就是类库

个人中心
购物车
优惠劵
有新私信 私信列表
搜索