想写个小程序,点击启动按钮后,不断得去匹配本机时间,当到11点59分59秒(如果还能更精确的话更好),鼠标左键单击一下。

解决方案 »

  1.   

    是的,用一个timer控件。设置它的Enbled=true;,设置Interval=1000,然后在它的Tick事件中写:
    DateTime dt=DateTime.Now;
    if(dt.Hour==11 && dt.Minute==59 && dt.Seconds==59)
    //做你想做的事。以上代码为随手写,只是告诉你逻辑
      

  2.   

    你为什么要让它点按钮呢?点击按钮还不是要执行你的事件?你直接把要执行的事件写出来不就行了?
    if(dt.Hour==11 && dt.Minute==59 && dt.Seconds==59)
    {
       //代码
    }
      

  3.   

    csdn里面很多类似的;
    http://topic.csdn.net/u/20090219/16/f4118ed3-fced-4ae2-b6a9-70af7b23665f.html
    你看一下这个就可以了。
      

  4.   

    onmouse这个事件。鼠标移动在上面就出发了 如果,是连鼠标都不动,那你请神吧!
      

  5.   

    用Mouse_event()来控制鼠标操作
      

  6.   

    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;
    namespace 让姐省点力
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            [DllImport("User32")]
            public extern static void mouse_event(int dwFlags, int dx, int dy, int dwData, IntPtr dwExtraInfo);        [DllImport("User32")]
            public extern static void SetCursorPos(int x, int y);        [DllImport("User32")]
            public extern static bool GetCursorPos(out POINT p);        [StructLayout(LayoutKind.Sequential)]        public struct POINT
            {
                public int X;
                public int Y;
            }        public enum MouseEventFlags
            {
                Move = 0x0001,
                LeftDown = 0x0002,
                LeftUp = 0x0004,
                RightDown = 0x0008,
                RightUp = 0x0010,
                MiddleDown = 0x0020,
                MiddleUp = 0x0040,
                Wheel = 0x0800,
                Absolute = 0x8000
            }        private void AutoClick()
            {
                POINT p = new POINT();
                GetCursorPos(out p);
                //try
                //{
                //    SetCursorPos(x, y);
                    mouse_event((int)(MouseEventFlags.LeftDown | MouseEventFlags.Absolute), 0, 0, 0, IntPtr.Zero);
                    mouse_event((int)(MouseEventFlags.LeftUp | MouseEventFlags.Absolute), 0, 0, 0, IntPtr.Zero);
                //}
                //finally
                //{
                //    SetCursorPos(p.X, p.Y);
                //}
            }        private void button1_Click(object sender, EventArgs e)
            {
                timer1.Start();
            }        private void timer1_Tick(object sender, EventArgs e)
            {
                DateTime dt = DateTime.Now;            label1.Text = dt.ToString();            if (dt.Hour == 23 && dt.Minute == 59 && dt.Second == 59)
                {
                    AutoClick();
                }
            }
        }
    }
    谢谢大家了。。已经搞定了 贴出代码 嘿嘿
      

  7.   

    lz  原来拿来泡MM的哦
    namespace 让姐省点力