1 Star 9 Fork 1

xcatp/ahk-lib

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
TipUI.ahk 1.44 KB
Copy Edit Raw Blame History
xcatp authored 2024-10-25 14:09 +08:00 . feat: 添加tip的ui版本
; Tip.ahk 的ui版本
#Requires AutoHotkey v2.0
#Include Theme.ahk
#Include util\Animation.ahk
/*
; ======== 使用静态方法
DCon TipUI.ShowTip('halo'), &x, &y, &w, &h ; 可以解构出x,y,w,h,duration
TipUI.ShowTip('xcatp', , y + h + 10)
; ======== 自己new
t := TipUI('meow', 100, 100, 1000, Noop)
t.Start() ; 开始
t.Stop() ; 内部使用的方法,调用后就停止了(无法恢复)
t.Destroy() ; 销毁
*/
class TipUI extends Gui {
__New(text, x, y, duration, onRClick) {
if duration <= 100
throw Error('必须大于100')
super.__New('+AlwaysOnTop +ToolWindow -Caption +Border')
this.SetFont('s13', 'consolas')
this.AddText('Section x16 y5', text).GetPos(, , &w)
this.AddText('xs y25 Backgroundffd500 h1 w' w)
this.OnEvent('ContextMenu', onRClick)
Theme.Dark(this), this.Show('hide'), this.GetPos(, , &w, &h)
this.p := this.AddText('x0 y' h - 4 ' Backgroundff2323 h3 w' w)
this.data := [x, y, w, h, duration]
}
Start() {
DCon(this.data, &x, &y, &w, , &time), this.Show('NA x' x ' y' y)
t := 100, i := 0, _w := w / t, _d := time / t
SetTimer(d, _d), this.Stop := (*) => SetTimer(d, 0)
return this.data
d() {
this.p.Move(, , w - _w * i), i++
if i >= t
Animation.FadeOut(this)
}
}
Destroy() => (this.Stop(), super.Destroy())
static ShowTip(text, x := 100, y := 50, duration := 4000, onRClick := Noop)
=> TipUI(text, x, y, duration, onRClick).Start()
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
AutoHotkey
1
https://gitee.com/dkwd/ahk-lib.git
git@gitee.com:dkwd/ahk-lib.git
dkwd
ahk-lib
ahk-lib
master

Search