/// <summary> /// 練功狀態下的Update /// </summary> private void AttactBehavior() { if (IsFighting() && mSurvivalPoints.Count > 0) { foreach (Point point in mSurvivalPoints) { Bitmap bmp = ScreenLib.GetScreen(point, AttackTargeSize); if (!ScreenLib.Scan(bmp, TargetColor)) { mSurvivalPoints.Remove(point); } } MouseSimulator.Position = mSurvivalPoints[0]; Thread.Sleep(100); KeyboardSimulator.KeyPress(PrimaryKey); Thread.Sleep(100); MouseSimulator.Click(MouseButton.Left); } else { mSurvivalPoints.Clear(); CurrentBehavior = NormalBehavior; } }
private void playOperation(IntPtr h, Rectangle rect, string op) { Point p = NativeUtils.NativeClientToScreen(h, rect.Location); rect.Location = p; //从左上角调整到控件中心 p.X += rect.Width / 2; p.Y += rect.Height / 2; string s = op + ":" + h.ToString() + rect.ToString(); lstBox.Items.Add(s); lstBox.SelectedIndex = lstBox.Items.Count - 1; //画这次的线和框 drawLine(_currentPoint, p); drawRectangle(rect); MouseSimulator.Position = p; System.Threading.Thread.Sleep(1000); MouseSimulator.Click(MouseButton.Left); System.Threading.Thread.Sleep(1000); //消除这次画的线和框 drawLine(_currentPoint, p); drawRectangle(rect); System.Threading.Thread.Sleep(1000); _currentPoint = p; }
private void SimulateClick(IHTMLElement el) { BrowserWindow bw = browser as BrowserWindow; if (bw != null) { MyBrowser wb = bw.WBBrowser as MyBrowser; Point p = wb.GetScroll(); int scrollTop = p.Y; int scrollLeft = p.X; logger.InfoFormat("scrolltop:{0},scrollleft:{1}", scrollTop, scrollLeft); Rectangle rect = browser.GetAbsolutePosition(el); System.Windows.Forms.Control control = wb as System.Windows.Forms.Control; //获取控件绝对位置 Point location = control.PointToScreen(Point.Empty); Point newPosition = new Point(rect.X + rect.Width / 2 - scrollLeft, rect.Y + location.Y - scrollTop + 2); logger.InfoFormat("new position, x:{0}, y:{0}", newPosition.X, newPosition.Y); AutoRobo.Core.Macro.Macror.LinearSmoothMove(newPosition, 200); MouseSimulator.X = newPosition.X; MouseSimulator.Y = newPosition.Y; MouseSimulator.Click(System.Windows.Forms.MouseButtons.Left); } }
/// <summary> /// 左右鍵連點 /// </summary> private void OnRightAndLeftClick() { if (LeftAndRightCheckBox.Checked) { MouseSimulator.Click(MouseButton.Right); MouseSimulator.Click(MouseButton.Left); } }
private void ShowSymbol(object sender, RoutedEventArgs e) { var selectedSymbol = dataGridSymbols.SelectedItem as Symbol; if (selectedSymbol == null) { return; } MouseSimulator.Position = new System.Drawing.Point(selectedSymbol.Position.X, selectedSymbol.Position.Y); Thread.Sleep(100); MouseSimulator.Click(MouseButton.Right); }
void MouseSimClick() { timer1.Stop(); bistAll.Clear(); bistAll.Add(0); bistAll.Add(0); Thread.Sleep(500); MouseSimulator.X = 1761; MouseSimulator.Y = 655; MouseSimulator.Click(MouseButton.Left); Thread.Sleep(1500); timer1.Start(); }
static void Demo() { bool toggle = false; while (true) { toggle = !toggle; if (toggle) { MouseSimulator.MoveTo(200, 200); } else { MouseSimulator.MoveTo(400, 200); } MouseSimulator.Click(); Thread.Sleep(1000); } }
public bool execute(Dictionary <string, String> pv) { if (data_ready) { try { System.Windows.Forms.Cursor.Position = new System.Drawing.Point(x, y); Thread.Sleep(10); MouseSimulator.Click(MouseButtons.Left); } catch (Exception e) { Last_Error = "执行鼠标操作错误 " + e.Message; return(false); } return(true); } Last_Error = "SetMouse参数错误"; return(false); }
// Makes a right click at the current location public void rightClick() { MouseSimulator.Click(MouseButton.Right); }
// Makes a left click at the current location public void leftClick() { MouseSimulator.Click(MouseButton.Left); }
private void LeftClick(int x, int y, int delay) { MouseSimulator.Position = new System.Drawing.Point(x, y); MouseSimulator.Click(MouseKeyboardLibrary.MouseButton.Left); Thread.Sleep(delay * 1000); }