0
点赞
收藏
分享

微信扫一扫

[AHK]简版堆栈实现


数据结构

S:=[]  ; new Stack
S.Push("Hello")
S.Push("World")
MsgBox % S.Pop() S.Pop()




[AHK]简版堆栈实现_热键


栈数据结构的应用,按热键依次最小化当前窗口,再按热键依次逆序恢复最小化的窗口(作品来自网友: 道破红尘  )


WindowList:=[]
;shift+esc 最小化窗口,shift+`还原窗口
+esc::
WindowLIst.push(WinExist("A"))
PostMessage,0X112,0XF020,,,% "ahk_id" WinExist("A")
return

+`::
WinActivate % "ahk_id" WindowList.pop()
return


[AHK]简版堆栈实现_最小化_02





实现顺序粘贴,即先在某个窗口复制几个条目(F1热键),然后再另一个窗口依次粘贴填表(F2热键),每粘贴完成后会清除掉该条目,如果想恢复刚用过的条目需要按(F3热键)。代码出自:QZ/VimD/TC/AHK


#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

f1::
  CBData.Copy()
return
f2::
  CBData.Paste()
return
f3::
  CBData.Redo()
return

Class CBData
{
    Static List:= []
    Static Recycle := []

    Copy()
    {
        CB := ClipboardAll
        Clipboard := ""
        SendInput, ^{Ins} ;^{vk43sc02E} ;ctrl+c
        ClipWait,% 1, 1
        If !Errorlevel
            this.List.Insert(Clipboard)
        Clipboard := CB
        this.Show()
    }

    Paste()
    {
        msg := this.List[this.List.MinIndex()]
        If strlen(msg)
        {
            CB := ClipboardAll
            Clipboard := msg
            SendInput, ^v
            this.List.Remove(1)
            this.Recycle.Insert(msg)
        }
        this.Show()
    }

    Redo()
    {
        msg := this.Recycle[this.Recycle.MaxIndex()]
        If strlen(msg)
        {
            this.List.InsertAt(1,msg)
            this.Recycle.Remove()
        }
        this.Show()
    }

    Show()
    {
        Loop % this.List.MaxIndex()
        {
            msg .= "#" A_Index " | `t" this.List[A_Index] "`n"
        }
        Tooltip % msg
    }

}







举报

相关推荐

0 条评论