![使鼠标指针在空闲时不可见](https://linux22.com/image/1220216/%E4%BD%BF%E9%BC%A0%E6%A0%87%E6%8C%87%E9%92%88%E5%9C%A8%E7%A9%BA%E9%97%B2%E6%97%B6%E4%B8%8D%E5%8F%AF%E8%A7%81.png)
有没有办法让鼠标指针在计算机空闲时消失?如果该解决方案可以在 Windows XP 和 Windows 7 中工作,那就太好了。
答案1
SystemCursor("Init")
SetTimer, CheckIdle, 250
return
CheckIdle:
TimeIdle := A_TimeIdlePhysical // 1000
if TimeIdle >= 3
{
SystemCursor("Off")
}
else
{
SystemCursor("On")
}
return
#Persistent
OnExit, ShowCursor ; Ensure the cursor is made visible when the script exits.
return
ShowCursor:
SystemCursor("On")
ExitApp
SystemCursor(OnOff=1) ; INIT = "I","Init"; OFF = 0,"Off"; TOGGLE = -1,"T","Toggle"; ON = others
{
static AndMask, XorMask, $, h_cursor
,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 ; system cursors
, b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13 ; blank cursors
, h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13 ; handles of default cursors
if (OnOff = "Init" or OnOff = "I" or $ = "") ; init when requested or at first call
{
$ = h ; active default cursors
VarSetCapacity( h_cursor,4444, 1 )
VarSetCapacity( AndMask, 32*4, 0xFF )
VarSetCapacity( XorMask, 32*4, 0 )
system_cursors = 32512,32513,32514,32515,32516,32642,32643,32644,32645,32646,32648,32649,32650
StringSplit c, system_cursors, `,
Loop %c0%
{
h_cursor := DllCall( "LoadCursor", "uint",0, "uint",c%A_Index% )
h%A_Index% := DllCall( "CopyImage", "uint",h_cursor, "uint",2, "int",0, "int",0, "uint",0 )
b%A_Index% := DllCall("CreateCursor","uint",0, "int",0, "int",0
, "int",32, "int",32, "uint",&AndMask, "uint",&XorMask )
}
}
if (OnOff = 0 or OnOff = "Off" or $ = "h" and (OnOff < 0 or OnOff = "Toggle" or OnOff = "T"))
$ = b ; use blank cursors
else
$ = h ; use the saved cursors
Loop %c0%
{
h_cursor := DllCall( "CopyImage", "uint",%$%%A_Index%, "uint",2, "int",0, "int",0, "uint",0 )
DllCall( "SetSystemCursor", "uint",h_cursor, "uint",c%A_Index% )
}
}
答案2
尝试这个:光标隐藏器
答案3
答案4
8 年后约瑟夫答案仍然很好,并且可以在 AHK 中使用!但我让它变得更好了……在我看来。
我添加了鼠标检查,因此光标仅在移动时才会再次显示。确实,我可以添加其他鼠标事件,例如点击,但由于光标被隐藏,我认为这太过极端,不值得费心。如果您需要,您可以自行添加 :)
我所做的更改是将其移至#Persistent
顶部,因为它是全局的并且无论它是什么都存在于整个脚本中。
在自动执行部分中添加CoordMode, Mouse, Screen
和,并在进入空闲状态时再次添加。在每个上设置和在鼠标移动时将变量与进行比较。MouseGetPos, ix, iy
MouseGetPos, ix, iy
MouseGetPos, cx, cy
CheckIdle
if (cx != ix or cy != iy)
#Persistent
CoordMode, Mouse, Screen
MouseGetPos, ix, iy
SystemCursor("Init")
SetTimer, CheckIdle, 250
return
CheckIdle:
MouseGetPos, cx, cy
TimeIdle := A_TimeIdlePhysical // 1000
if (TimeIdle >= 3)
{
MouseGetPos, ix, iy
SystemCursor("Off")
}
else if (cx != ix or cy != iy)
{
SystemCursor("On")
}
return
OnExit, ShowCursor ; Ensure the cursor is made visible when the script exits.
return
ShowCursor:
SystemCursor("On")
ExitApp
SystemCursor(OnOff=1) ; INIT = "I","Init"; OFF = 0,"Off"; TOGGLE = -1,"T","Toggle"; ON = others
{
static AndMask, XorMask, $, h_cursor
,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 ; system cursors
, b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13 ; blank cursors
, h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13 ; handles of default cursors
if (OnOff = "Init" or OnOff = "I" or $ = "") ; init when requested or at first call
{
$ = h ; active default cursors
VarSetCapacity( h_cursor,4444, 1 )
VarSetCapacity( AndMask, 32*4, 0xFF )
VarSetCapacity( XorMask, 32*4, 0 )
system_cursors = 32512,32513,32514,32515,32516,32642,32643,32644,32645,32646,32648,32649,32650
StringSplit c, system_cursors, `,
Loop %c0%
{
h_cursor := DllCall( "LoadCursor", "uint",0, "uint",c%A_Index% )
h%A_Index% := DllCall( "CopyImage", "uint",h_cursor, "uint",2, "int",0, "int",0, "uint",0 )
b%A_Index% := DllCall("CreateCursor","uint",0, "int",0, "int",0
, "int",32, "int",32, "uint",&AndMask, "uint",&XorMask )
}
}
if (OnOff = 0 or OnOff = "Off" or $ = "h" and (OnOff < 0 or OnOff = "Toggle" or OnOff = "T"))
$ = b ; use blank cursors
else
$ = h ; use the saved cursors
Loop %c0%
{
h_cursor := DllCall( "CopyImage", "uint",%$%%A_Index%, "uint",2, "int",0, "int",0, "uint",0 )
DllCall( "SetSystemCursor", "uint",h_cursor, "uint",c%A_Index% )
}
}