-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
827899f
commit caab73c
Showing
10 changed files
with
95 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System.Runtime.InteropServices; | ||
|
||
namespace ComputerLock.Hooks; | ||
internal class MouseHook | ||
{ | ||
[DllImport("user32.dll")] | ||
private static extern int ShowCursor(bool bShow); | ||
|
||
private int _cursorCount = 0; | ||
|
||
/// <summary> | ||
/// 隐藏鼠标光标。 | ||
/// </summary> | ||
public void HideCursor() | ||
{ | ||
if (_cursorCount >= 0) // 如果光标可见 | ||
{ | ||
_cursorCount = ShowCursor(false); // 隐藏光标 | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// 显示鼠标光标。 | ||
/// </summary> | ||
public void ShowCursor() | ||
{ | ||
if (_cursorCount < 0) // 如果光标不可见 | ||
{ | ||
_cursorCount = ShowCursor(true); // 显示光标 | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// 重置光标显示状态。 | ||
/// </summary> | ||
public void ResetCursorState() | ||
{ | ||
while (_cursorCount < 0) // 如果光标隐藏 | ||
{ | ||
ShowCursor(true); // 显示光标 | ||
_cursorCount++; | ||
} | ||
|
||
while (_cursorCount > 0) // 如果光标多次显示 | ||
{ | ||
ShowCursor(false); // 隐藏光标 | ||
_cursorCount--; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters