C#实现想法小记[程序部分]

C#实现想法小记

自己的程序部分 注释也打不上来多少,因为自己对核心概念也说不清楚嗷嗷嗷 /./

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Timers;

namespace WindowsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {  

            InitializeComponent();
            this.KeyUp += new KeyEventHandler(this.Form1_KeyUp);  //键盘事件
        
        }
        private System.Timers.Timer timerClock = new System.Timers.Timer();  
 
        public void OnTimer(Object source, ElapsedEventArgs e)  //鼠标点击模拟,由时间事件引发
        {
            const int MOUSEEVENTF_MOVE = 0x0001;    //  移动鼠标
            const int MOUSEEVENTF_LEFTDOWN = 0x0002;// 模拟鼠标左键按下
            const int MOUSEEVENTF_LEFTUP = 0x0004;// 模拟鼠标左键抬起
            const int MOUSEEVENTF_RIGHTDOWN = 0x0008; //模拟鼠标右键按下
            const int MOUSEEVENTF_RIGHTUP = 0x0010;// 模拟鼠标右键抬起
            const int MOUSEEVENTF_MIDDLEDOWN = 0x0020;// 模拟鼠标中键按下
            const int MOUSEEVENTF_MIDDLEUP = 0x0040; //模拟鼠标中键抬起
            const int MOUSEEVENTF_ABSOLUTE = 0x8000;// 标示是否采用绝对坐标

             // mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 500, 500, 0, 0);
              mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
              mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
            
           // MessageBox.Show("test","test");
        }

     
   

        private void button1_Click(object sender, EventArgs e) //这个是前期测试的一部分 后面直接留作按钮启动timer的方法
        {
          
             timerClock.Enabled = false;
             timerClock.Elapsed += new ElapsedEventHandler(OnTimer);
             timerClock.Interval =this.trackBar1.Value*1000;
             timerClock.Enabled = true;

        }



        private void Form1_KeyUp(object sender, KeyEventArgs e) //按键事件
        {
            if (e.Control && e.KeyCode == Keys.P)
            {
                if (timerClock.Enabled == false)
                {
                  
                    timerClock.Elapsed += new ElapsedEventHandler(OnTimer);
                    timerClock.Interval = this.trackBar1.Value * 1000;
                    timerClock.Enabled = true;
                }
                else timerClock.Enabled = false;
              
            }

        }
        private void Form1_Load(object sender, EventArgs e)
        {
         
        }

        private void trackBar1_Scroll(object sender, EventArgs e)  //拉条 (- - 是拉条么._)选择间隔时间,显示出来
        {
           this.label1.Text=this.trackBar1.Value.ToString()+"秒";
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值