临时启动器

如果短时间内需要频繁打开或启动某程序可能需要不断切换到资源管理器, 这个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 个赞