剪贴板助手

如果短时间内需要频繁打开或启动某程序可能需要不断切换到资源管理器, 这个ahk脚本只需在资源管理器选定文件然后按两次反引号:` 会用gui显示路径, 点击路径可启动/打开文件, 点按gui边缘可拖动位置.

2024/08/28 19:59:59

选定文字 按2次 Ctrl+c —> 点击可粘贴到活动窗口
选定数字 按2次 Ctrl+c —> 将数字作为分钟倒计时
资源管理器中选定文件 按2次 Ctrl+c —>点击运行这个文件
claunahk 中键长按 —> 悬浮 图标+文件名
claunahk 右键长按 —> 悬浮 图标


:pushpin:按2次 Ctrl+c

~^c::
    if (A_PriorHotkey = "~^c") and (A_TimeSincePriorHotkey < 500)
    {
        Run, "D:\Documents\ahk\guiFileStarter.ahk"
    }
return

:pushpin:长按中键

~MButton::
    StartTime := A_TickCount
    MouseGetPos, xpos, ypos,,classNN
    WinGetPos, , , win_width, , A
KeyWait, MButton
        if (A_TickCount - StartTime > 500) {
        ;~ If (A_TimeSinceThisHotkey > 500) {
        CoordMode, Mouse, screen
 {
        MouseGetPos, xx, yy, id
        Sleep 100
        WinGet, exename, ProcessName, ahk_id %id%
        Sleep 100

    if (exename = "claunch.exe" or exename = "claunch2.exe")
    {
        Send, ^p
        Loop{
            WinWaitActive, 项目属性
            ControlGetText, runpath, Edit2, 项目属性
            if (runpath != "")
              ;~ MsgBox,,,% runpath, 1
                break
        }

        ControlClick, 更改图标, 项目属性,,,, NA
        Loop{
        WinWaitActive, 图标设置
        ControlGetText, runico, Edit1, 图标设置
        if (runico != "")
          ;~ MsgBox,,,% runico
            break
         }
         send, {Esc 3}
         Clipboard := "claunclaunclaun`n" . runpath . "`n" . runico
        MouseMove, %xx%, %yy%

        Run, "D:\Documents\ahk\guiFileStarter.ahk"
        return
    }

:pushpin:长按右键

~RButton::
CoordMode, ToolTip, screen
;~ LAlt::
MouseGetPos,,,,ClassNN

;~ MsgBox,,,%ClassNN%
	KeyWait, RButton
	If (A_TimeSinceThisHotkey > 500)  ; 右键长按
    {
        CoordMode, Mouse, screen
        MouseGetPos, xx, yy, id
    WinGet, exename, ProcessName, ahk_id %id%
        Sleep 100
    if (exename = "claunch.exe" or exename = "claunch2.exe")
    {
        Sleep 100
        Send, {Up}{Enter}
        Loop{
            WinWaitActive, 项目属性
            ControlGetText, runpath, Edit2, 项目属性
            if (runpath != "")
              ;~ MsgBox,,,% runpath, 1
                break
        }

        ControlClick, 更改图标, 项目属性,,,, NA
        Loop{
        WinWaitActive, 图标设置
        ControlGetText, runico, Edit1, 图标设置
        if (runico != "")
          ;~ MsgBox,,,% runico
            break
         }
         send, {Esc 3}
         Clipboard := "justIcon`n" . runpath . "`n" . runico
        MouseMove, %xx%, %yy%

        Run, "D:\Documents\ahk\guiFileStarter.ahk"
        return
    }
    }

第二部分:


#singleinstance off
#NoTrayIcon
CoordMode, mouse, screen
MouseGetPos, xpos, ypos


iconpath := ""
FullFileName := ""
FullFileName_justIcon := ""


if (Clipboard = "")
{
    ToolTip, 空
    SetTimer, RemoveToolTip, 500
    return
}


if (RegExMatch(Clipboard, "claunclaunclaun", icon_name))
{
    ;~ MsgBox,,,21,2
    StringSplit, Lines, Clipboard, `n, %A_Space%
        {
            FullFileName := Lines2
            iconpath := Lines3
            SplitPath, FullFileName, name , dir, ext, name_no_ext
            Gui Add, picture,gOnPic w16 h16 x2 y5, % iconpath
            Gui Add, Text,  cBlue gOpen x20 y7, %name_no_ext%

            }
}

if (RegExMatch(Clipboard, "justIcon", just_Icon))
{
     ;~ MsgBox,,,34,2
    StringSplit, Lines, Clipboard, `n, %A_Space%
        {
            FullFileName_justIcon := Lines2
            justIcon := Lines3
            Gui, Margin, 2, 2
            Gui Add, picture,gJustIcon w16 h16 x2 y2, % justIcon
            }

}
if (!RegExMatch(Clipboard, "justIcon", ustIcon) && !RegExMatch(Clipboard, "claunclaunclaun", claun))
{
;~ MsgBox,,,43,2
FullFileName := Clipboard
iconpath := ""
SplitPath, FullFileName, name , dir, ext, name_no_ext


IfInString, FullFileName, `:`\    ; 文件地址
{
        ;~ MsgBox,,,60,3
        Gui Add, Text,  h14 cBlue gOpen, %name_no_ext%
}
else IfInString, FullFileName, www`.    ;网址
{
        ;~ MsgBox,,,65,3
        Gui Add, Text,  h14 cBlue gOpen, %name_no_ext%
}
else if (RegExMatch(Clipboard, "^\d+$", num)) {  ;数字 将剪贴板数字作为分钟倒计时
        numlen := StrLen(clipboard) * 12
        number := num
        Gui, Margin, 2, 2
        Gui, font, cRed Bold s16
        Gui, Add, Text, w%numlen% vNumberText
        GuiControl,, NumberText, %number%
        SetTimer, UpdateNumber, 60000
}

else                                           ;文本 点击直接粘贴
{
    Gui Add, Text,  h14 cblack gCopy, %FullFileName%
}
}



Gui  +AlwaysOnTop -Caption ToolWindow

Gui Show, x%xpos% y%ypos%

Gui, +LastFound
WinGet, MyGuiHWND
winSet, ExStyle, +0x08000000, ahk_id %MyGuiHWND%
OnMessage(0x201, "move_Win")

Return

Open:
tooltip, clicked
SetTimer, RemoveToolTip, 1000
Run, %FullFileName%
return

OnPic:
return
JustIcon:
tooltip, clicked
SetTimer, RemoveToolTip, 1000
Run, %FullFileName_justIcon%
return

Copy:
Clipboard := FullFileName
Sleep 50
Send, ^v
return
~MButton::
    MouseGetPos, MouseX, MouseY, WinUnderMouse
    if (WinExist("ahk_id " MyGuiHWND) && WinUnderMouse = MyGuiHWND) {
        ExitApp
    }
return

RemoveToolTip:
SetTimer, RemoveToolTip, Off
ToolTip
Return

UpdateNumber:
    if (number > 1) {
        number --
        GuiControl,, NumberText, %number%
    } else {
        loop 3
        {
        SoundBeep
        sleep, 200
        }
        SetTimer, UpdateNumber, Off
        ExitApp
    }
return


move_Win()
{
    PostMessage, 0xA1, 2
}
4 个赞

2025年9月30日10:10:02 更新

临时剪贴板, 单击粘贴, 或输入开头的字母快捷键粘贴, 字母快捷键同时按下, 默认有十组, 都在左手. 中键关闭.

长文本显示

链接单击打开, 可转换为普通文本, 单击粘贴

文件夹, 可转换为普通文本, 单击粘贴

打开具体文件

#singleinstance off
#NoTrayIcon
#NoEnv
#KeyHistory 0
#MaxHotkeysPerInterval 200
#HotkeyInterval 2000
#InstallKeybdHook
#InstallMouseHook
CoordMode, mouse, screen

; 检查是否存在临时文件,如果存在则读取保存的位置信息
tempFile := A_Temp . "\guiFileStarter_temp.txt"
if (FileExist(tempFile)) {
    FileReadLine, savedX, %tempFile%, 1
    FileReadLine, savedY, %tempFile%, 2
    FileReadLine, savedWidth, %tempFile%, 3
    FileReadLine, savedHeight, %tempFile%, 4
    FileReadLine, savedContent, %tempFile%, 5
    ; 将保存的内容放入剪贴板
    Clipboard := savedContent
    ; 删除临时文件
    FileDelete, %tempFile%
}

MouseGetPos, xpos, ypos

; 如果有保存的位置信息,则使用它
if (savedX != "" and savedY != "") {
    xpos := savedX
    ypos := savedY
}

; 全局变量初始化
Global keyCombos := []  ; 快捷键组合数组
Global currentKeyIndex := 1  ; 当前快捷键索引

; 从文件读取上次使用的快捷键索引
keyIndexFile := A_ScriptDir . "\key_index.txt"
if FileExist(keyIndexFile) {
    FileRead, savedKeyIndex, %keyIndexFile%
    if (savedKeyIndex is number && savedKeyIndex >= 1 && savedKeyIndex <= 10) {
        currentKeyIndex := savedKeyIndex
    }
}

; 全局变量用于存储当前的随机快捷键
randomKey1 := ""
randomKey2 := ""

; 全局变量用于存储颜色组合和当前颜色索引
global colorCombos := Object()
colorCombos[1] := Object("TextColor", "#F5F176", "GuiColor", "#58C0A0")  ; 文本色, GUI色
colorCombos[2] := Object("TextColor", "#2C5530", "GuiColor", "#E8F5E2")
colorCombos[3] := Object("TextColor", "#FFFFFF", "GuiColor", "#8F9CA4")
colorCombos[4] := Object("TextColor", "#FFFFFF", "GuiColor", "#1A958A")
colorCombos[5] := Object("TextColor", "#FFE160", "GuiColor", "#3D7AAA")
colorCombos[6] := Object("TextColor", "#FFFFFF", "GuiColor", "#CCE8FF")
colorCombos[7] := Object("TextColor", "#1D3557", "GuiColor", "#A8DADC")
colorCombos[8] := Object("TextColor", "#7719AA", "GuiColor", "#CD85F1")
colorCombos[9] := Object("TextColor", "#8B0000", "GuiColor", "#FFEBEE")
colorCombos[10] := Object("TextColor", "#3656A3", "GuiColor", "#FFF7CC")

; 从文件读取上次使用的颜色索引
global currentColorIndex := 1
indexFile := A_ScriptDir . "\color_index.txt"
if FileExist(indexFile) {
    FileRead, savedIndex, %indexFile%
    if (savedIndex is number && savedIndex >= 1 && savedIndex <= 10) {
        currentColorIndex := savedIndex
    }
}

; 设置默认字体以改善中文显示
Gui, Font, s9, Microsoft YaHei

iconpath := ""
FullFileName := ""
FullFileName_iconOnly := ""


if (Clipboard = "")
{
    ToolTip, 空
    SetTimer, RemoveToolTip, 500
    return
}


if (RegExMatch(Clipboard, "claunclaunclaun", icon_name))
{
    ;~ MsgBox,,,21,2
    StringSplit, Lines, Clipboard, `n, %A_Space%
        {
            FullFileName := Lines2
            iconpath := Lines3
            SplitPath, FullFileName, name , dir, ext, name_no_ext
            Gui Add, picture,gOnPic w16 h16 x2 y5, % iconpath
            Gui Add, Text,  cBlue gOpen x20 y7, %name_no_ext%


            Gui  +AlwaysOnTop -Caption ToolWindow
            Gui Show, x%xpos% y%ypos%
            Gui, +LastFound
            WinGet, MyGuiHWND
            winSet, ExStyle, +0x08000000, ahk_id %MyGuiHWND%


            }

}

if (RegExMatch(Clipboard, "iconOnly", icon_Only))
{
    StringSplit, Lines, Clipboard, `n, %A_Space%
        {
            FullFileName_iconOnly := Lines2
            iconOnly := Lines3
            Gui, Margin, 2, 2
            Gui Add, picture,giconOnly w16 h16 x2 y2, %iconOnly%


            Gui  +AlwaysOnTop -Caption ToolWindow
            Gui Show, x%xpos% y%ypos%
            Gui, +LastFound
            WinGet, MyGuiHWND
            winSet, ExStyle, +0x08000000, ahk_id %MyGuiHWND%

            }



}
if (!RegExMatch(Clipboard, "iconOnly", ustIcon) && !RegExMatch(Clipboard, "claunclaunclaun", claun))
{
;~ MsgBox,,,43,2
FullFileName := Clipboard
iconpath := ""
SplitPath, FullFileName, name , dir, ext, name_no_ext


IfInString, FullFileName, :\    ; 文件地址
;~ if (RegExMatch(FullFileName, ":\\"))
{
        ;~ MsgBox,,,60,3
        Gui, font,s9, Microsoft YaHei

        ; 增强文件夹检测逻辑,处理可能的路径格式问题
        ; 确保路径没有前导或尾随空格
        FullFileName := Trim(FullFileName)

        ; 添加调试信息以帮助诊断
        ; MsgBox, 调试信息:`n路径: %FullFileName%`nFileExist返回值: %FileExist(FullFileName)%

        ; 检查路径是否为文件夹(使用更可靠的检测方法)
        isFolder := false
        fileType := FileExist(FullFileName)
        if (fileType = "D")
        {
            isFolder := true
        }
        ; 额外检查:如果路径最后有反斜杠,也视为文件夹
        else if (SubStr(FullFileName, 0) = "\")
        {
            isFolder := true
        }

        if (isFolder)
        {
            ; 是文件夹,使用文件夹图标并显示文件夹名称
            Gui Add, Text,gtotext x5 y5 w14 h14 , 📁
            Gui Add, Text, x22 y5 h14 cblue gOpen, %name%
        }
        else
        {
            ; 是文件,保持原有显示方式
            Gui Add, Text, x20 y5 h14 cblue gOpen, %name_no_ext%
            Gui Add, Text,gtotext x5 y5 w14 h14 ,📄
        }

        Gui  +AlwaysOnTop -Caption ToolWindow
        Gui Show, x%xpos% y%ypos% NA
        Gui, Color, EBCEBD
        Gui, +LastFound

        winSet, ExStyle, +0x08000000, ahk_id %MyGuiHWND%
        WinGet, MyGuiHWND
        
        ; 调整窗口大小为单行高度
        WinGetPos, winX, winY, winWidth, winHeight, ahk_id %MyGuiHWND%
        Gui Show, x%xpos% y%ypos% w%winWidth% h24

}
else IfInString, FullFileName, `:`/`/    ;网址
{
        ;~ MsgBox,,,65,1
        Gui, font,s10, Microsoft YaHei
        ; 将"网址"和实际URL分开,让"网址"也可点击,点击后切换到文本模式
        Gui Add, Text,   cffffff gtotext  x4 y3, 🌐
        Gui Add, Text,  h14 cBlue gOpen x+2 y2,  %FullFileName%
        Gui, color, 5AA9D4
        Gui  +AlwaysOnTop -Caption ToolWindow
        Gui Show, x%xpos% y%ypos% NA
        Gui, +LastFound
        WinGet, MyGuiHWND
        winSet, ExStyle, +0x08000000, ahk_id %MyGuiHWND%
        
        ; 调整窗口大小为单行高度
        WinGetPos, winX, winY, winWidth, winHeight, ahk_id %MyGuiHWND%
        Gui Show, x%xpos% y%ypos% w%winWidth% h24

}
else if (RegExMatch(Clipboard, "^\d+$", num)) {  ;数字 将剪贴板数字作为分钟倒计时

        numlen := StrLen(clipboard) * 12
        number := num
        Gui, Margin, 2, 2
        Gui, font, cRed Bold s16
        Gui, Add, Text, w%numlen% vNumberText
        GuiControl,, NumberText, %number%
        SetTimer, UpdateNumber, 60000

        Gui  +AlwaysOnTop -Caption ToolWindow
        Gui Show, x%xpos% y%ypos%
        Gui, +LastFound
        WinGet, MyGuiHWND
        winSet, ExStyle, +0x08000000, ahk_id %MyGuiHWND%
        OnMessage(0x201, "move_Win")
        return
}




else if (RegExMatch(Clipboard, "^#[0-9A-Fa-f]{6}$", hex)){   ; 显示16进制 和rgb颜色
    StringReplace, hex, hex, `#,
    rgb := hexToRGB(hex)
    Gui Add, Text,  h14 cwhite  gCopy, hex`:`#%hex% `nrgb`:%rgb%
    Gui, color, %hex%
    Gui  +AlwaysOnTop -Caption ToolWindow
    Gui Show, x%xpos% y%ypos% AutoSize
    Gui, +LastFound
    WinGet, MyGuiHWND
    winSet, ExStyle, +0x08000000, ahk_id %MyGuiHWND%

    OnMessage(0x201, "move_Win")
    return


}
/*

                                                ..'":                           "I;I,
                                                ?CQZm}                          \pwqv
                                    ':::::::::::!Ldppw_:::::::::::' '!!!!!!!!!!!xdqpU!!!!!!!!!!!"
                                    >qqqqwmmmmwqwqpppdpqmmmmmwqqqqi !pddddddddpqqqqqqqppdddddddb|
                                    lccccYpqqpLvccvvvvcv0pqqpQccccI ,\//////\|rmqqqqqqz|\//////t~
                                            'cdqpL;       iOpqdL:               +JppqqqppO)'
                                            "YdqpQ<     -ZpqdCI              <cpbOCpqpCYddQ{^
                                            ^npppwt, ;rqppdu"            '_cqbpc;\dqpc'|mbdQ(;
                                            .}0pqd0nOdqp0}.           I(CpdpU-  /dqpc  ;jmddmv?,
                                                ;cpqpdpqpu,          ")YwdbpO\l"::jpqpX::,,-zmdbpmz~
                                            ^!}rCmppdpdppZYf?l`      `{Qdwc_nqqqqqqqqqqqqqqqY;(CpC[^
                                    `!+{jX0qdbbpZX)~|Ymdbbdq0Xr)?<^  `]l  ?fttt/UpqpQttttt1  `>`
                                    "jpbbbdqOX/_,    .;?fYZpbbbbw\^             /bpbz
                                        +Yct[!^             ">[/cr;               1CJCj
                                        .                                        .....
*/
else                                           ;文本 点击直接粘贴
{
    ; 从指定的10个组合中随机选择一个
    keyCombo := GetRandomKeyCombo()
    randomKey1 := keyCombo[1]
    randomKey2 := keyCombo[2]

    ; 声明颜色变量并设置默认值
    textColor := "FFFFFF"
    guiColor := "8E68EF"

    ; 获取当前的颜色组合
    GetNextColorCombo(textColor, guiColor)

    ; 移除颜色值中的#符号(AHK v1中颜色格式需要)
    textColor := StrReplace(textColor, "#")
    guiColor := StrReplace(guiColor, "#")

    ; 显示文本内容,前面添加快捷键组合
    displayText := randomKey1 randomKey2 ": " FullFileName
    
    ; 如果文本超过56个字符,则进行换行处理
    displayText := WrapText(displayText, 56)

    Gui, Margin, 20, 5
    Gui, font, c%textColor% s9, Microsoft YaHei
    Gui Add, Text,  h14  hwndTexttoshow gCopy, %displayText%
    ; 默认选中复选框,使文字状态默认为固定显示
    Gui, Add, Checkbox, x5 y5 w15 h15 vMyCheckbox gTextFixed Checked,
    ;~ Gui, color, 5787C7

    Gui, color, %guiColor%

    Gui  +AlwaysOnTop -Caption ToolWindow
    Gui Show, x%xpos% y%ypos% AutoSize

    Gui, +LastFound
    WinGet, MyGuiHWND
    winSet, ExStyle, +0x08000000, ahk_id %MyGuiHWND%
    WinGetPos , Xo, Yo, Width, Height, ahk_id %MyGuiHWND%
    
    ; 检查是否存在临时位置文件,如果存在则使用它
    tempFile := A_Temp . "\guiFileStarter_temp.txt"
    if (FileExist(tempFile)) {
        FileReadLine, savedX, %tempFile%, 1
        FileReadLine, savedY, %tempFile%, 2
        FileReadLine, savedWidth, %tempFile%, 3
        FileReadLine, savedHeight, %tempFile%, 4
        ; 使用保存的位置
        Gui Show, x%savedX% y%savedY%
        ; 删除临时文件
        FileDelete, %tempFile%
    }
    
    ; 现在可以正确设置返回按钮位置,因为Width已知
    backX := Width - 25
    backY := 5
    GuiControl, Move, BackButton, x%backX% y%backY%

    ; 因为默认为固定显示,所以保持完整窗口大小,不自动缩小
    Width_s := Width
    Height_s := Height

    ; 添加临时热键,两个随机字母同时按下时粘贴
    Hotkey, ~%randomKey1% & %randomKey2%, CheckAndPaste, On

    ; 设置鼠标位置检测定时器,用于实现鼠标悬浮展开和离开收缩效果
    SetTimer,mousepos, 200

}
}

Clipboard :=
OnMessage(0x201, "move_Win")

Return

TextFixed:
    GuiControlGet, CheckboxState, , MyCheckbox
    if (CheckboxState = 1) {
        ; 固定状态
        ToolTip, % "固定 "
        SetTimer, RemoveToolTip, 1000
        Width_s := Width
        Height_s := Height
        ; 使用平滑动画调整窗口大小为完整尺寸
        SmoothWindowResize(MyGuiHWND, Width_s, Height_s, 15)
        return
    } else {
        ; 取消固定状态
        ToolTip, % "取消固定 "
        SetTimer, RemoveToolTip, 500
        Width_s := 130
        Height_s := 26
        ; 使用平滑动画调整窗口大小为小尺寸
        SmoothWindowResize(MyGuiHWND, Width_s, Height_s, 15)
        return
    }
return

; 返回到初始状态的函数
backToInitial:
    ; 保存当前GUI的位置和大小
    WinGetPos, guiX, guiY, guiWidth, guiHeight, ahk_id %MyGuiHWND%
    
    ; 保存位置和大小以及内容到临时文件
    tempFile := A_Temp . "\guiFileStarter_temp.txt"
    FileDelete, %tempFile%
    FileAppend, %guiX%`n%guiY%`n%guiWidth%`n%guiHeight%`n%FullFileName%, %tempFile%
    
    ; 销毁当前GUI
    gui, destroy
    
    ; 重启脚本
    Run, "%A_AhkPath%" "%A_ScriptFullPath%"
    ExitApp
    
    return

mousepos:
CoordMode, Mouse, screen
MouseGetPos, x, y
WinGetPos, X_text_win, Y_text_win, Width_text_win, Height_text_win, ahk_id %MyGuiHWND%
; 如果鼠标悬浮在小窗口则显示完整文本控件
if (x>(X_text_win)&& x<(X_text_win + Width_s) && y>(Y_text_win) && y<(Y_text_win + Height_s)) {
	; 使用平滑动画展开窗口
	SmoothWindowResize(MyGuiHWND, Width, Height, 15)
	SetTimer, leave_text, 50 ; 增加定时器间隔,给动画足够时间完成
}
	return


closethis:
MsgBox,,,1,1
return

totext:
    gui, destroy

    ; 从指定的10个组合中随机选择一个
    keyCombo := GetRandomKeyCombo()
    randomKey1 := keyCombo[1]
    randomKey2 := keyCombo[2]

    ; 声明颜色变量并设置默认值
    textColor := "FFFFFF"
    guiColor := "8E68EF"

    ; 获取当前的颜色组合
    GetNextColorCombo(textColor, guiColor)

    ; 移除颜色值中的#符号(AHK v1中颜色格式需要)
    textColor := StrReplace(textColor, "#")
    guiColor := StrReplace(guiColor, "#")

    ; 显示文本内容,前面添加随机字母
    displayText := randomKey1 randomKey2 ": " FullFileName
    
    ; 如果文本超过56个字符,则进行换行处理
    displayText := WrapText(displayText, 56)

    Gui, Margin, 20, 5
    Gui, font, c%textColor% s9, Microsoft YaHei
    Gui Add, Text,  h14  hwndTexttoshow gCopy, %displayText%
    ; 默认选中复选框,使文字状态默认为固定显示
    Gui, Add, Checkbox, x5 y5 w15 h15 vMyCheckbox gTextFixed Checked,
    ; 创建返回按钮但暂不设置位置
    Gui Add, Text, vBackButton gbackToInitial w20 h16, % "🔙"
    ;~ Gui, color, 5787C7

    Gui, color, %guiColor%

    Gui  +AlwaysOnTop -Caption ToolWindow
    Gui Show, x%xpos% y%ypos% h24

    Gui, +LastFound
    WinGet, MyGuiHWND
    winSet, ExStyle, +0x08000000, ahk_id %MyGuiHWND%
    WinGetPos , Xo, Yo, Width, Height, ahk_id %MyGuiHWND%
    
    ; 检查是否存在临时位置文件,如果存在则使用它
    tempFile := A_Temp . "\guiFileStarter_temp.txt"
    if (FileExist(tempFile)) {
        FileReadLine, savedX, %tempFile%, 1
        FileReadLine, savedY, %tempFile%, 2
        FileReadLine, savedWidth, %tempFile%, 3
        FileReadLine, savedHeight, %tempFile%, 4
        ; 使用保存的位置
        Gui Show, x%savedX% y%savedY%
        ; 删除临时文件
        FileDelete, %tempFile%
    }
    
    ; 现在可以正确设置返回按钮位置,因为Width已知
    backX := Width - 25
    backY := 5
    GuiControl, Move, BackButton, x%backX% y%backY%

    ; 因为默认为固定显示,所以保持完整窗口大小,不自动缩小
    Width_s := Width
    Height_s := Height

    ; 添加临时热键,两个随机字母同时按下时粘贴
    Hotkey, ~%randomKey1% & %randomKey2%, CheckAndPaste, On

    ; 设置鼠标位置检测定时器,用于实现鼠标悬浮展开和离开收缩效果
    SetTimer,mousepos, 200

return


leave_text:                                  ; 检查鼠标是否离开

    winSet, ExStyle, +0x08000000, ahk_id %MyGuiHWND%
	CoordMode, Mouse, Screen
    MouseGetPos, xx, yy
    WinGetPos, winX, winY, Wwin, Hwin, ahk_id %MyGuiHWND%
	if(xx < winX or (xx > (winX+Wwin)) or yy < (winY) or yy > (winY+Hwin)){  ; 鼠标离开折叠
		; 使用平滑动画收缩窗口
		SmoothWindowResize(MyGuiHWND, Width_s, Height_s, 5)
		SetTimer, leave_text, off
	}
return


;~ ~RButton::
 ;~ MouseGetPos, MouseX, MouseY, WinUnderMouse
    ;~ if (WinExist("ahk_id " MyGuiHWND) && WinUnderMouse = MyGuiHWND) {
        ;~ switcher += 1

    ;~ if (switcher > 2){

        ;~ ToolTip, % "固定 " switcher
        ;~ SetTimer, RemoveToolTip, 1000
        ;~ Width_s := Width
        ;~ Height_s := Height
        ;~ switcher := 0
        ;~ return
    ;~ }
    ;~ if (switcher < 2){
        ;~ ToolTip, % "取消固定 " switcher
        ;~ SetTimer, RemoveToolTip, 500
        ;~ Width_s := 130
        ;~ Height_s := 26
        ;~ return


    ;~ }
;~ }

; 快速窗口大小调整函数(高性能版)
; 参数: hWnd - 窗口句柄, targetW - 目标宽度, targetH - 目标高度, duration - 动画持续时间(毫秒)(已优化,此参数不再使用)
SmoothWindowResize(hWnd, targetW, targetH, duration) {
    global g_isAnimating

    ; 如果已经有动画在运行,则退出
    if (g_isAnimating)
        return

    ; 设置动画运行标志
    g_isAnimating := true

    ; 高性能模式设置 - 关闭批处理以获得最大速度
    SetBatchLines, -1

    ; 获取当前窗口大小
    WinGetPos,,, currentW, currentH, ahk_id %hWnd%

    ; 计算宽度和高度的总变化量
    deltaW := targetW - currentW
    deltaH := targetH - currentH

    ; 最小化动画步骤以获得最大速度
    steps := 2 ; 非常少的步骤,但仍然能提供平滑效果

    ; 缓存常用变量以减少重复计算
    stepSizeW := deltaW / steps
    stepSizeH := deltaH / steps

    ; 使用增量更新而不是百分比进度计算
    newW := currentW
    newH := currentH

    ; 执行快速动画循环
    Loop, % steps {
        ; 计算当前步的窗口大小(使用简化的线性插值提高速度)
        if (A_Index = 1) {
            ; 第一步稍微慢一点,提供初始缓冲
            newW += stepSizeW * 0.8
            newH += stepSizeH * 0.8
        } else if (A_Index = steps) {
            ; 最后一步直接到位,确保动画结束时精确
            newW := targetW
            newH := targetH
        } else {
            ; 中间步骤使用简单的线性插值
            newW += stepSizeW
            newH += stepSizeH
        }

        ; 应用新的窗口大小
        WinMove, ahk_id %hWnd%,,,, %newW%, %newH%

        ; 对于中间步骤,完全不使用延迟以获得最大速度
    }

    ; 确保最终达到目标大小
    WinMove, ahk_id %hWnd%,,,, %targetW%, %targetH%

    ; 恢复默认性能设置
    SetBatchLines, 10ms

    ; 清除动画运行标志
    g_isAnimating := false

    return
}
;~ return

Open:
tooltip, clicked
SetTimer, RemoveToolTip, 1000
Run, %FullFileName%
return

OnPic:
return
iconOnly:
tooltip, clicked
SetTimer, RemoveToolTip, 1000
Run, %FullFileName_iconOnly%
return

Copy:
Clipboard := FullFileName
Sleep 50
Send, ^v
return

~MButton::
    MouseGetPos, MouseX, MouseY, WinUnderMouse
    if (WinExist("ahk_id " MyGuiHWND) && WinUnderMouse = MyGuiHWND) {
        ;~ MsgBox, % MyGuiHWND
        WinClose, ahk_id %MyGuiHWND%
        ExitApp
    }
return


RemoveToolTip:
SetTimer, RemoveToolTip, Off
ToolTip
Return

UpdateNumber:
    if (number > 1) {
        number --
        GuiControl,, NumberText, %number%
    } else {
        loop 3
        {
        SoundBeep
        sleep, 200
        }
        SetTimer, UpdateNumber, Off
        ExitApp
    }
return

hexToRGB(hex) {
    hex := RegExReplace(hex, "#", "")
    ; Convert HEX to RGB
    r := SubStr(hex, 1, 2)
    g := SubStr(hex, 3, 2)
    b := SubStr(hex, 5, 2)

    r := "0x" r
    g := "0x" g
    b := "0x" b

    r := Format("{:d}", r)
    g := Format("{:d}", g)
    b := Format("{:d}", b)

    return r "," g "," b
}

; 文本换行函数 - 当文本超过指定字符数时进行换行
WrapText(text, maxCharsPerLine := 56) {
    ; 如果文本长度小于等于最大字符数,则直接返回原文本
    if (StrLen(text) <= maxCharsPerLine)
        return text
    
    ; 否则进行换行处理
    wrappedText := ""
    
    ; 循环处理文本,每次处理一行
    while (StrLen(text) > 0) {
        ; 如果剩余文本长度小于等于最大字符数,直接添加到结果中
        if (StrLen(text) <= maxCharsPerLine) {
            wrappedText .= text
            break
        }
        
        ; 取一行文本
        line := SubStr(text, 1, maxCharsPerLine)
        remaining := SubStr(text, maxCharsPerLine + 1)
        
        wrappedText .= line
        ; 如果还有剩余文本,添加换行符
        if (StrLen(remaining) > 0) {
            wrappedText .= "`n"
        }
        
        ; 更新text为剩余文本
        text := remaining
    }
    
    return wrappedText
}

; 从指定的10个组合中循环选择一个(类似颜色组合的循环方式)
GetRandomKeyCombo() {
    global keyCombos, currentKeyIndex
    
    ; 如果是首次调用,初始化快捷键组合数组
    if (keyCombos.Length() = 0) {
        ; 指定的10个快捷键组合
        keyCombos := ["er", "we", "as", "sd", "df", "dr", "dv", "fe", "fw", "fa"]
    }
    
    ; 获取当前快捷键组合
    combo := keyCombos[currentKeyIndex]
    
    ; 更新索引,循环使用快捷键组合
    currentKeyIndex := currentKeyIndex + 1
    if (currentKeyIndex > 10) {
        currentKeyIndex := 1
    }
    
    ; 保存当前索引到文件,以便下次启动时使用
    keyIndexFile := A_ScriptDir . "\key_index.txt"
    FileDelete, %keyIndexFile%
    FileAppend, %currentKeyIndex%, %keyIndexFile%
    
    ; 返回第一个字符和第二个字符
    return [SubStr(combo, 1, 1), SubStr(combo, 2, 1)]
}

; 获取下一个颜色组合(循环)
GetNextColorCombo(ByRef textColor, ByRef guiColor) {
    global colorCombos, currentColorIndex

    ; 获取当前颜色组合
    currentCombo := colorCombos[currentColorIndex]

    ; 提取文本色和GUI色
    if IsObject(currentCombo) {
        textColor := currentCombo["TextColor"]
        guiColor := currentCombo["GuiColor"]
    }

    ; 确保颜色值不为空
    if (textColor = "")
        textColor := "#FFFFFF"  ; 默认文本色为白色
    if (guiColor = "")
        guiColor := "#8E68EF"  ; 默认GUI色为紫色

    ; 更新索引,循环使用颜色组合
    currentColorIndex := currentColorIndex + 1
    if (currentColorIndex > 10) {
        currentColorIndex := 1
    }

    ; 保存当前索引到文件,以便下次启动时使用
    indexFile := A_ScriptDir . "\color_index.txt"
    FileDelete, %indexFile%
    FileAppend, %currentColorIndex%, %indexFile%
}

; 检查两个键是否同时按下并执行粘贴
CheckAndPaste() {
    global FullFileName ; 声明使用全局变量

    ; 直接执行粘贴操作
    bak := Clipboard
    Clipboard := FullFileName
    Sleep 50
    ;~ Send, ^v
    ;~ MsgBox, testtttt
    Send, {Backspace}
    Sleep 50
    Send, ^v
    Clipboard := bak
    ;~ SendRaw, %FullFileName%

    ; 只显示提示,不关闭窗口
    ToolTip, 已粘贴
    SetTimer, RemoveToolTip, 1000
}

move_Win()
{
    PostMessage, 0xA1, 2
}

写了个PPT网页来吹牛介绍, 吹牛还得是AI , 很多描述要我自己写, 绝对写不出的, 丢给AI真的压力全没了:https://2b5yfndy4b5cm.ok.kimi.link/