#NoEnv
#Persistent
SetTimer, GetCursor, 50
return
GetCursor:
t:=QPC()
Shape := GetCursorShape()
ToolTip, % "特征码:" Shape . "`n用时:" . QPC()-t . "ms"
return
Esc:: ExitApp
QPC() ; <==> A_TickCount
{
static f, c:=DllCall("QueryPerformanceFrequency", "Int*",f)
return (!DllCall("QueryPerformanceCounter","Int64*",c))*0+(c/f)*1000
}
GetCursorShape() ; 获取光标特征码 by nnrxin,FeiYue改进
{
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 ;输出特征码
}
#NoEnv
#Persistent
SetTimer, GetCursor, 50
return
GetCursor:
t:=QPC()
Shape := GetCursorShape()
ToolTip, % "特征码:" Shape . "`n用时:" . QPC()-t . "ms"
return
Esc:: ExitApp
QPC() ; <==> A_TickCount
{
static f, c:=DllCall("QueryPerformanceFrequency", "Int*",f)
return (!DllCall("QueryPerformanceCounter","Int64*",c))*0+(c/f)*1000
}
GetCursorShape() ; 获取光标特征码 by nnrxin,FeiYue改进
{
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 ;输出特征码
}
#NoEnv
#Persistent
SetTimer, GetCursor, 50
return
GetCursor:
t:=QPC()
Shape := GetCursorShape()
ToolTip, % "特征码:" Shape . "`n用时:" . QPC()-t . "ms"
return
Esc:: ExitApp
QPC() ; <==> A_TickCount
{
static f, c:=DllCall("QueryPerformanceFrequency", "Int*",f)
return (!DllCall("QueryPerformanceCounter","Int64*",c))*0+(c/f)*1000
}
GetCursorShape() ; 获取光标特征码 by nnrxin,FeiYue改进
{
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 ;输出特征码
}
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。
评论(0)