开启辅助访问 切换到宽版

精易论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

用微信号发送消息登录论坛

新人指南 邀请好友注册 - 我关注人的新帖 教你赚取精币 - 每日签到


求职/招聘- 论坛接单- 开发者大厅

论坛版规 总版规 - 建议/投诉 - 应聘版主 - 精华帖总集 积分说明 - 禁言标准 - 有奖举报

查看: 192|回复: 1
收起左侧

[C#源码] c#重构狮子头扣字软件源码

[复制链接]
结帖率:100% (1/1)
发表于 2025-2-11 16:50:22 | 显示全部楼层 |阅读模式   河北省廊坊市
本帖最后由 chenn 于 2025-2-11 17:09 编辑

1.png
核心代码:
[C#] 纯文本查看 复制代码
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace shizi
{
    public partial class Form1 : Form
    {
        private const int WM_HOTKEY = 0x0312;
        private const int ID_F8 = 9000;

        private const int ID_F7 = 2000;
        int count;
        int total = 0;
        bool switch1;
        string[] Returnlines;
        bool switch2;

        [DllImport("user32.dll")]
        private static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk);

        [DllImport("user32.dll")]
        private static extern bool UnregisterHotKey(IntPtr hWnd, int id);

        public Form1()
        {
            InitializeComponent();
            this.FormClosing += new FormClosingEventHandler(Form1_FormClosing);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            RegisterHotKey(this.Handle, ID_F8, 0, (uint)Keys.F8);

            RegisterHotKey(this.Handle, ID_F7, 0, (uint)Keys.F7);

        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            UnregisterHotKey(this.Handle, ID_F8);

            UnregisterHotKey(this.Handle, ID_F7);
        }

        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);
            if (m.Msg == WM_HOTKEY && m.WParam.ToInt32() == ID_F8)
            {
                if (textBox_路径.Text == "")
                {
                    MessageBox.Show("请先导入词汇后再进行操作");
                    return;
                }


                if (switch1 == true)
                {
                    switch1 = false;
                    return;
                }
                if (switch1 == false)
                {
                    switch1 = true;
                    initiateAsync();
                    return;
                }




            }

            if (m.Msg == WM_HOTKEY && m.WParam.ToInt32() == ID_F7)
            {
                if (switch2 == true)
                {
                    switch2 = false;
                    this.Hide();
                    return;
                }
                if (switch2 == false)
                {
                    switch2 = true;
                    this.Show();
                    return;
                }




            }
        }
        private async Task initiateAsync()
        {

            Random random = new Random();
            int min = int.Parse(textBox_毫秒.Text);
            int max = int.Parse(textBox_毫秒1.Text);
            int randomNumber = random.Next(min, max + 1);
            count = int.Parse(textBox_行.Text);
            while(1+1==2)
            {
                

                char[] Returntext = Returnlines[count].ToCharArray();

                for (int a = 0; a < Returntext.Length; a++)
                {
                   
                    SendKeys.Send(Returntext[a].ToString());
                    await Task.Delay(randomNumber);
                }
                
               
                if (comboBox_发送.SelectedIndex == 0)
                {
                    SendKeys.Send("{ENTER}");
                }
                else if (comboBox_发送.SelectedIndex == 1)
                {
                    SendKeys.Send("^{ENTER}");
                }

                if (checkBox_行.Checked == true)
                {
                    count++;
                }
                else
                {
                    count++;
                    if (count >= total)
                    {

                        switch1 = false;
                        break;
                    }

                }
                textBox_运行行.Text = count.ToString();
                textBox_行.Text = count.ToString();
                if (count >= Returnlines.Length)
                {
                    count = 0;
                }

                if (switch1 == false)
                {
                    break;
                }
                Application.DoEvents();
            }
        }

        private void button_导入_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*";
            openFileDialog.Multiselect = true;

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                foreach (string file in openFileDialog.FileNames)
                {

                    textBox_路径.Text = file;
                    string filePath = textBox_路径.Text;
                    string content = File.ReadAllText(filePath);
                    Returnlines = content.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                    total = Returnlines.Length;
                    textBox_总行.Text = Returnlines.Length.ToString();
                }
            }
        }

        private void button_软件介绍_Click(object sender, EventArgs e)
        {
            MessageBox.Show("本款软件为c#重构版本f8为启动/关闭----f7隐藏/显示", "软件介绍");

        }
    }
}


布局代码:
[C#] 纯文本查看 复制代码
namespace shizi
{
    partial class Form1
    {
        /// <summary>
        /// 必需的设计器变量。
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// 清理所有正在使用的资源。
        /// </summary>
        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows 窗体设计器生成的代码

        /// <summary>
        /// 设计器支持所需的方法 - 不要修改
        /// 使用代码编辑器修改此方法的内容。
        /// </summary>
        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.button_软件介绍 = new System.Windows.Forms.Button();
            this.comboBox_发送 = new System.Windows.Forms.ComboBox();
            this.checkBox_行 = new System.Windows.Forms.CheckBox();
            this.label7 = new System.Windows.Forms.Label();
            this.textBox_行 = new System.Windows.Forms.TextBox();
            this.label6 = new System.Windows.Forms.Label();
            this.label5 = new System.Windows.Forms.Label();
            this.textBox_毫秒1 = new System.Windows.Forms.TextBox();
            this.label4 = new System.Windows.Forms.Label();
            this.textBox_毫秒 = new System.Windows.Forms.TextBox();
            this.label3 = new System.Windows.Forms.Label();
            this.button_导入 = new System.Windows.Forms.Button();
            this.textBox_路径 = new System.Windows.Forms.TextBox();
            this.label2 = new System.Windows.Forms.Label();
            this.label1 = new System.Windows.Forms.Label();
            this.groupBox2 = new System.Windows.Forms.GroupBox();
            this.textBox_运行行 = new System.Windows.Forms.TextBox();
            this.label8 = new System.Windows.Forms.Label();
            this.textBox_总行 = new System.Windows.Forms.TextBox();
            this.groupBox1.SuspendLayout();
            this.groupBox2.SuspendLayout();
            this.SuspendLayout();
            // 
            // groupBox1
            // 
            this.groupBox1.Controls.Add(this.button_软件介绍);
            this.groupBox1.Controls.Add(this.comboBox_发送);
            this.groupBox1.Controls.Add(this.checkBox_行);
            this.groupBox1.Controls.Add(this.label7);
            this.groupBox1.Controls.Add(this.textBox_行);
            this.groupBox1.Controls.Add(this.label6);
            this.groupBox1.Controls.Add(this.label5);
            this.groupBox1.Controls.Add(this.textBox_毫秒1);
            this.groupBox1.Controls.Add(this.label4);
            this.groupBox1.Controls.Add(this.textBox_毫秒);
            this.groupBox1.Controls.Add(this.label3);
            this.groupBox1.Controls.Add(this.button_导入);
            this.groupBox1.Controls.Add(this.textBox_路径);
            this.groupBox1.Controls.Add(this.label2);
            this.groupBox1.Controls.Add(this.label1);
            this.groupBox1.Location = new System.Drawing.Point(2, 2);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(277, 144);
            this.groupBox1.TabIndex = 0;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "设置";
            // 
            // button_软件介绍
            // 
            this.button_软件介绍.Location = new System.Drawing.Point(135, 112);
            this.button_软件介绍.Name = "button_软件介绍";
            this.button_软件介绍.Size = new System.Drawing.Size(123, 23);
            this.button_软件介绍.TabIndex = 14;
            this.button_软件介绍.Text = "软件介绍";
            this.button_软件介绍.UseVisualStyleBackColor = true;
            this.button_软件介绍.Click += new System.EventHandler(this.button_软件介绍_Click);
            // 
            // comboBox_发送
            // 
            this.comboBox_发送.FormattingEnabled = true;
            this.comboBox_发送.Items.AddRange(new object[] {
            "Enter发送",
            "Ctrl+Enter发送"});
            this.comboBox_发送.Location = new System.Drawing.Point(8, 114);
            this.comboBox_发送.Name = "comboBox_发送";
            this.comboBox_发送.Size = new System.Drawing.Size(121, 20);
            this.comboBox_发送.TabIndex = 13;
            this.comboBox_发送.Text = "Enter发送";
            // 
            // checkBox_行
            // 
            this.checkBox_行.AutoSize = true;
            this.checkBox_行.Checked = true;
            this.checkBox_行.CheckState = System.Windows.Forms.CheckState.Checked;
            this.checkBox_行.Location = new System.Drawing.Point(138, 90);
            this.checkBox_行.Name = "checkBox_行";
            this.checkBox_行.Size = new System.Drawing.Size(120, 16);
            this.checkBox_行.TabIndex = 12;
            this.checkBox_行.Text = "运行完回到第一行";
            this.checkBox_行.UseVisualStyleBackColor = true;
            // 
            // label7
            // 
            this.label7.AutoSize = true;
            this.label7.Location = new System.Drawing.Point(94, 92);
            this.label7.Name = "label7";
            this.label7.Size = new System.Drawing.Size(41, 12);
            this.label7.TabIndex = 11;
            this.label7.Text = "行开始";
            // 
            // textBox_行
            // 
            this.textBox_行.Location = new System.Drawing.Point(45, 87);
            this.textBox_行.Name = "textBox_行";
            this.textBox_行.Size = new System.Drawing.Size(43, 21);
            this.textBox_行.TabIndex = 10;
            this.textBox_行.Text = "0";
            // 
            // label6
            // 
            this.label6.AutoSize = true;
            this.label6.Location = new System.Drawing.Point(10, 91);
            this.label6.Name = "label6";
            this.label6.Size = new System.Drawing.Size(29, 12);
            this.label6.TabIndex = 9;
            this.label6.Text = "从第";
            // 
            // label5
            // 
            this.label5.AutoSize = true;
            this.label5.Location = new System.Drawing.Point(185, 65);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(29, 12);
            this.label5.TabIndex = 8;
            this.label5.Text = "毫秒";
            // 
            // textBox_毫秒1
            // 
            this.textBox_毫秒1.Location = new System.Drawing.Point(138, 61);
            this.textBox_毫秒1.Name = "textBox_毫秒1";
            this.textBox_毫秒1.Size = new System.Drawing.Size(43, 21);
            this.textBox_毫秒1.TabIndex = 7;
            this.textBox_毫秒1.Text = "30";
            // 
            // label4
            // 
            this.label4.AutoSize = true;
            this.label4.Location = new System.Drawing.Point(121, 67);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(11, 12);
            this.label4.TabIndex = 6;
            this.label4.Text = "-";
            // 
            // textBox_毫秒
            // 
            this.textBox_毫秒.Location = new System.Drawing.Point(71, 60);
            this.textBox_毫秒.Name = "textBox_毫秒";
            this.textBox_毫秒.Size = new System.Drawing.Size(43, 21);
            this.textBox_毫秒.TabIndex = 5;
            this.textBox_毫秒.Text = "10";
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(6, 66);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(59, 12);
            this.label3.TabIndex = 4;
            this.label3.Text = "按键间隔:";
            // 
            // button_导入
            // 
            this.button_导入.Location = new System.Drawing.Point(189, 32);
            this.button_导入.Name = "button_导入";
            this.button_导入.Size = new System.Drawing.Size(75, 23);
            this.button_导入.TabIndex = 3;
            this.button_导入.Text = "导入";
            this.button_导入.UseVisualStyleBackColor = true;
            this.button_导入.Click += new System.EventHandler(this.button_导入_Click);
            // 
            // textBox_路径
            // 
            this.textBox_路径.Location = new System.Drawing.Point(13, 33);
            this.textBox_路径.Name = "textBox_路径";
            this.textBox_路径.ReadOnly = true;
            this.textBox_路径.Size = new System.Drawing.Size(171, 21);
            this.textBox_路径.TabIndex = 2;
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.ForeColor = System.Drawing.Color.Red;
            this.label2.Location = new System.Drawing.Point(123, 17);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(155, 12);
            this.label2.TabIndex = 1;
            this.label2.Text = "※请切换为智能ABC输入法!";
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(10, 17);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(107, 12);
            this.label1.TabIndex = 0;
            this.label1.Text = "模拟扣字代码文件:";
            // 
            // groupBox2
            // 
            this.groupBox2.Controls.Add(this.textBox_运行行);
            this.groupBox2.Controls.Add(this.label8);
            this.groupBox2.Controls.Add(this.textBox_总行);
            this.groupBox2.Location = new System.Drawing.Point(3, 153);
            this.groupBox2.Name = "groupBox2";
            this.groupBox2.Size = new System.Drawing.Size(271, 58);
            this.groupBox2.TabIndex = 1;
            this.groupBox2.TabStop = false;
            this.groupBox2.Text = "运行信息";
            // 
            // textBox_运行行
            // 
            this.textBox_运行行.Location = new System.Drawing.Point(176, 24);
            this.textBox_运行行.Name = "textBox_运行行";
            this.textBox_运行行.ReadOnly = true;
            this.textBox_运行行.Size = new System.Drawing.Size(89, 21);
            this.textBox_运行行.TabIndex = 6;
            // 
            // label8
            // 
            this.label8.AutoSize = true;
            this.label8.Location = new System.Drawing.Point(76, 28);
            this.label8.Name = "label8";
            this.label8.Size = new System.Drawing.Size(101, 12);
            this.label8.TabIndex = 5;
            this.label8.Text = "总行数:运行位置:";
            // 
            // textBox_总行
            // 
            this.textBox_总行.Location = new System.Drawing.Point(6, 24);
            this.textBox_总行.Name = "textBox_总行";
            this.textBox_总行.ReadOnly = true;
            this.textBox_总行.Size = new System.Drawing.Size(65, 21);
            this.textBox_总行.TabIndex = 3;
            // 
            // Form1
            // 
            this.AllowDrop = true;
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(283, 216);
            this.Controls.Add(this.groupBox2);
            this.Controls.Add(this.groupBox1);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "Form1";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "狮子头扣字软件";
            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
            this.Load += new System.EventHandler(this.Form1_Load);
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            this.groupBox2.ResumeLayout(false);
            this.groupBox2.PerformLayout();
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.GroupBox groupBox1;
        private System.Windows.Forms.Button button_导入;
        private System.Windows.Forms.TextBox textBox_路径;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Button button_软件介绍;
        private System.Windows.Forms.ComboBox comboBox_发送;
        private System.Windows.Forms.CheckBox checkBox_行;
        private System.Windows.Forms.Label label7;
        private System.Windows.Forms.TextBox textBox_行;
        private System.Windows.Forms.Label label6;
        private System.Windows.Forms.Label label5;
        private System.Windows.Forms.TextBox textBox_毫秒1;
        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.TextBox textBox_毫秒;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.GroupBox groupBox2;
        private System.Windows.Forms.TextBox textBox_运行行;
        private System.Windows.Forms.Label label8;
        private System.Windows.Forms.TextBox textBox_总行;
    }
}


版权©by辰楠
已经上传csdn:https://blog.csdn.net/qq_65208683/article/details/145575101?fromshare=blogdetail&sharetype=blogdetail&sharerId=145575101&sharerefer=PC&sharesource=qq_65208683&sharefrom=from_link

同时上传个人论坛:https://1987a.cn/forum.php?mod=viewthread&tid=143
(出处: 1987官方论坛)

自己搭建的易支fu:pay.1987a.cn(八年站长信誉

结帖率:100% (2/2)

签到天数: 21 天

发表于 2025-2-12 02:30:07 | 显示全部楼层   香港特别行政区*
感觉这个问题值得探讨,先关注。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 致发广告者

发布主题 收藏帖子 返回列表

sitemap| 易语言源码| 易语言教程| 易语言论坛| 易语言模块| 手机版| 广告投放| 精易论坛
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论,本站内容均为会员发表,并不代表精易立场!
论坛帖子内容仅用于技术交流学习和研究的目的,严禁用于非法目的,否则造成一切后果自负!如帖子内容侵害到你的权益,请联系我们!
防范网络诈骗,远离网络犯罪 违法和不良信息举报电话0663-3422125,QQ: 793400750,邮箱:wp@125.la
网站简介:精易论坛成立于2009年,是一个程序设计学习交流技术论坛,隶属于揭阳市揭东区精易科技有限公司所有。
Powered by Discuz! X3.4 揭阳市揭东区精易科技有限公司 ( 粤ICP备12094385号-1) 粤公网安备 44522102000125 增值电信业务经营许可证 粤B2-20192173

快速回复 返回顶部 返回列表