; 通过对当前光标状态的判断,来切换上下左右键的功能
#NoEnv
; #NoTrayIcon ; 可以关闭托盘图标显示
#SingleInstance Force
SetBatchLines -1
Return
F1::MsgBox % "获取当前光标状态:" GetCursorShape()
; 数字小键盘的上下左右
$Numpad2::
GetCaret(x, y)
if (GetCursorShape()!=163200) and (x!=0) and (y!=0) {
Send {Down}
return
}
Send {Numpad2}
return
$Numpad4::
GetCaret(x, y)
if (GetCursorShape()!=163200) and (x!=0) and (y!=0) {
Send {Left}
return
}
Send {Numpad4}
return
$Numpad6::
GetCaret(x, y)
if (GetCursorShape()!=163200) and (x!=0) and (y!=0) {
Send {Right}
return
}
Send {Numpad6}
return
$Numpad8::
GetCaret(x, y)
if (GetCursorShape()!=163200) and (x!=0) and (y!=0) {
Send {Up}
return
}
Send {Numpad8}
return
GetCursorShape() {
static Ptr:=(A_PtrSize ? "Ptr":"UInt"), PtrSize:=(A_PtrSize=8 ? 8:4)
VarSetCapacity(CursorInfo, 40, 0) ; 创建 光标信息 结构(申请空间大一点没关系)
NumPut(16+PtrSize, CursorInfo, 0, "int") ; 写入 结构 的大小cbSize(必须准确)
DllCall("GetCursorInfo", Ptr,&CursorInfo) ; 获取光标信息填入结构
bShow :=NumGet(CursorInfo, 4, "int") ; 读取光标状态 flags字段
hCursor :=NumGet(CursorInfo, 8, Ptr) ; 读取光标句柄
if (!bShow)
return 0
VarSetCapacity(IconInfo, 40, 0) ; 创建 图标信息 结构(申请空间大一点没关系)
DllCall("GetIconInfo", Ptr,hCursor, Ptr,&IconInfo) ;获取 图标信息填入结构
hBMMask :=NumGet(IconInfo, 8+PtrSize, Ptr)
hBMColor:=NumGet(IconInfo, 8+PtrSize*2, Ptr)
MaskCode:=ColorCode:=0, size:=16*16
VarSetCapacity(lpvMaskBits, size//4, 0) ; 创造 数组-掩码图信息,每个字节含4个掩码位
DllCall("GetBitmapBits", Ptr,hBMMask, "int",size//4, Ptr,&lpvMaskBits)
Loop, % size//4
MaskCode += NumGet(lpvMaskBits, A_Index-1, "UChar")
if (hBMColor)
{
VarSetCapacity(lpvColorBits, size*4, 0) ; 创造 数组-彩色图信息,每个彩色位占4个字节
DllCall("GetBitmapBits", Ptr,hBMColor, "int",size*4, Ptr,&lpvColorBits)
Loop, % size ; 只读取彩色位中的绿色分量
ColorCode += NumGet(lpvColorBits, A_Index*4-3, "UChar")
}
DllCall("DeleteObject", Ptr,hBMMask) ; *清理掩码图
DllCall("DeleteObject", Ptr,hBMColor) ; *清理彩色图
return MaskCode . ColorCode ;输出特征码
}
GetCaret(Byref CaretX="", Byref CaretY="") {
static init
CoordMode, Caret, Screen
CaretX:=A_CaretX, CaretY:=A_CaretY
if (!CaretX or !CaretY)
Try {
if (!init)
init:=DllCall("LoadLibrary","Str","oleacc","Ptr")
VarSetCapacity(IID,16), idObject:=OBJID_CARET:=0xFFFFFFF8
, NumPut(idObject==0xFFFFFFF0?0x0000000000020400:0x11CF3C3D618736E0, IID, "Int64")
, NumPut(idObject==0xFFFFFFF0?0x46000000000000C0:0x719B3800AA000C81, IID, 8, "Int64")
if DllCall("oleacc\AccessibleObjectFromWindow", "Ptr",WinExist("A"), "UInt",idObject, "Ptr",&IID, "Ptr*",pacc)=0
{
Acc:=ComObject(9,pacc,1), ObjAddRef(pacc)
, Acc.accLocation(ComObj(0x4003,&x:=0), ComObj(0x4003,&y:=0)
, ComObj(0x4003,&w:=0), ComObj(0x4003,&h:=0), ChildId:=0)
, CaretX:=NumGet(x,0,"int"), CaretY:=NumGet(y,0,"int")
}
}
return {x:CaretX, y:CaretY}
}
; 通过对当前光标状态的判断,来切换上下左右键的功能
#NoEnv
; #NoTrayIcon ; 可以关闭托盘图标显示
#SingleInstance Force
SetBatchLines -1
Return
F1::MsgBox % "获取当前光标状态:" GetCursorShape()
; 数字小键盘的上下左右
$Numpad2::
GetCaret(x, y)
if (GetCursorShape()!=163200) and (x!=0) and (y!=0) {
Send {Down}
return
}
Send {Numpad2}
return
$Numpad4::
GetCaret(x, y)
if (GetCursorShape()!=163200) and (x!=0) and (y!=0) {
Send {Left}
return
}
Send {Numpad4}
return
$Numpad6::
GetCaret(x, y)
if (GetCursorShape()!=163200) and (x!=0) and (y!=0) {
Send {Right}
return
}
Send {Numpad6}
return
$Numpad8::
GetCaret(x, y)
if (GetCursorShape()!=163200) and (x!=0) and (y!=0) {
Send {Up}
return
}
Send {Numpad8}
return
GetCursorShape() {
static Ptr:=(A_PtrSize ? "Ptr":"UInt"), PtrSize:=(A_PtrSize=8 ? 8:4)
VarSetCapacity(CursorInfo, 40, 0) ; 创建 光标信息 结构(申请空间大一点没关系)
NumPut(16+PtrSize, CursorInfo, 0, "int") ; 写入 结构 的大小cbSize(必须准确)
DllCall("GetCursorInfo", Ptr,&CursorInfo) ; 获取光标信息填入结构
bShow :=NumGet(CursorInfo, 4, "int") ; 读取光标状态 flags字段
hCursor :=NumGet(CursorInfo, 8, Ptr) ; 读取光标句柄
if (!bShow)
return 0
VarSetCapacity(IconInfo, 40, 0) ; 创建 图标信息 结构(申请空间大一点没关系)
DllCall("GetIconInfo", Ptr,hCursor, Ptr,&IconInfo) ;获取 图标信息填入结构
hBMMask :=NumGet(IconInfo, 8+PtrSize, Ptr)
hBMColor:=NumGet(IconInfo, 8+PtrSize*2, Ptr)
MaskCode:=ColorCode:=0, size:=16*16
VarSetCapacity(lpvMaskBits, size//4, 0) ; 创造 数组-掩码图信息,每个字节含4个掩码位
DllCall("GetBitmapBits", Ptr,hBMMask, "int",size//4, Ptr,&lpvMaskBits)
Loop, % size//4
MaskCode += NumGet(lpvMaskBits, A_Index-1, "UChar")
if (hBMColor)
{
VarSetCapacity(lpvColorBits, size*4, 0) ; 创造 数组-彩色图信息,每个彩色位占4个字节
DllCall("GetBitmapBits", Ptr,hBMColor, "int",size*4, Ptr,&lpvColorBits)
Loop, % size ; 只读取彩色位中的绿色分量
ColorCode += NumGet(lpvColorBits, A_Index*4-3, "UChar")
}
DllCall("DeleteObject", Ptr,hBMMask) ; *清理掩码图
DllCall("DeleteObject", Ptr,hBMColor) ; *清理彩色图
return MaskCode . ColorCode ;输出特征码
}
GetCaret(Byref CaretX="", Byref CaretY="") {
static init
CoordMode, Caret, Screen
CaretX:=A_CaretX, CaretY:=A_CaretY
if (!CaretX or !CaretY)
Try {
if (!init)
init:=DllCall("LoadLibrary","Str","oleacc","Ptr")
VarSetCapacity(IID,16), idObject:=OBJID_CARET:=0xFFFFFFF8
, NumPut(idObject==0xFFFFFFF0?0x0000000000020400:0x11CF3C3D618736E0, IID, "Int64")
, NumPut(idObject==0xFFFFFFF0?0x46000000000000C0:0x719B3800AA000C81, IID, 8, "Int64")
if DllCall("oleacc\AccessibleObjectFromWindow", "Ptr",WinExist("A"), "UInt",idObject, "Ptr",&IID, "Ptr*",pacc)=0
{
Acc:=ComObject(9,pacc,1), ObjAddRef(pacc)
, Acc.accLocation(ComObj(0x4003,&x:=0), ComObj(0x4003,&y:=0)
, ComObj(0x4003,&w:=0), ComObj(0x4003,&h:=0), ChildId:=0)
, CaretX:=NumGet(x,0,"int"), CaretY:=NumGet(y,0,"int")
}
}
return {x:CaretX, y:CaretY}
}
; 通过对当前光标状态的判断,来切换上下左右键的功能
#NoEnv
; #NoTrayIcon ; 可以关闭托盘图标显示
#SingleInstance Force
SetBatchLines -1
Return
F1::MsgBox % "获取当前光标状态:" GetCursorShape()
; 数字小键盘的上下左右
$Numpad2::
GetCaret(x, y)
if (GetCursorShape()!=163200) and (x!=0) and (y!=0) {
Send {Down}
return
}
Send {Numpad2}
return
$Numpad4::
GetCaret(x, y)
if (GetCursorShape()!=163200) and (x!=0) and (y!=0) {
Send {Left}
return
}
Send {Numpad4}
return
$Numpad6::
GetCaret(x, y)
if (GetCursorShape()!=163200) and (x!=0) and (y!=0) {
Send {Right}
return
}
Send {Numpad6}
return
$Numpad8::
GetCaret(x, y)
if (GetCursorShape()!=163200) and (x!=0) and (y!=0) {
Send {Up}
return
}
Send {Numpad8}
return
GetCursorShape() {
static Ptr:=(A_PtrSize ? "Ptr":"UInt"), PtrSize:=(A_PtrSize=8 ? 8:4)
VarSetCapacity(CursorInfo, 40, 0) ; 创建 光标信息 结构(申请空间大一点没关系)
NumPut(16+PtrSize, CursorInfo, 0, "int") ; 写入 结构 的大小cbSize(必须准确)
DllCall("GetCursorInfo", Ptr,&CursorInfo) ; 获取光标信息填入结构
bShow :=NumGet(CursorInfo, 4, "int") ; 读取光标状态 flags字段
hCursor :=NumGet(CursorInfo, 8, Ptr) ; 读取光标句柄
if (!bShow)
return 0
VarSetCapacity(IconInfo, 40, 0) ; 创建 图标信息 结构(申请空间大一点没关系)
DllCall("GetIconInfo", Ptr,hCursor, Ptr,&IconInfo) ;获取 图标信息填入结构
hBMMask :=NumGet(IconInfo, 8+PtrSize, Ptr)
hBMColor:=NumGet(IconInfo, 8+PtrSize*2, Ptr)
MaskCode:=ColorCode:=0, size:=16*16
VarSetCapacity(lpvMaskBits, size//4, 0) ; 创造 数组-掩码图信息,每个字节含4个掩码位
DllCall("GetBitmapBits", Ptr,hBMMask, "int",size//4, Ptr,&lpvMaskBits)
Loop, % size//4
MaskCode += NumGet(lpvMaskBits, A_Index-1, "UChar")
if (hBMColor)
{
VarSetCapacity(lpvColorBits, size*4, 0) ; 创造 数组-彩色图信息,每个彩色位占4个字节
DllCall("GetBitmapBits", Ptr,hBMColor, "int",size*4, Ptr,&lpvColorBits)
Loop, % size ; 只读取彩色位中的绿色分量
ColorCode += NumGet(lpvColorBits, A_Index*4-3, "UChar")
}
DllCall("DeleteObject", Ptr,hBMMask) ; *清理掩码图
DllCall("DeleteObject", Ptr,hBMColor) ; *清理彩色图
return MaskCode . ColorCode ;输出特征码
}
GetCaret(Byref CaretX="", Byref CaretY="") {
static init
CoordMode, Caret, Screen
CaretX:=A_CaretX, CaretY:=A_CaretY
if (!CaretX or !CaretY)
Try {
if (!init)
init:=DllCall("LoadLibrary","Str","oleacc","Ptr")
VarSetCapacity(IID,16), idObject:=OBJID_CARET:=0xFFFFFFF8
, NumPut(idObject==0xFFFFFFF0?0x0000000000020400:0x11CF3C3D618736E0, IID, "Int64")
, NumPut(idObject==0xFFFFFFF0?0x46000000000000C0:0x719B3800AA000C81, IID, 8, "Int64")
if DllCall("oleacc\AccessibleObjectFromWindow", "Ptr",WinExist("A"), "UInt",idObject, "Ptr",&IID, "Ptr*",pacc)=0
{
Acc:=ComObject(9,pacc,1), ObjAddRef(pacc)
, Acc.accLocation(ComObj(0x4003,&x:=0), ComObj(0x4003,&y:=0)
, ComObj(0x4003,&w:=0), ComObj(0x4003,&h:=0), ChildId:=0)
, CaretX:=NumGet(x,0,"int"), CaretY:=NumGet(y,0,"int")
}
}
return {x:CaretX, y:CaretY}
}
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。
评论(0)