跳到主要内容

github/tai

公开

Tai · Windows 软件与网站使用时长统计。上游 Planshit/Tai 的源码镜像,非灵栈原创;MIT 许可。来源:https://github.com/Planshit/Tai 。本次为手动同步,暂不提供安装包。

提交记录
修改Core/Librarys/Win32API.cs+53 −3看文件
@@ -63,8 +63,8 @@ namespace Core.Librarys
6363 public const UInt32 PROCESS_QUERY_INFORMATION = 0x400;
6464 public const UInt32 PROCESS_VM_READ = 0x010;
6565
66删除: private const uint WINEVENT_OUTOFCONTEXT = 0;
67删除: private const uint EVENT_SYSTEM_FOREGROUND = 3;
66新增: //private const uint WINEVENT_OUTOFCONTEXT = 0;
67新增: //private const uint EVENT_SYSTEM_FOREGROUND = 3;
6868 public static string UWP_AppName(IntPtr hWnd, uint pID)
6969 {
7070 WINDOWINFO windowinfo = new WINDOWINFO();
@@ -117,8 +117,26 @@ namespace Core.Librarys
117117 /// <returns></returns>
118118 [DllImport("user32.dll", SetLastError = true)]
119119 [return: MarshalAs(UnmanagedType.Bool)]
120删除: public static extern bool GetCursorPos(out Point lpPoint);
120新增: private static extern bool GetCursorPos(out POINT lpPoint);
121121
122新增: [StructLayout(LayoutKind.Sequential)]
123新增: public struct POINT
124新增: {
125新增: public int X;
126新增: public int Y;
127新增:
128新增: public static implicit operator Point(POINT point)
129新增: {
130新增: return new Point(point.X, point.Y);
131新增: }
132新增: }
133新增:
134新增: public static Point GetCursorPosition()
135新增: {
136新增: POINT lpPoint;
137新增: GetCursorPos(out lpPoint);
138新增: return lpPoint;
139新增: }
122140
123141 #region 声音判断
124142 /// <summary>
@@ -255,5 +273,37 @@ namespace Core.Librarys
255273 [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
256274 public static extern IntPtr GetModuleHandle(string lpModuleName);
257275 #endregion
276新增:
277新增: #region 获取窗口信息
278新增: [DllImport("user32.dll")]
279新增: [return: MarshalAs(UnmanagedType.Bool)]
280新增: public static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);
281新增:
282新增: [StructLayout(LayoutKind.Sequential)]
283新增: public struct RECT
284新增: {
285新增: public int Left; // x position of upper-left corner
286新增: public int Top; // y position of upper-left corner
287新增: public int Right; // x position of lower-right corner
288新增: public int Bottom; // y position of lower-right corner
289新增:
290新增: public int Width
291新增: {
292新增: get
293新增: {
294新增: return Right - Left;
295新增: }
296新增: }
297新增: public int Height
298新增: {
299新增: get
300新增: {
301新增: return Bottom - Top;
302新增: }
303新增: }
304新增:
305新增: }
306新增:
307新增: #endregion
258308 }
259309}
修改Core/Servicers/Instances/Sleepdiscover.cs+4 −7看文件
@@ -112,8 +112,7 @@ namespace Core.Servicers.Instances
112112 {
113113 TimeSpan timeSpan = DateTime.Now - pressKeyboardLastTime;
114114
115删除: Point point;
116删除: Win32API.GetCursorPos(out point);
115新增: Point point = Win32API.GetCursorPosition();
117116 if (lastPoint.ToString() == point.ToString() && timeSpan.TotalSeconds > 10)
118117 {
119118 // 非鼠标或键盘激活
@@ -135,7 +134,7 @@ namespace Core.Servicers.Instances
135134 timer.Tick += Timer_Tick;
136135 timer.Start();
137136
138删除: Win32API.GetCursorPos(out lastPoint);
137新增: lastPoint = Win32API.GetCursorPosition();
139138
140139 playSoundStartTime = DateTime.MinValue;
141140
@@ -147,9 +146,7 @@ namespace Core.Servicers.Instances
147146
148147 private void Timer_Tick(object sender, EventArgs e)
149148 {
150删除: Point point;
151删除:
152删除: Win32API.GetCursorPos(out point);
149新增: Point point = Win32API.GetCursorPosition();
153150
154151 if (point.X + point.Y == 0)
155152 {
@@ -227,8 +224,8 @@ namespace Core.Servicers.Instances
227224 }
228225
229226 Logger.Info("【当前坐标】status:" + status + ",lastPoint:" + lastPoint.ToString() + ",now point:" + point.ToString());
227新增:
230228 lastPoint = point;
231删除: //Win32API.GetCursorPos(out lastPoint);
232229 }
233230
234231