ahk悬浮工具栏

天天用ahk都需要快速测试脚本,快速查帮助,有时候卡键了需要恢复一下,还有就是看到有有用的代码快速存一个文件打开编辑器编辑

所以做了个ahk工具栏

给大家看看效果

ahk悬浮工具栏

global path:="C:\Users\Administrator\Desktop"
global EditorPath:="C:\SoftDir\VSCode\Code.exe"
ahk_tools:
IniRead, Gui_x, % A_WorkingDir "\Set.ini", GuiHotkey, Gui_x
IniRead, Gui_y, % A_WorkingDir "\Set.ini", GuiHotkey, Gui_y
Gui_x := ((Gui_x = "ERROR") || !(Gui_x)) ? "x" RegExReplace(A_ScreenWidth/2,"\..+") : Gui_x
Gui_y := ((Gui_y = "ERROR") || !(Gui_y)) ? "y" RegExReplace(A_ScreenHeight/2,"\..+") : Gui_y
Gui, a:+Owner -Caption +AlwaysOnTop +HwndZYGui border -DPIScale +E0x08000000
Gui, a:font, s10, 微软雅黑
Gui, a:Margin,6,4
; Gui,a:Add, Picture,gHide , .\tb.png
Gui, a:Add, Text, y0 gsave,save
Gui, a:Add, Text, x+5, |
Gui, a:Add, Text, x+5 grun,run
Gui, a:Add, Text, x+5, |
Gui, a:Add, Text, x+5 ghelp,help
Gui, a:Add, Text, x+5, |
Gui, a:Add, Text, x+5 gstop,stop
Gui, a:Add, Text, x+5, |
Gui, a:Add, Text, x+5 gup,up
Gui, a:show,%Gui_x% %Gui_y%
OnMessage(0x201,"pos")
return
pos(){
	Global ZYGui
	; 用于移动Gui
    PostMessage, 0xA1, 2
	; 等待左键释放
	KeyWait, LButton
	; 获取ImTipGui信息
	WinGetpos, Gui_x, Gui_y, Gui_w, Gui_h, ahk_id %ZYGui%
	; 记录相应信息到ini
	IniWrite, % "x" Gui_x, % A_WorkingDir "\Set.ini", GuiHotkey, Gui_x
	IniWrite, % "y" Gui_y, % A_WorkingDir "\Set.ini", GuiHotkey, Gui_y
}

save:
ahk("save")
return
run:
ahk("run")
return
stop:
ahk("stop")
return
up:
ahk("up")
return

ahk(which){
global
copy()
switch which{
    case "save":
    InputBox, name,输入保存文件名, 输入要保存文件的文件名不含后缀
    FileAppend, % Clipboard, % path "\" name ".ahk", UTF-8
    run % EditorPath " " path "\" name ".ahk"
    case "run":
    Exec(Clipboard, 1)
    case "stop":
    Exec("", 1)
    case "up":
    gosub SolveKeyProblem
}
return
}

help:
copy()
Loop, Read, wd.txt
{
	If (Trim(Clipboard," ") = RegExReplace(A_LoopReadLine, "[()]*<<>>.+"))
		mbUrl := RegExReplace(A_LoopReadLine, "^.+<<>>")
}
If (mbUrl)
{
	mubiao := "C:\AHK\SciTE\中文帮助\AutoHotkey_CN.chm::" mbUrl
	if (WinExist("ahk_class HH Parent"))
		WinClose, ahk_class HH Parent
	run, "hh.exe" "%mubiao%"
	mbUrl := ""
}
return

; ==================================================================================
    ; dbgba 的新建进程 
    ; ==================================================================================
    Exec(s, flag="Default") {
        SetBatchLines, -1
        SetWorkingDir %A_ScriptDir%
        DetectHiddenWindows, On
        WinGet, NewPID, PID, <<ExecNew%flag%>> ahk_class AutoHotkeyGUI
        PostMessage, 0x111, 65307,,, %A_ScriptDir%\* ahk_pid %NewPID%
        add=`nflag=<<ExecNew%flag%>>`n
        (%
            Gui, Gui_Flag_Gui: Show, Hide, %flag%
            DllCall("RegisterShellHookWindow", "Ptr", A_ScriptHwnd)
            OnMessage(DllCall("RegisterWindowMessage", "Str", "ShellHook"), "ShellEvent")
            ShellEvent(wParam, lParam) {
                DetectHiddenWindows, On
                if !WinExist("HostProcessName")
                    ExitApp
            }
        )
        s:=add "`n" s "`nExitApp"
        s:=RegExReplace(s, "HostProcessName", "ahk_pid "DllCall("GetCurrentProcessId"))
        exec := ComObjCreate("WScript.Shell").Exec(A_AhkPath " /ErrorStdOut /f *")
        exec.StdIn.Write(s)
        exec.StdIn.Close()
    }
SolveKeyProblem:
ToolTip,try to up the key
Gosub,WhichButton
Gosub, GetUpAll
Gosub, ReloadAll
ToolTip
Return

WhichButton:
if GetKeyState("Shift")
    MsgBox At least one Shift key is down.
if GetKeyState("Ctrl")
    MsgBox At least one Ctrl key is down.
if GetKeyState("Alt")
    MsgBox At least one Alt key is down.
if GetKeyState("Capslock")
    MsgBox At least one Capslock key is down.
Return
GetUpAll:
SendInput, {Shift up}{Ctrl Up}{CapsLock up}{Alt up}{Space Up}
Loop 26{
	str:= Chr(Asc("a") + A_Index - 1)
    SendInput, {%str% up}
}
loop 10{
num:=A_Index-1
SendInput, {%num% up}
}
Return
ReloadAll:
DetectHiddenWindows On
if !(A_IsAdmin || InStr(DllCall("GetCommandLine", "str"), ".exe"" /r"))
	Run % "*RunAs " (s:=A_IsCompiled ? "" : A_AhkPath " /r ") """" A_ScriptFullPath """" (s ? "" : " /r")
selfPID := DllCall("GetCurrentProcessId")
	WinGet, id, List, ahk_class AutoHotkey
	Loop, %id% {
		this_id := id%A_Index%
		WinGet, this_pid, PID, ahk_id %this_id%
		if (this_pid != selfPID)
		{
			WinGetTitle, this_title, ahk_id %this_id%
				fPath := RegExReplace(this_title, " - AutoHotkey v[\d.]+$")
                PostMessage, 0x111, 65303,,, % fPath " ahk_pid " this_pid
		}
    }
    DetectHiddenWindows Off
    Return


 

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

给TA捐赠
共{{data.count}}人
人已捐赠
其他

easyini库详解(3)

2022-9-19 10:05:26

其他

影子万能键阉割版移植kbl输入法切换

2022-9-21 10:39:54

3 条回复 A文章作者 M管理员
  1. 蜜獾哥

    一个僵尸影子工具栏被你玩出花

个人中心
购物车
优惠劵
有新私信 私信列表
搜索