[AHK]简版堆栈实现

来源:互联网 发布:java 网络拓扑发现 编辑:程序博客网 时间:2024/06/05 21:19

数据结构

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



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


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




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


#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()returnf2::  CBData.Paste()returnf3::  CBData.Redo()returnClass 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    }}





原创粉丝点击