示例#1
0
 public MainFrom()
 {
     InitializeComponent();
     mouse = new MouseHookEvents();
     mouse.OnMouseActivity += new MouseEventHandler(mouse_OnMouseActivity);
     this.FormMovingEvent += FollowMainForm;
     mouse.Start();
     task = new TaskModel();
 }
示例#2
0
 //新增一个任务
 public static void AddTask(TaskModel task)
 {
     XmlOperator.CreateXmlTask(task);
 }
示例#3
0
 public static List<TaskModel> GetXmlTaskList()
 {
     doc.Load(path);//注意Load数据
     XmlNodeList list = doc.SelectNodes("tasks/task");
     List<TaskModel> tasks = new List<TaskModel>();
     foreach (XmlElement item in list)
     {
         TaskModel task = new TaskModel();
         task.Name = item.SelectSingleNode("./taskName").InnerText;
         task.Application = item.SelectSingleNode("./application").InnerText;
         task.Url = item.SelectSingleNode("./param").InnerText;
         task.PositionX = item.SelectSingleNode("./position/x").InnerText.ToInt();
         task.PositionY = item.SelectSingleNode("./position/y").InnerText.ToInt();
         tasks.Add(task);
     }
     return tasks;
 }
示例#4
0
        //将新建的任务信息存储进XML数据文件中
        public static void CreateXmlTask(TaskModel task)
        {
            doc.Load(path);
            XmlElement xe1 = doc.CreateElement(NodeName.task.ToString());
            XmlElement xe21 =doc.CreateElement(NodeName.taskName.ToString());
            xe21.InnerText = task.Name;
            XmlElement xe22 = doc.CreateElement(NodeName.application.ToString());
            xe22.InnerText = task.Application;
            XmlElement xe23 = doc.CreateElement(NodeName.param.ToString());
            xe23.InnerText = task.Url;
            XmlElement xe24 = doc.CreateElement(NodeName.position.ToString());
            XmlElement xe241 = doc.CreateElement(NodeName.x.ToString());
            xe241.InnerText = task.PositionX.ToString();
            XmlElement xe242 = doc.CreateElement(NodeName.y.ToString());
            xe242.InnerText = task.PositionY.ToString();
            xe24.AppendChild(xe241);
            xe24.AppendChild(xe242);

            XmlElement[] xes = { xe21,xe22,xe23,xe24};
            AppendXeChildren(xe1, xes);
            doc.DocumentElement.AppendChild(xe1);
            doc.Save(path);
        }
示例#5
0
        public void ExcuteTask(TaskModel task)
        {
            int processID;
            ProcessStartInfo ps = new ProcessStartInfo(task.Application, task.Url);
            ps.WindowStyle = ProcessWindowStyle.Maximized;
            Process myProc = Process.Start(ps);
            processID = myProc.Id;
            Thread.Sleep((int)numericUpDown2.Value * BASENUM);
            //设置鼠标位置
            MouseEvents.SetCursorPosition(task.PositionX, task.PositionY);
            //模拟鼠标双击
            MouseEvents.MouseDbClick();
            Thread.Sleep(1000);

            KillProcess(task.Application);
            //Process.GetCurrentProcess().Kill();
            //myProc = Process.GetProcessById(processID);
            //myProc.Kill();
        }