
/*
基于标签矩阵的无鼠标屏幕点击器
按 右Ctrl键 显示和关闭标签矩阵
标签矩阵显示时,使用使用方向键进行移动, 配合shift键和ctrl键可以降低移动速度(要么shift+方向, 要么shift+ctrl+方向)
标签矩阵显示时, 连续输入标签对应的两个字母,鼠标将会移动到对应标签的左上角位置进行点击
基于 AHKCoordGrid v2.5.1 https://www.autohotkey.com/boards/viewtopic.php?t=51201 修改
*/
#SingleInstance
SetBatchLines, -1
SetWinDelay, -1
DetectHiddenWindows, On
; AHK脚本以管理员权限自启
if !A_IsAdmin && !RegExMatch(_:=DllCall("GetCommandLine", "Str"), " /restart(?!\S)")
RunWait % "*RunAs " RegExReplace(_, "^\"".*?\""\K|^\S*\K", " /restart")
flag_zimu_up := 1
VerticalScale := 1
; 标签网格的行数列数,越大越密集,默认26*26
numberOfRows := 26
; numberOfRows := 6
numberOfCols := 26
; numberOfCols := 6
GridHeight := VerticalScale * A_ScreenHeight
GridWidth := A_ScreenWidth
rowSpacing := GridHeight / numberOfRows
colSpacing := GridWidth / numberOfCols
x_offset :=colSpacing/2 * 0.6
y_offset :=rowSpacing/2 * 0.6
AscA := 97
KeyArray := ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
#IfWinNotActive CoordGrid
#IfWinNotExist CoordGrid
global VerticalScale, numberOfRows, numberOfCols, GridHeight, GridWidth, rowSpacing, colSpacing, KeyArray
global hGui,flag_zimu_up
RControl::
rowCounter := 0
Loop {
rowYCoord := rowCounter * rowSpacing + y_offset
rowYCoordAlpha := KeyArray[rowCounter+1]
if(flag_zimu_up){
StringUpper, rowYCoordAlpha, rowYCoordAlpha
}
colCounter := 0
Loop {
colXCoord := colCounter * colSpacing + x_offset
colXCoordAlpha := KeyArray[colCounter+1]
if(flag_zimu_up){
StringUpper, colXCoordAlpha, colXCoordAlpha
}
gui, add, text, w15 h15 x%colXCoord% y%rowYCoord% border 0x201 readonly -Background cRed, %colXCoordAlpha%%rowYCoordAlpha%
colCounter := colCounter + 1
}
Until colCounter = numberOfcols
rowCounter := rowCounter + 1
}
Until rowCounter = numberOfRows
Gui, Color, 000115
Gui, Show, W1920 H1050 NoActivate, CoordGrid
Gui -Caption +AlwaysOnTop
Gui +hwndhGui
WinSet, Transcolor, 000115, CoordGrid
Return
#IfWinNotExist
#IfWinNotActive
#if WinExist("CoordGrid") and isGuiHide()
RControl::
winmove , CoordGrid,,0,0
Gui Show,NA
; KeyWait, RControl
Return
#if WinExist("CoordGrid") and !isGuiHide()
RControl::
Gui Hide
; KeyWait, RControl
Return
; 使用方向键移动网格,加上shift键减速,加ctrl键再减速
left::
WinGetPos , currentposX, currentposY,,, CoordGrid
winmove, CoordGrid,, % currentposX-10
return
right::
WinGetPos , currentposX, currentposY,,, CoordGrid
winmove, CoordGrid,, % currentposX+10
return
Up::
WinGetPos , currentposX, currentposY,,, CoordGrid
winmove, CoordGrid,, , % currentposY-10
return
Down::
WinGetPos , currentposX, currentposY,,, CoordGrid
winmove, CoordGrid,, , % currentposY+10
return
+left::
WinGetPos , currentposX, currentposY,,, CoordGrid
winmove, CoordGrid,, % currentposX-5
return
+right::
WinGetPos , currentposX, currentposY,,, CoordGrid
winmove, CoordGrid,, % currentposX+5
return
+Up::
WinGetPos , currentposX, currentposY,,, CoordGrid
winmove, CoordGrid,, , % currentposY-5
return
+Down::
WinGetPos , currentposX, currentposY,,, CoordGrid
winmove, CoordGrid,, , % currentposY+5
return
+^left::
WinGetPos , currentposX, currentposY,,, CoordGrid
winmove, CoordGrid,, % currentposX-2
return
+^right::
WinGetPos , currentposX, currentposY,,, CoordGrid
winmove, CoordGrid,, % currentposX+2
return
+^Up::
WinGetPos , currentposX, currentposY,,, CoordGrid
winmove, CoordGrid,, , % currentposY-2
return
+^Down::
WinGetPos , currentposX, currentposY,,, CoordGrid
winmove, CoordGrid,, , % currentposY+2
return
; 在一定时间内输入两个字母,则鼠标移动到相应的位置进行点击
a:: gosub, RunKey
b:: gosub, RunKey
c:: gosub, RunKey
d:: gosub, RunKey
e:: gosub, RunKey
f:: gosub, RunKey
g:: gosub, RunKey
h:: gosub, RunKey
i:: gosub, RunKey
j:: gosub, RunKey
k:: gosub, RunKey
l:: gosub, RunKey
m:: gosub, RunKey
n:: gosub, RunKey
o:: gosub, RunKey
p:: gosub, RunKey
q:: gosub, RunKey
r:: gosub, RunKey
s:: gosub, RunKey
t:: gosub, RunKey
u:: gosub, RunKey
v:: gosub, RunKey
w:: gosub, RunKey
x:: gosub, RunKey
y:: gosub, RunKey
z:: gosub, RunKey
Runkey:
if (winc_presses > 0) {
winc_presses += 1
Return
}
winc_presses = 1
SetTimer, TheKey, 1000
Return
TheKey:
SetTimer, TheKey, off
if (winc_presses = 2) {
NavigateToCoord()
}
winc_presses = 0
Return
; 光标移动到相应的标签位置(左上角)进行点击
NavigateToCoord() {
CoordMode, Mouse, Screen
global VeraaticalScale, numberOfRows, numberOfCols, GridHeight, GridWidth, rowSpacing, colSpacing
global x_offset,y_offset
XCoordInput := SubStr(A_PriorHotkey,1,1)
YCoordInput := SubStr(A_ThisHotkey,1,1)
XCoordToUse := ConvertInputCoord(XcoordInput, "X")
YCoordToUse := ConvertInputCoord(YcoordInput, "Y")
XCoord := (XCoordToUse) * colSpacing + x_offset
YCoord := (YCoordToUse) * rowSpacing + y_offset
WinGetPos , currentposX, currentposY,,, CoordGrid
MouseMove, % currentposX+XCoord, % currentposY+YCoord,0
sleep, 100
Gui Hide
sleep, 100
Click
Return
}
ConvertInputCoord(coordInput, XorY) {
global AscA
coordAsc := Asc(coordInput)
if (XorY = "X") {
coordToUse := coordAsc - AscA
} else {
coordToUse := coordAsc - AscA
}
coordToUse := floor(coordToUse)
Return coordToUse
}
#if
; 全局快捷键
!F11::Suspend
!F10::Edit
!F12::Reload
; run,"%A_AhkPath%" /restart /cp65001 "%A_ScriptFullPath%"
return
isGuiHide(){
global hGui
WinGet, Style, Style, ahk_id %hGui%
If (Style & 0x10000000){ ; 0x10000000 is WS_VISIBLE
Return 0
} Else {
Return 1
}
}
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。

评论(1)
我也写过这个功能,但是还是没有鼠标方便,弃了