提交记录修改Core/Librarys/Win32API.cs+53 −3看文件
修改Core/Servicers/Instances/Sleepdiscover.cs+4 −7看文件
| @@ -63,8 +63,8 @@ namespace Core.Librarys | ||
| 63 | 63 | public const UInt32 PROCESS_QUERY_INFORMATION = 0x400; |
| 64 | 64 | public const UInt32 PROCESS_VM_READ = 0x010; |
| 65 | 65 | |
| 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; | |
| 68 | 68 | public static string UWP_AppName(IntPtr hWnd, uint pID) |
| 69 | 69 | { |
| 70 | 70 | WINDOWINFO windowinfo = new WINDOWINFO(); |
| @@ -117,8 +117,26 @@ namespace Core.Librarys | ||
| 117 | 117 | /// <returns></returns> |
| 118 | 118 | [DllImport("user32.dll", SetLastError = true)] |
| 119 | 119 | [return: MarshalAs(UnmanagedType.Bool)] |
| 120 | 删除: public static extern bool GetCursorPos(out Point lpPoint); | |
| 120 | 新增: private static extern bool GetCursorPos(out POINT lpPoint); | |
| 121 | 121 | |
| 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 | 新增: } | |
| 122 | 140 | |
| 123 | 141 | #region 声音判断 |
| 124 | 142 | /// <summary> |
| @@ -255,5 +273,37 @@ namespace Core.Librarys | ||
| 255 | 273 | [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] |
| 256 | 274 | public static extern IntPtr GetModuleHandle(string lpModuleName); |
| 257 | 275 | #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 | |
| 258 | 308 | } |
| 259 | 309 | } |
| @@ -112,8 +112,7 @@ namespace Core.Servicers.Instances | ||
| 112 | 112 | { |
| 113 | 113 | TimeSpan timeSpan = DateTime.Now - pressKeyboardLastTime; |
| 114 | 114 | |
| 115 | 删除: Point point; | |
| 116 | 删除: Win32API.GetCursorPos(out point); | |
| 115 | 新增: Point point = Win32API.GetCursorPosition(); | |
| 117 | 116 | if (lastPoint.ToString() == point.ToString() && timeSpan.TotalSeconds > 10) |
| 118 | 117 | { |
| 119 | 118 | // 非鼠标或键盘激活 |
| @@ -135,7 +134,7 @@ namespace Core.Servicers.Instances | ||
| 135 | 134 | timer.Tick += Timer_Tick; |
| 136 | 135 | timer.Start(); |
| 137 | 136 | |
| 138 | 删除: Win32API.GetCursorPos(out lastPoint); | |
| 137 | 新增: lastPoint = Win32API.GetCursorPosition(); | |
| 139 | 138 | |
| 140 | 139 | playSoundStartTime = DateTime.MinValue; |
| 141 | 140 | |
| @@ -147,9 +146,7 @@ namespace Core.Servicers.Instances | ||
| 147 | 146 | |
| 148 | 147 | private void Timer_Tick(object sender, EventArgs e) |
| 149 | 148 | { |
| 150 | 删除: Point point; | |
| 151 | 删除: | |
| 152 | 删除: Win32API.GetCursorPos(out point); | |
| 149 | 新增: Point point = Win32API.GetCursorPosition(); | |
| 153 | 150 | |
| 154 | 151 | if (point.X + point.Y == 0) |
| 155 | 152 | { |
| @@ -227,8 +224,8 @@ namespace Core.Servicers.Instances | ||
| 227 | 224 | } |
| 228 | 225 | |
| 229 | 226 | Logger.Info("【当前坐标】status:" + status + ",lastPoint:" + lastPoint.ToString() + ",now point:" + point.ToString()); |
| 227 | 新增: | |
| 230 | 228 | lastPoint = point; |
| 231 | 删除: //Win32API.GetCursorPos(out lastPoint); | |
| 232 | 229 | } |
| 233 | 230 | |
| 234 | 231 | |

