国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

C# 實(shí)現(xiàn)按鍵精靈 記錄錄制鍵盤鼠標(biāo)

這篇具有很好參考價值的文章主要介紹了C# 實(shí)現(xiàn)按鍵精靈 記錄錄制鍵盤鼠標(biāo)。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報違法"按鈕提交疑問。

?是一個非常實(shí)用的鍵盤鼠標(biāo)腳本錄制工具,通過它你可以輕松地進(jìn)行腳本錄制,簡單易用,不需要任何編程知識就能做出功能強(qiáng)大的腳本,只要你在電腦前用雙手可以完成的動作,都可以替你完成。

C# 實(shí)現(xiàn)按鍵精靈 記錄錄制鍵盤鼠標(biāo)

?下載地址:?

? ? ? ? ? ? ? ?下載軟件

特性

1.運(yùn)行錄制腳步時模擬過程 比按鍵精靈 更加流暢,還原度更高,以模擬鼠標(biāo)在畫圖軟件里畫畫還原為例.

2.支持錄制腳步 可以在按鍵精靈運(yùn)行 ,按鍵精靈 錄制鼠標(biāo)按鍵鍵盤腳步也可以復(fù)制到記錄框 在我這個里運(yùn)行.其他找色等就不支持

3.免費(fèi) 無廣告.按鍵精靈錄制生成的exe文件會插入廣告 還有登陸注冊 比較麻煩


代碼引用了github 開源?神龍輔助工具 C#??

GitHub - respost/DragonHelperTool: 一個非常實(shí)用的鍵盤鼠標(biāo)腳本錄制工具,通過它你可以輕松地進(jìn)行腳本錄制,簡單易用。一個非常實(shí)用的鍵盤鼠標(biāo)腳本錄制工具,通過它你可以輕松地進(jìn)行腳本錄制,簡單易用。. Contribute to respost/DragonHelperTool development by creating an account on GitHub.https://github.com/respost/DragonHelperTool文章來源地址http://www.zghlxwxcb.cn/news/detail-508525.html

?代碼概述

 //設(shè)置鍵盤勾子
khl = new KeyboardHookListener(new MouseKeyboardActivityMonitor.WinApi.GlobalHooker());

// 鍵盤按下事件 ,通過記錄按下的時間和按鍵 保存到文件
khl.KeyDown += (a, b) =>
{
      if (currState == KState.Recording && checkBox2.Checked)
      {
                   string s = "", d = "", m = "";
                    recordList.Add(TimeEx.GetCurrTimestamp());
                    d = "Delay " + AndLastTime();
                    s = "KeyDown \"" + b.KeyData + "\", 1";
      }

};

khl.Enabled = true;

運(yùn)行腳本時
循環(huán)讀取文件 讀取每行 運(yùn)行延遲 和 模擬按鍵按下

Thread.Sleep((int)(delayTime));

if (rf.mouseX == 0)
{//鍵盤事件
    Keys key = (Keys)rf.keyNumber;
    if (rf.keyState == 0)
    {
        KeyboardHelper.KeyDown(key);
	}

?Form.cs

using MouseKeyboardActivityMonitor;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using Wb.EventSystem;
using  神龍輔助工具;

namespace KeyboardRecord_V2
{
    public partial class Form1 : Form
    {

        public static Form1 instance = null;
        private MouseHookListener mhl;
        private KeyboardHookListener khl;
        RecordFileManage rm;
        public static TextBox textBox1Static;

        private static bool mouseLeftDown = false;
        private static bool mouseRightDown = false;
        private static bool mouseMiddleDown = false;
        public static List<MyThread> myThreads = new List<MyThread>();
        /// <summary>
        /// 是否有鼠標(biāo)按鍵被按下
        /// </summary>
        private static bool mouseIsDown
        {
            get
            {
                return mouseLeftDown || mouseRightDown || mouseMiddleDown;
            }
        }

        /// <summary>
        /// 循環(huán)遍歷窗體中的所有控件。使用if語句判斷控件是否為按鈕控件,如果是,禁用啟用所有按鍵
        /// </summary>
        public bool Button_Enable_All
        {
            get { return false; }
            set
            {
                // 查找窗體中的所有按鈕
                Button[] buttons = this.Controls.OfType<Button>().ToArray();
                // 遍歷所有按鈕
                foreach (Button button in buttons)
                {
                        button.Enabled = value;
                        // 打印按鈕名稱
                        Console.WriteLine(button.Name);
                }

            }
        }

        private volatile bool flag = false;


       public static KState currState = KState.Null;
        int pp0p3p = 0;
        string savePath = System.AppDomain.CurrentDomain.BaseDirectory + @"Recorder\";
        public string saveFilePath = "";

        public string SaveNewTypePath = System.AppDomain.CurrentDomain.BaseDirectory;
        string saveNewTypeFilePath = "";
        public Form1()
        {
            InitializeComponent();

            instance = this;

            SetKeyboradHookEvent();

            // 注冊事件
            EventSystem.RegisterEvent(EGameEvent.append_textbox1_text, (a, new_text) =>
            {
                textBox1.Append((new_text[0] as string));
            });

            textBox1Static = textBox1;


            textBox1.AddScrollBars_WordWrap_Multiline_v2();


            //判斷該路徑下文件夾是否存在,不存在的情況下新建文件夾
            if (!Directory.Exists(savePath))
            {
                Directory.CreateDirectory(savePath);
            }
            if (!Directory.Exists(SaveNewTypePath))
            {
                Directory.CreateDirectory(SaveNewTypePath);
            }

            saveFilePath = WinformExtension.GetRegistData("saveFilePath") as string;
            textBox4.Text = Path.GetFileName(saveFilePath);



            autoFilePath = WinformExtension.GetRegistData("autoFilePath") as string;
            if (File.Exists(autoFilePath))
            {

                textBox3.Text = autoFilePath;
            }

            var checkBox3_Checked = WinformExtension.GetRegistData("checkBox3_Checked");
            if (checkBox3_Checked != null)
            {
                checkBox3.Checked = checkBox3_Checked.ToString() == "True" ? true : false;
                if (checkBox3.Checked)
                {
                    if (File.Exists(autoFilePath))
                    {
                        MyThread thread1 = new MyThread();
                        thread1.Bind(RecordFileManage.RunFile, autoFilePath);
                        thread1.Start();
                        myThreads.Add(thread1);
                    }
                }

            }

            #region comboBox1
            ComboBox combBox9527 = null;

             combBox9527 = comboBox1;
            // 將枚舉類型的所有值添加到下拉選擇框中
            foreach (Keys gender in Enum.GetValues(typeof(Keys)))
            {
                combBox9527.Items.Add(gender);
            }
            //這兩個屬性的區(qū)別在于它們分別返回顯示文本和所選項的值
            //comboBox1.DisplayMember 返回顯示文本
            //comboBox1.SelectedItem 返回所選項的值

             combBox9527.SelectedItem = comboBox1_key = Keys.F6;
            combBox9527.DisplayMember = Enum.GetName(typeof(Keys), Keys.F6);

            combBox9527 = comboBox2;
            // 將枚舉類型的所有值添加到下拉選擇框中
            foreach (Keys gender in Enum.GetValues(typeof(Keys)))
            {
                combBox9527.Items.Add(gender);
            }
            //這兩個屬性的區(qū)別在于它們分別返回顯示文本和所選項的值
            //comboBox1.DisplayMember 返回顯示文本
            //comboBox1.SelectedItem 返回所選項的值

           combBox9527.SelectedItem = comboBox2_key = Keys.F7;
            combBox9527.DisplayMember = Enum.GetName(typeof(Keys), Keys.F7);


            combBox9527 = comboBox3;
            // 將枚舉類型的所有值添加到下拉選擇框中
            foreach (Keys gender in Enum.GetValues(typeof(Keys)))
            {
                combBox9527.Items.Add(gender);
            }
            //這兩個屬性的區(qū)別在于它們分別返回顯示文本和所選項的值
            //comboBox1.DisplayMember 返回顯示文本
            //comboBox1.SelectedItem 返回所選項的值

            combBox9527.SelectedItem = comboBox3_key = Keys.F8;
            combBox9527.DisplayMember = Enum.GetName(typeof(Keys), Keys.F8);



            #endregion

            #region 窗口居中
            // 獲取屏幕尺寸
            int screenWidth = Screen.PrimaryScreen.WorkingArea.Width;
            int screenHeight = Screen.PrimaryScreen.WorkingArea.Height;

            // 計算窗口居中的位置
            int left = (screenWidth - this.Width) / 2;
            int top = (screenHeight - this.Height) / 2;

            // 設(shè)置窗口位置
            this.StartPosition = FormStartPosition.Manual;
            this.Location = new Point(left, top);
            #endregion

//            確保 Form 控件的 KeyPreview 屬性設(shè)置為 true。這樣,F(xiàn)orm 窗口會在其他控件之前接收所有按鍵事件。

//確保 Form 控件有焦點(diǎn),否則它將無法接收按鍵事件。
            this.KeyPreview = true;
            this.Focus();
        }

 
        public  void RunRecordScript( )
        {
            Form1.instance.Button_Enable_All = false;
            currState = KState.Runing;

            MyThread thread1 = new MyThread();
            thread1.Bind(RecordFileManage.RunFile, saveFilePath);
            thread1.Start();
            myThreads.Add(thread1);


        }

        public static void StopRunRecordScript()
        {

            Form1.instance.Button_Enable_All = true;
            currState = KState.Null;
            Form1.instance.SetTextSafe("鍵盤記錄器(執(zhí)行完畢)");

            myThreads.ForEach(x =>
            {
                x.Stop();
            });

           


        }



        long recordStartTime = 0;
        long lastTimer = 0;
        List<long> recordList = new List<long>(10000);
        long AndLastTime()
        {
            if (recordList.Count == 0)
                return 108;

            var currTime = recordList[recordList.Count - 1];
            var delayTime = currTime - recordStartTime - lastTimer;
            lastTimer = currTime - recordStartTime;

            if (delayTime <= 0)
            {
                return 186;
                throw new Exception("delayTime <= 0,在某些情況下先按的按鍵事件沒有及時返回,到后面才返回,導(dǎo)致減法為負(fù)數(shù).解決辦法:事件根據(jù)時間戳排序在減");

            }
            return delayTime;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            StartRecord();

        }
        private void button2_Click(object sender, EventArgs e)
        {
            StopRecord();
        }

        private void button3_Click(object sender, EventArgs e)
        {

            string filePath = FolderBrowserHelper.SelectFile(savePath);

            //MyThread thread1 = new MyThread(RecordFileManage.RunFile, filePath);
            //thread1.Start();
            //myThreads.Add(thread1);
        }

        void StartRecord()
        {
            button1.Text = "已開始錄制";
            button1.Enabled = false;
            button2.Enabled = true;
            checkBox1.Enabled = false;
            checkBox2.Enabled = false;
            checkBox4.Enabled = false;
            textBox1.ReadOnly = true;
            currState = KState.Recording;
            recordStartTime = TimeEx.GetCurrTimestamp();



            saveFilePath = savePath + TimeEx.GetCurrTimeStr() + ".txt";
            WinformExtension.SetRegistData("saveFilePath", saveFilePath);
            string fileName = Path.GetFileName(saveFilePath);
            textBox4.Text = fileName;

            rm = new RecordFileManage(recordStartTime, saveFilePath);

            SetMouseHookEvent();
            if (checkBox1.Checked)
            {
                mhl.Enabled = true;
            }
   

            textBox1.AddScrollBars_WordWrap_Multiline_v2();


        }
        void StopRecord()
        {
            if (currState != KState.Recording) return;

            button1.Text = "?  開始錄制";
            button2.Enabled = false;
            button1.Enabled = true;
            checkBox1.Enabled = true;
            checkBox2.Enabled = true;
            checkBox4.Enabled = true;
            textBox1.ReadOnly = false;
            textBox1.ReduceScrollBars_WordWrap_Multiline();
            currState = KState.Null;
           if(mhl!=null) mhl.Enabled = false;
            rm.SaveFile();
        }

        /// <summary>
        /// 設(shè)置鍵盤勾子事件
        /// </summary>
        void SetKeyboradHookEvent()
        {
            //設(shè)置鍵盤勾子
            khl = new KeyboardHookListener(new MouseKeyboardActivityMonitor.WinApi.GlobalHooker());

            khl.KeyDown += (a, b) =>
            {
                if (currState == KState.Recording && checkBox2.Checked)
                {
                    string s = "", d = "", m = "";
                    recordList.Add(TimeEx.GetCurrTimestamp());
                    d = "Delay " + AndLastTime();
                    s = "KeyDown \"" + b.KeyData + "\", 1";

                    EventSystem.SendEvent(EGameEvent.append_textbox1_text, d);
                    EventSystem.SendEvent(EGameEvent.append_textbox1_text, s);
                    rm.AddKeyboard(b.KeyData, 0, TimeEx.GetCurrTimestamp());
                }

                HotKey(b);

            };


            khl.KeyUp += (a, b) =>
            {
                if (currState == KState.Recording && checkBox2.Checked)
                {
                    string s = "", d = "", m = "";
                    recordList.Add(TimeEx.GetCurrTimestamp());
                    d = "Delay " + AndLastTime();
                    s = "KeyUp \"" + b.KeyData + "\", 1";
                    EventSystem.SendEvent(EGameEvent.append_textbox1_text, d);
                    EventSystem.SendEvent(EGameEvent.append_textbox1_text, s);
                    rm.AddKeyboard(b.KeyData, 2, TimeEx.GetCurrTimestamp());
                }
            };

            khl.Enabled = true;
        }


        void HotKey(KeyEventArgs e)
        {
            if (e.KeyCode == comboBox1_key && currState == KState.Null)
            {
                StartRecord();
            }
            if (e.KeyCode == comboBox2_key)
            {
                if (currState == KState.Recording)
                {
                    StopRecord();
                }
                if (currState == KState.Runing)
                {
                    StopRunRecordScript();
                }
            }
            if (e.KeyCode == comboBox3_key && currState == KState.Null)
            {
                RunRecordScript();
            }
        }

        /// <summary>
        /// 設(shè)置鼠標(biāo)勾子事件
        /// </summary>
        void SetMouseHookEvent()
        {
            //設(shè)置鼠標(biāo)勾子
            mhl = new MouseHookListener(new MouseKeyboardActivityMonitor.WinApi.GlobalHooker());

            if (checkBox4.Checked)
            {
                mhl.MouseMove += (a, b) =>
                {
                    if (mouseIsDown)
                    {
                        string s = "", d = "", m = "";
                        recordList.Add(TimeEx.GetCurrTimestamp());
                        m = "MoveTo " + b.X + ", " + b.Y;
                        d = "Delay " + AndLastTime();
                        EventSystem.SendEvent(EGameEvent.append_textbox1_text, d);
                        EventSystem.SendEvent(EGameEvent.append_textbox1_text, m);
                        rm.AddMouse(b.Button, 0, TimeEx.GetCurrTimestamp(), b.X, b.Y);
                    }
                };

            }

            mhl.MouseDownExt += (a, b) =>
            {
                string s = "", d = "", m = "";

                switch (b.Button)
                {
                    case MouseButtons.None:
                        break;
                    case MouseButtons.Left:
                        recordList.Add(TimeEx.GetCurrTimestamp());
                        d = "Delay " + AndLastTime();
                        m = "MoveTo " + b.X + ", " + b.Y;
                        s = "Left" + "Down" + " 1";

                        EventSystem.SendEvent(EGameEvent.append_textbox1_text, d);
                        EventSystem.SendEvent(EGameEvent.append_textbox1_text, m);
                        EventSystem.SendEvent(EGameEvent.append_textbox1_text, s);
                        rm.AddMouse(b.Button, 0, TimeEx.GetCurrTimestamp(), b.X, b.Y);
                        mouseLeftDown = true;
                        break;

                    case MouseButtons.Right:
                        recordList.Add(TimeEx.GetCurrTimestamp());
                        d = "Delay " + AndLastTime();
                        m = "MoveTo " + b.X + ", " + b.Y;
                        s = "Right" + "Down" + " 1";
                        EventSystem.SendEvent(EGameEvent.append_textbox1_text, d);
                        EventSystem.SendEvent(EGameEvent.append_textbox1_text, m);
                        EventSystem.SendEvent(EGameEvent.append_textbox1_text, s);
                        rm.AddMouse(b.Button, 0, TimeEx.GetCurrTimestamp(), b.X, b.Y);
                        mouseRightDown = true;
                        break;
                    case MouseButtons.Middle:
                        recordList.Add(TimeEx.GetCurrTimestamp());
                        d = "Delay " + AndLastTime();
                        m = "MoveTo " + b.X + ", " + b.Y;
                        s = "Middle" + "Down" + " 1";

                        EventSystem.SendEvent(EGameEvent.append_textbox1_text, d);
                        EventSystem.SendEvent(EGameEvent.append_textbox1_text, m);
                        EventSystem.SendEvent(EGameEvent.append_textbox1_text, s);
                        rm.AddMouse(b.Button, 0, TimeEx.GetCurrTimestamp(), b.X, b.Y);
                        mouseMiddleDown = true;
                        break;
                    case MouseButtons.XButton1:
                        break;
                    case MouseButtons.XButton2:
                        break;
                }
            };
            mhl.MouseUp += (a, b) =>
            {
                string s = "", d = "", m = "";
                switch (b.Button)
                {
                    case MouseButtons.None:
                        break;
                    case MouseButtons.Left:
                        recordList.Add(TimeEx.GetCurrTimestamp());

                        d = "Delay " + AndLastTime();
                        m = "MoveTo " + b.X + ", " + b.Y;
                        s = "Left" + "Up" + " 1";
                        EventSystem.SendEvent(EGameEvent.append_textbox1_text, d);
                        EventSystem.SendEvent(EGameEvent.append_textbox1_text, m);
                        EventSystem.SendEvent(EGameEvent.append_textbox1_text, s);
                        rm.AddMouse(b.Button, 2, TimeEx.GetCurrTimestamp(), b.X, b.Y);
                        mouseLeftDown = false;
                        break;

                    case MouseButtons.Right:
                        recordList.Add(TimeEx.GetCurrTimestamp());
                        d = "Delay " + AndLastTime();
                        m = "MoveTo " + b.X + ", " + b.Y;
                        s = "Right" + "Up" + " 1";

                        EventSystem.SendEvent(EGameEvent.append_textbox1_text, d);
                        EventSystem.SendEvent(EGameEvent.append_textbox1_text, m);
                        EventSystem.SendEvent(EGameEvent.append_textbox1_text, s);
                        rm.AddMouse(b.Button, 2, TimeEx.GetCurrTimestamp(), b.X, b.Y);
                        mouseRightDown = false;
                        break;
                    case MouseButtons.Middle:
                        recordList.Add(TimeEx.GetCurrTimestamp());
                        d = "Delay " + AndLastTime();
                        m = "MoveTo " + b.X + ", " + b.Y;
                        s = "Middle" + "Up" + " 1";
                        EventSystem.SendEvent(EGameEvent.append_textbox1_text, d);
                        EventSystem.SendEvent(EGameEvent.append_textbox1_text, m);
                        EventSystem.SendEvent(EGameEvent.append_textbox1_text, s);
                        rm.AddMouse(b.Button, 2, TimeEx.GetCurrTimestamp(), b.X, b.Y);
                        mouseMiddleDown = false;
                        break;
                    case MouseButtons.XButton1:
                        break;
                    case MouseButtons.XButton2:
                        break;
                }
            };



            
        }



        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void button4_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("notepad.exe", saveFilePath);

        }

        private void button5_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("explorer.exe", savePath);
        }

        string autoFilePath;
        private void button6_Click(object sender, EventArgs e)
        {
            autoFilePath = FolderBrowserHelper.SelectFile(savePath);
            textBox3.Text = autoFilePath;
            WinformExtension.SetRegistData("autoFilePath", autoFilePath);
        }

        bool checkBox3_Checked;
        private void checkBox3_CheckedChanged(object sender, EventArgs e)
        {
            WinformExtension.SetRegistData("checkBox3_Checked", checkBox3.Checked);
        }

        private void d(object sender, EventArgs e)
        {

        }

        private void button7_Click(object sender, EventArgs e)
        {

            //MyThread thread1 = new MyThread(RecordFileManage.RunFile, saveFilePath);
            //thread1.Start();
        }

        private void button8_Click(object sender, EventArgs e)
        {
            //MyThread thread1 = new MyThread(RecordFileManage.RunFile, autoFilePath);
            //thread1.Start();
            //myThreads.Add(thread1);
            currState = KState.Runing;
        }

        string fixSaveFilePath = "";
        private void button9_Click(object sender, EventArgs e)
        {
            fixSaveFilePath = SaveNewTypePath + TimeEx.GetCurrTimeStr() + "_KeyboradRecordFile" + ".txt";
            saveFilePath = fixSaveFilePath;
            textBox4.Text = saveFilePath;
            var rfm = new RecordFileManage_V2(fixSaveFilePath);
            rfm.SaveFile();
        }

        private void button10_Click(object sender, EventArgs e)
        {
  
            WinformExtension.OpenFile(fixSaveFilePath);
        }

        private void button11_Click(object sender, EventArgs e)
        {


            HighPrecisionTimer.Test();
            textBox1.Text = "";


        }

        private void button12_Click(object sender, EventArgs e)
        {
            MyThread thread1 = new MyThread();
            thread1.Bind(RecordFileManage_V2.Run, textBox1.Text);
            thread1.Start();
            myThreads.Add(thread1);


        }

        private void button13_Click(object sender, EventArgs e)
        {

            RunRecordScript();
        }



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

        private void button9_MouseHover(object sender, EventArgs e)
        {
            //Point relativePos = button9.PointToClient(MousePosition); //將屏幕坐標(biāo)轉(zhuǎn)換為控件內(nèi)的相對坐標(biāo)
            toolTip1.Show("該文件只能在記錄框里執(zhí)行,其他運(yùn)行文件按鈕不支持\nThis file can only be executed within the logging framework. It is not supported by other executable files.",
                button9,0,-30,2000);
        }

        private void button14_Click(object sender, EventArgs e)
        {

        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void button14_Click_1(object sender, EventArgs e)
        {

            MyThreadExample.thread1.Stop();
        }
        Form2 form2;
        private void button14_Click_2(object sender, EventArgs e)
        {
            form2 = new Form2();
            string fileName = Path.GetFileName(saveFilePath);
            form2.textBox1.Text = fileName;
            form2.Show();
        }

        private void textBox5_TextChanged(object sender, EventArgs e)
        {

        }

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

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

        private void comboBox1_Enter(object sender, EventArgs e)
        {




        }

        private void comboBox3_KeyPress(object sender, KeyPressEventArgs e)
        {

        }

        Keys comboBox1_key, comboBox2_key, comboBox3_key;

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {


        }

        private void comboBox3_KeyDown(object sender, KeyEventArgs e)
        {

            var combBox9527 = comboBox1;
            if (combBox9527.Focused)
            {
                // 將選中項設(shè)置為用戶按下的鍵
                combBox9527.SelectedItem = e.KeyCode;
                // 設(shè)置顯示文本為鍵的名稱
                combBox9527.DisplayMember = Enum.GetName(typeof(Keys), e.KeyCode);
                comboBox1_key = e.KeyCode;
            }

             combBox9527 = comboBox2;
            if (combBox9527.Focused)
            {
                // 將選中項設(shè)置為用戶按下的鍵
                combBox9527.SelectedItem = e.KeyCode;
                // 設(shè)置顯示文本為鍵的名稱
                combBox9527.DisplayMember = Enum.GetName(typeof(Keys), e.KeyCode);
                comboBox2_key = e.KeyCode;
            }
            combBox9527 = comboBox3;
            if (combBox9527.Focused)
            {
                // 將選中項設(shè)置為用戶按下的鍵
                combBox9527.SelectedItem = e.KeyCode;
                // 設(shè)置顯示文本為鍵的名稱
                combBox9527.DisplayMember = Enum.GetName(typeof(Keys), e.KeyCode);
                comboBox3_key = e.KeyCode;
            }


        }
    }

    public class RecordFile
    {
        /// <summary>
        /// keyDown =0 ,keyUp =1
        /// </summary>
        public int keyState;
        /// <summary>
        /// 哪個按鍵被按下了
        /// </summary>
        public int keyNumber;
        /// <summary>
        /// 啥時候被按下了
        /// </summary>
        public long time;
        public int mouseX;
        public int mouseY;


        public string Str()
        {
            string s = "" + keyState + "," + keyNumber + "," + time + "," + mouseX + "," + mouseY;
            return s;
        }
    }


    public class RecordFileManage
    {
        string path;
        long startTime;
        List<RecordFile> list;
        public RecordFileManage(long startTime, string path)
        {
            list = new List<RecordFile>();
            this.startTime = startTime;
            this.path = path;
        }

        public void AddKeyboard(Keys key, int keyState, long time)
        {
            var rf = new RecordFile();
            rf.keyState = keyState;
            rf.keyNumber = (int)key;
            rf.time = time;
            list.Add(rf);
        }

        /// <summary>
        /// 添加鼠標(biāo)記錄
        /// </summary>
        /// <param name="key"></param>
        /// <param name="keyState">keyDown =0 ,keyUp =1</param>
        /// <param name="time"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        public void AddMouse(MouseButtons key, int keyState, long time, int x, int y)
        {
            var rf = new RecordFile();
            rf.keyState = keyState;
            rf.keyNumber = (int)key;
            rf.time = time;
            rf.mouseX = x;
            rf.mouseY = y;
            list.Add(rf);
        }


        public void SaveFile()
        {

            //為防止錯誤發(fā)生,按時間戳 從小到大排列
            var sortedList = list.OrderBy(row => row.time).ToList();

            // 追加模式
            string writePath = path;
            using (Stream outStream = new FileStream(writePath, FileMode.Append)) //Append:文件存在(在打開文件,流指向文件的末尾),文件不存在(創(chuàng)建一個新文件)
            using (var sw = new System.IO.StreamWriter(outStream, Encoding.UTF8))
            {
                sw.WriteLine(startTime + "");
                sortedList.ForEach(a =>
                {
                    sw.WriteLine(a.Str());
                });
            }
        }




        public static void RunFile(MyThread myThread,  object[] parameters)
        {
            var filePath = (string)parameters[0];
            if (string.IsNullOrEmpty(filePath) == true || System.IO.File.Exists(filePath) == false) return;

            var list = new List<RecordFile>();
            var File = new List<string>();

            using (Stream outStream = new FileStream(filePath, FileMode.Open)) //Append:文件存在(在打開文件,流指向文件的末尾),文件不存在(創(chuàng)建一個新文件)
            using (var sr = new System.IO.StreamReader(outStream, Encoding.UTF8))
            {
                string line = "";
                while ((line = sr.ReadLine()) != null)
                {
                    File.Add(line);
                }
            }

            long startTime = long.Parse(File[0]);
            if (File.Count > 0)
            {
                File.RemoveAt(0);
            }

            long lastTime = 0;



            File.ForEach(line =>
            {

                var rf = new RecordFile();
                var arr = line.Split(",");
                int i = 0;
                //鍵盤:2,97,1676246585895,0,0
                //鼠標(biāo):2,1048576,1676246584631,1034,581
                rf.keyState = int.Parse(arr[i++]);
                rf.keyNumber = int.Parse(arr[i++]);
                rf.time = long.Parse(arr[i++]);
                rf.mouseX = int.Parse(arr[i++]);
                rf.mouseY = int.Parse(arr[i++]);
                list.Add(rf);
            });

            // 根據(jù)time字段進(jìn)行從小到大的排序 
            var recordFiles = list.OrderBy(recordFile => recordFile.time).ToList();

            for(int n=0;n< recordFiles.Count;n++)
            {
                if (myThread.isRunning == false)
                {
                    break;//終止標(biāo)志
                }

                var rf = recordFiles[n];
                var delayTime = rf.time - startTime - lastTime;
                lastTime = rf.time - startTime;

                //string a = "delay = rf.time - startTime - lastTime :" + delayTime + " = " + rf.time + "-" + startTime + "-" + lastTime;
                // WinformExtension.WriteLineOnDisktopCreatTxtAndOpen(a);

                Thread.Sleep((int)(delayTime));

                if (rf.mouseX == 0)
                {//鍵盤事件
                    Keys key = (Keys)rf.keyNumber;
                    if (rf.keyState == 0)
                    {
                        KeyboardHelper.KeyDown(key);
                    }
                    else
                    {
                        KeyboardHelper.KeyUp(key);
                    }

                }
                else
                {//鼠標(biāo)事件

                    MouseButtons key = (MouseButtons)rf.keyNumber;
                    MouseEventFlags mfKey = MouseHelper.MouseEventFlags_To_MouseButtons(key, rf.keyState);
                    MouseHelper.KeyDownOrUp(mfKey, rf.mouseX, rf.mouseY);

                }
            }


        }

    }

    public class RecordFileManage_V2
    {
        string path;
        List<RecordFile> list;
        public RecordFileManage_V2(string path)
        {
            list = new List<RecordFile>();
            this.path = path;
        }

        public void AddKeyboard(Keys key, int keyState, long time)
        {
            var rf = new RecordFile();
            rf.keyState = keyState;
            rf.keyNumber = (int)key;
            rf.time = time;
            list.Add(rf);
        }

        /// <summary>
        /// 添加鼠標(biāo)記錄
        /// </summary>
        /// <param name="key"></param>
        /// <param name="keyState">keyDown =0 ,keyUp =1</param>
        /// <param name="time"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        public void AddMouse(MouseButtons key, int keyState, long time, int x, int y)
        {
            var rf = new RecordFile();
            rf.keyState = keyState;
            rf.keyNumber = (int)key;
            rf.time = time;
            rf.mouseX = x;
            rf.mouseY = y;
            list.Add(rf);
        }




        public void SaveFile()
        {
            // 追加模式
            string writePath = path;
            using (Stream outStream = new FileStream(writePath, FileMode.OpenOrCreate)) //Append:文件存在(在打開文件,流指向文件的末尾),文件不存在(創(chuàng)建一個新文件)
            using (var sw = new System.IO.StreamWriter(outStream, Encoding.UTF8))
            {
                Form1.textBox1Static.Text.DelEmptyLines().Split("\n").ToList().ForEach(a =>
                {
                    sw.Write(a);
                });
            }
        }



        static string[] mouseEvents =
            {
                    "MoveTo",
                    "LeftDown", "LeftUp" ,
                    "RightDown", "RightDown" ,
                    "MiddleDown", "MiddleUp" ,
            };


        public static void Run(MyThread myThread, object[] parameters)
        {

            string str = (string)parameters[0];
            if (string.IsNullOrEmpty(str) == true) return;



            Dictionary<string, MouseEventFlags> mouseDic = new Dictionary<string, MouseEventFlags>();
            mouseDic.Add("MoveTo", MouseEventFlags.Move);
            mouseDic.Add("LeftDown", MouseEventFlags.LeftDown);
            mouseDic.Add("LeftUp", MouseEventFlags.LeftUp);
            mouseDic.Add("RightDown", MouseEventFlags.RightDown);
            mouseDic.Add("RightUp", MouseEventFlags.RightUp);
            mouseDic.Add("MiddleDown", MouseEventFlags.MiddleDown);
            mouseDic.Add("MiddleUp", MouseEventFlags.MiddleUp);


            var list = new List<RecordFile>();
            var File = new List<string>();

            var allLine = str.Split("\r\n");
            allLine.ToList().ForEach(a =>
            {
                if (a.IsEmptyLine_Contontaining_Blank_Character())
                {
                    //不添加空行
                }
                else
                {

                    File.Add(a);
                }
            });


            int x = 0, y = 0;
            for (int i = 0; i < File.Count; i++)
            {

                if (myThread.isRunning == false)
                {
                    break;//終止標(biāo)志
                }

                var line = File[i];
                string copyLine = string.Copy(line);

                string currName = "Delay ";
                if (copyLine.Contains(currName))
                {
                    int delayTime = int.Parse(copyLine.Del(currName));
                    Thread.Sleep(delayTime);
                    continue;
                }





                bool isMouseEvent = false;
                string a = "";
                for (int j = 0; j < mouseEvents.Length; j++)
                {
                    if (line.Contains(mouseEvents[j]))
                    {
                        a = mouseEvents[j];
                        isMouseEvent = true;
                        break;
                    }
                }


                if (isMouseEvent == true)
                {
                    isMouseEvent = line.Contains(a);
                    //MoveTo 913, 631
                    if (a == "MoveTo")
                    {
                        string[] arr = copyLine.Del(a + " ").Split(", ");
                        if (arr.Length == 2)
                        {
                            x = int.Parse(arr[0]);
                            y = int.Parse(arr[1]);
                        }
                        else
                        {
                            throw new Exception("鼠標(biāo)坐標(biāo)解析失敗 丟失");
                        }
                    }

                    MouseHelper.KeyDownOrUp(mouseDic[a], x, y);
                    continue;
                }



                //解析鍵盤事件
                //KeyDown "D2", 1
                //KeyUp "D2", 1

                string[] keyEvents = { "KeyDown", "KeyUp" };

                if (line.Contains(keyEvents[0]))
                {
                    //var t = line.Del(keyEvents[0] + " ");
                    //var t1 = line.Del(keyEvents[0] + " ").Split(", ");
                    //var t2 = line.Del(keyEvents[0] + " ").Split(", ")[0];
                    //var t3 = line.Del(keyEvents[0] + " ").Split(", ")[0].Replace("\"", "");
                    //var t4 = (Keys)Enum.Parse(typeof(Keys), line.Del(keyEvents[0] + " ").Split(", ")[0].Del("\""));

                    Keys key = (Keys)Enum.Parse(typeof(Keys), line.Del(keyEvents[0] + " ").Split(", ")[0].Del("\""));
                    KeyboardHelper.KeyDown(key);
                }
                if (line.Contains(keyEvents[1]))
                {
                    Keys key = (Keys)Enum.Parse(typeof(Keys), line.Del(keyEvents[1] + " ").Split(", ")[0].Del("\""));
                    KeyboardHelper.KeyUp(key);
                }

            }
        }

        public static void RunFile(string filePath)
        {
            if (string.IsNullOrEmpty(filePath) == true || System.IO.File.Exists(filePath) == false) return;
            string str = "";
            using (Stream outStream = new FileStream(filePath, FileMode.Open)) //Append:文件存在(在打開文件,流指向文件的末尾),文件不存在(創(chuàng)建一個新文件)
            using (var sr = new System.IO.StreamReader(outStream, Encoding.UTF8))
            {
                str =sr.ReadToEnd();
            }

            MyThread thread1 = new MyThread();
            thread1.Bind(RecordFileManage_V2.Run, str);
            thread1.Start();
            Form1.myThreads.Add(thread1);

        }
    }

    public enum KState
    {
        Null,
        Recording,
        Runing,
    }
}


using System;
using System.Windows.Forms;
using MouseKeyboardActivityMonitor.WinApi;

namespace MouseKeyboardActivityMonitor
{
    /// <summary>
    /// This class monitors all keyboard activities and provides appropriate events.
    /// </summary>
    public class KeyboardHookListener : BaseHookListener
    {
        /// <summary>
        /// Initializes a new instance of <see cref="KeyboardHookListener"/>.
        /// </summary>
        /// <param name="hooker">Depending on this parameter the listener hooks either application or global keyboard events.</param>
        /// <remarks>Hooks are not active after instantiation. You need to use either <see cref="BaseHookListener.Enabled"/> property or call <see cref="BaseHookListener.Start"/> method.</remarks>
        public KeyboardHookListener(Hooker hooker)
            : base(hooker)
        {
        }

        /// <summary>
        /// This method processes the data from the hook and initiates event firing.
        /// </summary>
        /// <param name="wParam">The first Windows Messages parameter.</param>
        /// <param name="lParam">The second Windows Messages parameter.</param>
        /// <returns>
        /// True - The hook will be passed along to other applications.
        /// <para>
        /// False - The hook will not be given to other applications, effectively blocking input.
        /// </para>
        /// </returns>
        protected override bool ProcessCallback(int wParam, IntPtr lParam)
        {
            KeyEventArgsExt e = KeyEventArgsExt.FromRawData(wParam, lParam, IsGlobal);

            InvokeKeyDown(e);
            InvokeKeyPress(wParam, lParam);
            InvokeKeyUp(e);

            return !e.Handled;
        }

        /// <summary>
        /// Returns the correct hook id to be used for <see cref="Hooker.SetWindowsHookEx"/> call.
        /// </summary>
        /// <returns>WH_KEYBOARD (0x02) or WH_KEYBOARD_LL (0x13) constant.</returns>
        protected override int GetHookId()
        {
            return IsGlobal ? 
                GlobalHooker.WH_KEYBOARD_LL : 
                AppHooker.WH_KEYBOARD;
        }

        /// <summary>
        /// Occurs when a key is preseed. 
        /// </summary>
        public event KeyEventHandler KeyDown;

        private void InvokeKeyDown(KeyEventArgsExt e)
        {
            KeyEventHandler handler = KeyDown;
            if (handler == null || e.Handled || !e.IsKeyDown) { return; }
            handler(this, e);
        }

        /// <summary>
        /// Occurs when a key is pressed.
        /// </summary>
        /// <remarks>
        /// Key events occur in the following order: 
        /// <list type="number">
        /// <item>KeyDown</item>
        /// <item>KeyPress</item>
        /// <item>KeyUp</item>
        /// </list>
        ///The KeyPress event is not raised by noncharacter keys; however, the noncharacter keys do raise the KeyDown and KeyUp events. 
        ///Use the KeyChar property to sample keystrokes at run time and to consume or modify a subset of common keystrokes. 
        ///To handle keyboard events only in your application and not enable other applications to receive keyboard events, 
        ///set the <see cref="KeyPressEventArgs.Handled"/> property in your form's KeyPress event-handling method to <b>true</b>. 
        /// </remarks>
        public event KeyPressEventHandler KeyPress;

        private void InvokeKeyPress(int wParam, IntPtr lParam)
        {
            InvokeKeyPress(KeyPressEventArgsExt.FromRawData(wParam, lParam, IsGlobal));
        }

        private void InvokeKeyPress(KeyPressEventArgsExt e)
        {
            KeyPressEventHandler handler = KeyPress;
            if (handler == null || e.Handled || e.IsNonChar) { return; }
            handler(this, e);
        }

        /// <summary>
        /// Occurs when a key is released. 
        /// </summary>
        public event KeyEventHandler KeyUp;

        private void InvokeKeyUp(KeyEventArgsExt e)
        {
            KeyEventHandler handler = KeyUp;
            if (handler == null || e.Handled || !e.IsKeyUp) { return; }
            handler(this, e);
        }

        /// <summary>
        /// Release delegates, unsubscribes from hooks.
        /// </summary>
        /// <filterpriority>2</filterpriority>
        public override void Dispose()
        {
            KeyPress = null;
            KeyDown = null;
            KeyUp = null;

            base.Dispose();
        }
    }
}
using System;
using System.Windows.Forms;
using MouseKeyboardActivityMonitor.WinApi;

namespace MouseKeyboardActivityMonitor
{
	/// <summary>
	/// This class monitors all mouse activities and provides appropriate events.
	/// </summary>
	public class MouseHookListener : BaseHookListener
	{

		private Point m_PreviousPosition;
        private int m_PreviousClickedTime;
		private MouseButtons m_PreviousClicked;
		private MouseButtons m_DownButtonsWaitingForMouseUp;
		private MouseButtons m_SuppressButtonUpFlags;
        private int m_SystemDoubleClickTime;

		/// <summary>
		/// Initializes a new instance of <see cref="MouseHookListener"/>.
		/// </summary>
		/// <param name="hooker">Depending on this parameter the listener hooks either application or global mouse events.</param>
		/// <remarks>
        /// Hooks are not active after installation. You need to use either <see cref="BaseHookListener.Enabled"/> property or call <see cref="BaseHookListener.Start"/> method.
        /// </remarks>
		public MouseHookListener(Hooker hooker)
			: base(hooker)
		{
			m_PreviousPosition = new Point(-1, -1);
            m_PreviousClickedTime = 0;
			m_DownButtonsWaitingForMouseUp = MouseButtons.None;
            m_SuppressButtonUpFlags = MouseButtons.None;
			m_PreviousClicked = MouseButtons.None;
            m_SystemDoubleClickTime = Mouse.GetDoubleClickTime();
		}

        //##################################################################
        #region ProcessCallback and related subroutines

        /// <summary>
        /// This method processes the data from the hook and initiates event firing.
        /// </summary>
        /// <param name="wParam">The first Windows Messages parameter.</param>
        /// <param name="lParam">The second Windows Messages parameter.</param>
        /// <returns>
        /// True - The hook will be passed along to other applications.
        /// <para>
        /// False - The hook will not be given to other applications, effectively blocking input.
        /// </para>
        /// </returns>
        protected override bool ProcessCallback(int wParam, IntPtr lParam)
        {
            MouseEventExtArgs e = MouseEventExtArgs.FromRawData(wParam, lParam, IsGlobal);

            if (e.IsMouseKeyDown)
            {
                ProcessMouseDown(ref e);
            }

            if (e.Clicks == 1 && e.IsMouseKeyUp && !e.Handled)
            {
                ProcessMouseClick(ref e);
            }

            if (e.Clicks == 2 && !e.Handled)
            {
                InvokeMouseEventHandler(MouseDoubleClick, e);
            }

            if (e.IsMouseKeyUp)
            {
                ProcessMouseUp(ref e);
            }

            if (e.WheelScrolled)
            {
                InvokeMouseEventHandler(MouseWheel, e);
            }

            if (HasMoved(e.Point))
            {
                ProcessMouseMove(ref e);
            }

            return !e.Handled;
        }

        private void ProcessMouseDown(ref MouseEventExtArgs e)
        {
            if (IsGlobal)
            {
                ProcessPossibleDoubleClick(ref e);
            }
            else
            {
                // These are only used for global. No need for them in AppHooks
                m_DownButtonsWaitingForMouseUp = MouseButtons.None;
                m_PreviousClicked = MouseButtons.None;
                m_PreviousClickedTime = 0;
            } 
            

            InvokeMouseEventHandler(MouseDown, e);
            InvokeMouseEventHandlerExt(MouseDownExt, e);
            if (e.Handled)
            {
                SetSupressButtonUpFlag(e.Button);
                e.Handled = true;
            }
        }

        private void ProcessPossibleDoubleClick(ref MouseEventExtArgs e)
        {
            if (IsDoubleClick(e.Button, e.Timestamp))
            {
                e = e.ToDoubleClickEventArgs();
                m_DownButtonsWaitingForMouseUp = MouseButtons.None;
                m_PreviousClicked = MouseButtons.None;
                m_PreviousClickedTime = 0;
            }
            else
            {
                m_DownButtonsWaitingForMouseUp |= e.Button;
                m_PreviousClickedTime = e.Timestamp;
            }
        }

        private void ProcessMouseClick(ref MouseEventExtArgs e)
        {
            if ((m_DownButtonsWaitingForMouseUp & e.Button) != MouseButtons.None)
            {
                m_PreviousClicked = e.Button;
                m_DownButtonsWaitingForMouseUp = MouseButtons.None;
                InvokeMouseEventHandler(MouseClick, e);
                InvokeMouseEventHandlerExt(MouseClickExt, e);
            }
        }

        private void ProcessMouseUp(ref MouseEventExtArgs e)
        {
            if (!HasSupressButtonUpFlag(e.Button))
            {
                InvokeMouseEventHandler(MouseUp, e);
            }
            else
            {
                RemoveSupressButtonUpFlag(e.Button);
                e.Handled = true;
            }
        }

        private void ProcessMouseMove(ref MouseEventExtArgs e)
        {
            m_PreviousPosition = e.Point;

            InvokeMouseEventHandler(MouseMove, e);
            InvokeMouseEventHandlerExt(MouseMoveExt, e);
        }

        #endregion

        private void RemoveSupressButtonUpFlag(MouseButtons button)
		{
			m_SuppressButtonUpFlags = m_SuppressButtonUpFlags ^ button;
		}

		private bool HasSupressButtonUpFlag(MouseButtons button)
		{
			return (m_SuppressButtonUpFlags & button) != 0;
		}

		private void SetSupressButtonUpFlag(MouseButtons button)
		{
			m_SuppressButtonUpFlags = m_SuppressButtonUpFlags | button;
		}

		/// <summary>
		/// Returns the correct hook id to be used for <see cref="Hooker.SetWindowsHookEx"/> call.
		/// </summary>
		/// <returns>WH_MOUSE (0x07) or WH_MOUSE_LL (0x14) constant.</returns>
		protected override int GetHookId()
		{
			return IsGlobal ?
				GlobalHooker.WH_MOUSE_LL :
				AppHooker.WH_MOUSE;
		}

		private bool HasMoved(Point actualPoint)
		{
			return m_PreviousPosition != actualPoint;
		}

		private bool IsDoubleClick(MouseButtons button, int timestamp)
		{
            return
                button == m_PreviousClicked &&
                timestamp - m_PreviousClickedTime <= m_SystemDoubleClickTime; // Mouse.GetDoubleClickTime();
		}

		private void InvokeMouseEventHandler(MouseEventHandler handler, MouseEventArgs e)
		{
			if (handler != null)
			{
				handler(this, e);
			}
		}


		private void InvokeMouseEventHandlerExt(EventHandler<MouseEventExtArgs> handler, MouseEventExtArgs e)
		{
			if (handler != null)
			{
				handler(this, e);
			}
		}

		/// <summary>
		/// Occurs when the mouse pointer is moved.
		/// </summary>
		public event MouseEventHandler MouseMove;

		/// <summary>
		/// Occurs when the mouse pointer is moved.
		/// </summary>
		/// <remarks>
		/// This event provides extended arguments of type <see cref = "MouseEventArgs" /> enabling you to 
		/// supress further processing of mouse movement in other applications.
		/// </remarks>
		public event EventHandler<MouseEventExtArgs> MouseMoveExt;

		/// <summary>
		/// Occurs when a click was performed by the mouse.
		/// </summary>
		public event MouseEventHandler MouseClick;

		/// <summary>
		/// Occurs when a click was performed by the mouse.
		/// </summary>
		/// <remarks>
		/// This event provides extended arguments of type <see cref = "MouseEventArgs" /> enabling you to 
		/// supress further processing of mouse click in other applications.
		/// </remarks>
		[Obsolete("To supress mouse clicks use MouseDownExt event instead.")]
		public event EventHandler<MouseEventExtArgs> MouseClickExt;

		/// <summary>
		/// Occurs when the mouse a mouse button is pressed.
		/// </summary>
		public event MouseEventHandler MouseDown;

		/// <summary>
		/// Occurs when the mouse a mouse button is pressed.
		/// </summary>
		/// <remarks>
		/// This event provides extended arguments of type <see cref = "MouseEventArgs" /> enabling you to 
		/// supress further processing of mouse click in other applications.
		/// </remarks>
		public event EventHandler<MouseEventExtArgs> MouseDownExt;

		/// <summary>
		/// Occurs when a mouse button is released.
		/// </summary>
		public event MouseEventHandler MouseUp;

		/// <summary>
		/// Occurs when the mouse wheel moves.
		/// </summary>
		public event MouseEventHandler MouseWheel;

		/// <summary>
		/// Occurs when a mouse button is double-clicked.
		/// </summary>
		public event MouseEventHandler MouseDoubleClick;

		/// <summary>
		/// Release delegates, unsubscribes from hooks.
		/// </summary>
		/// <filterpriority>2</filterpriority>
		public override void Dispose()
		{
			MouseClick = null;
			MouseClickExt = null;
			MouseDown = null;
			MouseDownExt = null;
			MouseMove = null;
			MouseMoveExt = null;
			MouseUp = null;
			MouseWheel = null;
			MouseDoubleClick = null;
			base.Dispose();
		}
	}
}

到了這里,關(guān)于C# 實(shí)現(xiàn)按鍵精靈 記錄錄制鍵盤鼠標(biāo)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • C#實(shí)現(xiàn)鍵盤鼠標(biāo)模擬器

    C#實(shí)現(xiàn)鍵盤鼠標(biāo)模擬器

    下面程序可指定一連串重復(fù)動作,按順序執(zhí)行 ? using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Drawing; using System.IO; using System.Text.RegularExpressions; using System.Windows.Forms; namespace Simulator { ? ? public partial class Form1 : Form ? ? { ? ? ? ? [System.Runtime.InteropServices.DllImp

    2024年02月16日
    瀏覽(27)
  • C# 實(shí)現(xiàn)全局鼠標(biāo)鉤子操作以及發(fā)送鍵盤事件

    C# 實(shí)現(xiàn)全局鼠標(biāo)鉤子操作以及發(fā)送鍵盤事件

    全局鉤子定義 winfrom窗體代碼: 效果截圖:

    2024年02月05日
    瀏覽(28)
  • WinFrom、C# 學(xué)習(xí)記錄五 開發(fā)一個鼠標(biāo)自動點(diǎn)擊小軟件

    WinFrom、C# 學(xué)習(xí)記錄五 開發(fā)一個鼠標(biāo)自動點(diǎn)擊小軟件

    ? ? ? ? 經(jīng)常會被問到需要點(diǎn)擊軟件的,主要都是玩游戲的盆友,但是也有其它用途的。所以簡單弄了一個,打算每當(dāng)有時間,有需求,就加一些小功能。 ? ? ? ? 這里主要是要記錄一下相關(guān)開發(fā)工作,也記錄一些使用/更新的信息。 ????????【2022/08/22】版本v1.0(初始版

    2024年02月16日
    瀏覽(94)
  • 鼠標(biāo)驅(qū)動框架:模擬鍵盤按鍵

    裝載該驅(qū)動時,首先要卸載原本內(nèi)核自帶的驅(qū)動程序 # 把USB鼠標(biāo)查到開發(fā)板上 # 先看看原來有哪些設(shè)備節(jié)點(diǎn) ls /dev/input/event* # 安裝驅(qū)動程序 insmod usbmouse_as_key.ko # 再看看新得到了哪個設(shè)備節(jié)點(diǎn) ls /dev/input/event* # 執(zhí)行命令, 假設(shè)event4是新節(jié)點(diǎn) hexdump /dev/input/event4 # 點(diǎn)擊鼠標(biāo)按鍵即

    2024年01月16日
    瀏覽(27)
  • 按鍵精靈  屏蔽小精靈界面 改進(jìn)實(shí)現(xiàn)

    按鍵精靈 屏蔽小精靈界面 改進(jìn)實(shí)現(xiàn)

    最近沉迷于按鍵精靈這種簡單的,功能少,又不需要太多考慮類型的語言,來釋放雙手 在論壇搜索遇到的問題,瀏覽帖子的時候,發(fā)現(xiàn)了一個功能,“屏蔽小精靈界面” 原帖連接: 輕松屏蔽小精靈界面,實(shí)現(xiàn)自定義界面 _ 綜合討論 - 按鍵精靈論壇 (anjian.com) 我就照著在我寫

    2024年02月14日
    瀏覽(130)
  • C# Windows登錄界面進(jìn)行截圖,控制鼠標(biāo)鍵盤等操作實(shí)現(xiàn)(二)

    上一篇:C# Windows登錄界面進(jìn)行截圖,控制鼠標(biāo)鍵盤等操作實(shí)現(xiàn)(一) - log9527 - 博客園 (cnblogs.com)?我們了解了要實(shí)現(xiàn)在Windows登錄界面進(jìn)行截圖等操作必須滿足的條件,這一篇我們主要通過代碼實(shí)現(xiàn)這些條件。 首先先建一個項目A 下面一些windows自帶非托管dll的調(diào)用類。 外部調(diào)用

    2024年02月12日
    瀏覽(19)
  • C# Windows登錄界面進(jìn)行截圖,控制鼠標(biāo)鍵盤等操作實(shí)現(xiàn)(三)

    在Windows登錄界面進(jìn)行截圖,目前嘗試到的以下的截圖方法可以截取到圖,其它的方式要么卡住,要么截出來是黑屏的,直接上代碼: 操作鼠標(biāo)鍵盤等操作可以參考本人另一篇文章:使用C#制作可以錄制自動化執(zhí)行Windows操作腳本工具——類似于按鍵精靈 - log9527 - 博客園 (cnbl

    2024年02月12日
    瀏覽(17)
  • Python實(shí)現(xiàn)按鍵精靈功能

    最近一個小游戲挺火的,羊了個羊,很多程序員都通過后臺破解代碼讓道具無限,讓關(guān)卡重復(fù)第一關(guān)等等來實(shí)現(xiàn)通關(guān),但技術(shù)不夠,代碼來湊,想著游戲還有一定的幾率可以通關(guān),無非就是要多試幾把,那要不寫個程序讓電腦無限的自動匹配點(diǎn)擊。 第一想法是用按鍵精靈,但

    2024年02月06日
    瀏覽(21)
  • Linux輸入設(shè)備應(yīng)用編程(鍵盤,按鍵,觸摸屏,鼠標(biāo))

    Linux輸入設(shè)備應(yīng)用編程(鍵盤,按鍵,觸摸屏,鼠標(biāo))

    目錄 一 輸入設(shè)備編程介紹 1.1?什么是輸入設(shè)備呢? ?1.2 什么是輸入設(shè)備的應(yīng)用編程?? ?1.3 input子系統(tǒng) 1.4? 數(shù)據(jù)讀取流程 1.5 應(yīng)用程序如何解析數(shù)據(jù) 1.5.1 按鍵類事件: ?1.5.2 相對位移事件? 1.5.3 絕對位移事件? 二 讀取 struct input_event數(shù)據(jù)?? 本章學(xué)習(xí)Linux輸入設(shè)備的應(yīng)用編程

    2024年02月05日
    瀏覽(39)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包