if !A_IsAdmin
Run % "*RunAs " (s:=A_IsCompiled ? "" : A_AhkPath " /r ") """" A_ScriptFullPath """" (s ? "" : " /r")
SetWorkingDir %A_ScriptDir% ;要让脚本无条件使用它所在的文件夹作为工作目录,
#NoEnv
#InstallKeybdHook ;强制无条件安装键盘钩子.
#InstallMouseHook ;强制无条件安装鼠标钩子.
#KeyHistory 0
#UseHook
#MaxThreadsPerHotkey 1
#MaxHotkeysPerInterval 1000
ListLines, Off ;从历史记录中省略随后执行的脚本行.
SetKeyDelay, -1 ;按键无延时
#SingleInstance Force
#NoEnv
SetWorkingDir %A_ScriptDir%
SetBatchLines -1
Gui, 后台宏按键:Destroy ;移除当前名为jineng的窗口(如果它存在) 及其所有控件, 并释放其占用的内存和系统资源
Gui, 后台宏按键: New
Gui, 后台宏按键:+hWndh0 ;指定窗口句柄为变量h0
Gui, 后台宏按键:+AlwaysOnTop
Gui, 后台宏按键:Color, 0x98F5FF
Gui Font, Bold cFuchsia, 楷体
Gui, 后台宏按键:Add, Text, x8 y8 w61 h53 +Center, 触发键:`n`nF1
Gui , 后台宏按键:Add, Text, hWndh1 x80 y-5 w210 h64, `n 连发键:
ControlColor(h1, h0, 0x80FF00, 0xFF0000)
Gui Font, Bold cPurple
Gui , 后台宏按键:Add, Radio, hWndh2 x152 y0 w61 h28, 侧键1
ControlColor(h2, h0, 0x80FF00, 0xFF0000)
Gui , 后台宏按键:Add, Radio,hWndh3 x224 y0 w63 h28 Checked 1 vjiankaiguan,侧键2
ControlColor(h3, h0, 0x80FF00, 0xFF0000)
Gui , 后台宏按键:Add, Radio,hWndh4 x88 y32 w53 h28, 中键
ControlColor(h4, h0, 0x80FF00, 0xFF0000)
Gui , 后台宏按键:Add, Radio,hWndh5 x152 y32 w60 h28, 上滚键
ControlColor(h5, h0, 0x80FF00, 0xFF0000)
Gui , 后台宏按键:Add, Radio, hWndh6 x224 y32 w60 h28, 下滚键
ControlColor(h6, h0, 0x80FF00, 0xFF0000)
Gui , 后台宏按键:Font, s12 Bold Italic, 楷体
Gui , 后台宏按键:Add, Text, hWndh7 x8 y70 w86 h21 cred v按键状态, 按键已关闭 ;指定控件句柄h1
Gui , 后台宏按键:Font
Gui , 后台宏按键:Add, Text, x96 y64 w115 h28 +0x200, F11隐藏/显示
;Gui , 后台宏按键:Add, Picture, x178 y60 w35 h30, % A_WorkingDir "/OO.png"
Gui , 后台宏按键:Add, Text, x218 y64 w45 h25 +0x200, by 〇〇
Gui , 后台宏按键:Show, w300 h90, 后台宏按键
Gui, 后台宏按键:Submit,NoHide
;MsgBox %jiankaiguan%
aa:= ["x1", "x2", "MIDDLE", "WheelUp", "WheelDown"]
窗口hwnd := " "
xb := 0, yb :=0
F1::
Gui, 后台宏按键:Submit,NoHide
if (窗口hwnd = " ") ;若 变量 窗口hwnd 为空
{
窗口hwnd := WinExist("A") ;获得鼠标指向的活动窗口ID ,赋值给变量 窗口hwnd
}
if (onoff := !onoff)
{
GuiControl, 后台宏按键:Text, 按键状态, 按键已开启
ComObjCreate("SAPI.SpVoice").Speak("按键开启")
Settimer, LianFa, 50
}
else
{
GuiControl, 后台宏按键:Text, 按键状态, 按键已关闭
ComObjCreate("SAPI.SpVoice").Speak("按键关闭")
Settimer, LianFa, Off
窗口hwnd := " "
}
Return
LianFa: ;设置名为 连发 的标签
{
CoordMode,Mouse,Screen
MouseGetPos, x1, y1
if (窗口hwnd != " " And xb = 0 And yb = 0){
CoordMode,Mouse,Client ;Client [v1.1.05+]:坐标相对于活动窗口的工作区
MouseGetPos, x2, y2
xb := x1 -x2 , yb := y1 - y2 ;计算坐标偏差
}
x3 := x1 -xb , y3 := y1 - yb ;计算活动工作区坐标
;ToolTip % x1 A_Tab x2 A_Tab xb A_Tab y1 A_Tab y2
;ControlClick, , ahk_id %窗口hwnd% , ,% aa[jiankaiguan], , NA x%x3% y%y3% ;发送(XButton2: 第五个鼠标按钮)到窗口
ControlClick, , ahk_id %窗口hwnd% , ,% aa[jiankaiguan], , x%x3% y%y3%
Sleep 50
Return
}
F11::
XY := XY?0:1
If(XY=1)
{
Gui, 后台宏按键:Hide
}
Else
{
Gui, 后台宏按键:Show
}
Return
后台宏按键GuiEscape:
后台宏按键GuiClose:
ExitApp
;======================控件颜色函数===================================
ControlColor(Control, Window, bc := "", tc := "", Redraw := 1) {
a := {}
a["c"] := Control
a["g"] := Window
a["bc"] := (bc = "") ? "" : (((bc & 255) << 16) + (((bc >> 8) & 255) << 8) + (bc >> 16))
a["tc"] := (tc = "") ? "" : (((tc & 255) << 16) + (((tc >> 8) & 255) << 8) + (tc >> 16))
CC_WindowProc("Set", a, "", "")
If (Redraw) {
WinSet Redraw,, ahk_id %Control%
}
}
CC_WindowProc(hWnd, uMsg, wParam, lParam) {
Static Win := {}
If uMsg Between 0x132 And 0x138
If (Win[hWnd].HasKey(lParam)) {
If (tc := Win[hWnd, lParam, "tc"]) {
DllCall("gdi32.dll\SetTextColor", "Ptr", wParam, "UInt", tc)
}
If (bc := Win[hWnd, lParam, "bc"]) {
DllCall("gdi32.dll\SetBkColor", "Ptr", wParam, "UInt", bc)
}
Return Win[hWnd, lParam, "Brush"] ; Return the HBRUSH to notify the OS that we altered the HDC.
}
If (hWnd = "Set") {
a := uMsg
Win[a.g, a.c] := a
If (Win[a.g, a.c, "tc"] == "") And (Win[a.g, a.c, "bc"] == "")
Win[a.g].Remove(a.c, "")
If Not Win[a.g, "WindowProcOld"]
Win[a.g,"WindowProcOld"] := DllCall("SetWindowLong" . (A_PtrSize == 8 ? "Ptr" : "")
, "Ptr", a.g, "Int", -4, "Ptr", RegisterCallback("CC_WindowProc", "", 4), "UPtr")
If Win[a.g, a.c, "Brush"]
DllCall("gdi32.dll\DeleteObject", "Ptr", Brush)
If (Win[a.g, a.c, "bc"] != "")
Win[a.g, a.c, "Brush"] := DllCall("gdi32.dll\CreateSolidBrush", "UInt", a.bc, "UPtr")
Return
}
Return DllCall("CallWindowProc", "Ptr", Win[hWnd, "WindowProcOld"], "Ptr", hWnd, "UInt", uMsg, "Ptr", wParam, "Ptr", lParam, "Ptr")
}
;=============================================================================================
学习一下
谢谢提供思路,借鉴一下
谢谢提供思路,借鉴一下