public void ExecuteActions() { bool isRelative = false; POINT pos = new POINT(); POINT click = new POINT(); POINT start = new POINT(); string first = Actions.GetNextAction(); if (first.Contains("RELATIVE")) { isRelative = true; Actions.GetNextAction(); first = Actions.GetNextAction(); GetCursorPos(out click); string[] t = first.Split(' '); start.x = Convert.ToInt32(t[0]); start.y = Convert.ToInt32(t[1]); } while (Actions.Actions.Count > 0) { string str = Actions.GetNextAction(); if (str.Contains("CLICK")) { mouse_event((int)MouseCodes[str], pos.x, pos.y, 0, 0); } else if (str.Contains("WAIT")) { str = str.Substring(5); double ms = Convert.ToDouble(str); DateTime a = DateTime.Now; DateTime b = a; while ((b - a).TotalMilliseconds < ms) { b = DateTime.Now; } } else { string[] nbrs = str.Split(' '); int x = Convert.ToInt32(nbrs[0]); int y = Convert.ToInt32(nbrs[1]); pos.x = x; pos.y = y; if (isRelative) { pos.x = pos.x - start.x + click.x; pos.y = pos.y - start.y + click.y; } SetCursorPos(pos.x, pos.y); } } Started = false; }
private static extern bool GetCursorPos(out POINT lpMousePoint);