private void FrmMain_Load(object sender, EventArgs e) { Task.Factory.StartNew(() => { var hWnd = AppInvoke.Init(); MouseInvoke.InitApp(hWnd); var rect = AppInvoke.Rectangle; var g = Graphics.FromHwnd(hWnd); var pArray = new Point[4]; var w = rect.Width / 4; for (int i = 0; i < pArray.Length; i++) { pArray[i] = new Point(w / 2 + i * w, rect.Height * 2 / 3); } while (true) { if (!isRun) { autoResetEvent.WaitOne(); } Process(g, pArray); ShowGrid(g, w, pArray); Thread.Sleep(1); } }); }
void hotKey_OnHotkey(int hotKeyID) { switch (dicKeys[hotKeyID]) { case Keys.Home: { MouseInvoke.InitApp(AppInvoke.Init()); rectMain = AppInvoke.Rectangle; this.picModify.Height = rectMain.Height * this.picModify.Width / rectMain.Width; inRun = true; RefreshState(); } break; case Keys.End: { inRun = false; RefreshState(); } break; case Keys.X: { this.labPos.Text = $"{MousePosition.X - rectMain.X},{ MousePosition.Y - rectMain.Y }"; } break; } }