C#鼠标录音机需要鼠标点击录音

时间:2015-09-12 11:17:15

标签: c# mouse recorder

https://www.youtube.com/watch?v=tY8wxRGGHKs

跟随那个视频并且它可以工作,但它没有记录/播放鼠标点击,一旦我有了我将修改程序,以便它可以设置热键和随机间隔等,但首先我需要能够记录鼠标点击,我一直在谷歌搜索并尝试了一段时间,找不到任何有效/有帮助的东西:/

代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Mouse_Recorder
{
    public partial class Form1 : Form
    {

        ListViewItem lv;
        int a;
        int b;
        public Form1()
        {
            InitializeComponent();
        }


        private void timer1_Tick(object sender, EventArgs e)
        {
            lv = new ListViewItem(Cursor.Position.X.ToString());
            lv.SubItems.Add(Cursor.Position.Y.ToString());
            listView1.Items.Add(lv);
            b++;
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            if (a != b)
            {
                Cursor.Position = new Point(int.Parse(listView1.Items[a].SubItems[0].Text), int.Parse(listView1.Items[a].SubItems[1].Text));
                a++;
            }
        }

        private void btnRecord_Click(object sender, EventArgs e)
        {
            timer1.Start();
        }

        private void btnStop_Click(object sender, EventArgs e)
        {
            timer1.Stop();
            timer2.Stop();
        }

        private void btnPause_Click(object sender, EventArgs e)
        {
            timer2.Start();            
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            a = 0;
            b = 0;
        }


    }
}

0 个答案:

没有答案