【IT168技术文档】
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; using System.Threading; namespace ShuBiao { public partial class Form1 : Form { Window Api#region Window Api [DllImport("user32.dll")] static extern bool SetCursorPos(int x, int y); [DllImport("user32.dll")] static extern void mouse_event(uint mouseEvent, int dx, int dy, uint data, int extrainfo); #endregion Mouse Event#region Mouse Event public static readonly uint MOUSEEVENTF_LEFTDOWN = 2; public static readonly uint MOUSEEVENTF_LEFTUP = 4; public static readonly uint MOUSEEVENTF_RIGHTDOWN = 8; public static readonly uint MOUSEEVENTF_RIGHTUP = 16; # endregion public Form1() { InitializeComponent(); WindowState = FormWindowState.Minimized; //设置多长时间点鼠标 Thread.Sleep(6000); } private void Form1_Load(object sender, EventArgs e) { DateTime dt=DateTime .Now; string day; day = dt.DayOfWeek.ToString(); if (day == "Sunday" || day =="Saturday") ShutDown(); else MouseEvent(); } /**//// <summary> /// 鼠标事件 /// </summary> private void MouseEvent() { //启动officeIM System.Diagnostics.Process.Start(@"F:\陈想\软件\OfficeIM网络智能办公客户端\OfficeIM.exe"); //随机选取,在一定时间点击 Random rd=new Random(); int time=rd.Next(1,5); Thread .Sleep (time*60000); //点击升级以后再说 SetCursorPos(561, 467); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); SetCursorPos(561, 467); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); //点击考勤工作日志 Thread.Sleep(10000); SetCursorPos(88, 168); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); SetCursorPos(88, 168); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); //点击考勤登记 Thread.Sleep(5000); SetCursorPos(376, 84); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); SetCursorPos(376, 84); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); //点击登记(早晨) Thread.Sleep(5000); SetCursorPos(677, 315); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); SetCursorPos(677, 315); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); //点击退出 Thread.Sleep(5000); SetCursorPos(681, 547); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); SetCursorPos(681, 547); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); //点击关闭 Thread.Sleep(5000); SetCursorPos(1014, 10); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); SetCursorPos(1014, 10); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); SetCursorPos(1014, 10); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); SetCursorPos(1014, 10); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); Application.Exit(); } /**//// <summary> /// 周末的时候自动关机 /// </summary> private void ShutDown() { //60秒后自动关机 System.Diagnostics.Process.Start("shutdown", "-s -f -t 60"); } } }
以后升级561.467 考勤工作日志:101.167 考勤登记:386.84 上午登记:676.312 下午:675.351 退出:676.551