Windows系统简易操作工具箱

Windows系统简易操作工具箱


视频演示

SimpleToolBox使用情况及说明教程


前言

在日常使用Windows系统的过程中,经常会被同事或朋友请求修复电脑问题,于是心血来潮,根据这么多年来的使用体验和感悟,制作了这款免费可使用的简易小工具,同时也作为第一次接触C#学习成果的验收,于是一款基于.NET 的Windows系统简易操作工具箱应运而生。

提示:以下是本篇文章正文内容,下面案例仅供参考

一、发展过程

1.1 版本更新

该软件的设计经历了从最初1.0版本的设计构想,到2.0版本的图形化GUI设计,从2.0版本的雍容和界面单一到3.0版本的界面统一,从3.0版本的界面统一到界面的进一步美化,同时版本进行了相应的漏洞修复,加入了数字自签名,添加了界面显示信息和自动清除,软件在线安全下载等功能,基本上解决了中文编码乱码问题。

图1 版本更新
图2 更新过程
图3 更新过程

1.2功能开发

2.0版本只设计了一个主界面,只保证功能可以正常使用,其他界面不统一,界面不够美观。3.0版本逐步针对2.0版本边修复漏洞边添加新功能。3.2版本之后主要解决不同平台的适配问题,开发了针对X86,X64,ARM64平台的专用版本,3.3版本之后加入了数字签名,由于是自己制作的签名,所以需要用户手动安装,目的是防止Windows的安全防护无缘无故的报毒问题,同时给软件一个相应的身份证。

1.3版本展示

图4版本展示
图5版本展示
图6版本展示
图7版本展示
图8版本展示
图9版本展示

二、Windows简易工具箱设计

2.1登录界面

登录界面进行了输入隐藏显示,三次密码输入错误自动退出,错误提示弹窗自动等功能。

在这里插入图片描述
代码如下:

自动关闭弹窗提示
 // 查找窗口
 [System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true)]
 private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

 // 发送消息
 [System.Runtime.InteropServices.DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
 private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);

 // 关闭消息
 private const uint WM_CLOSE = 0x0010;
 

 // 创建一个线程来执行倒计时操作
    
    .......


 // 查找并关闭MessageBox窗口
     private void CloseMessageBox()
 {
     
     IntPtr MMMX = FindWindow(null, "SimpleToolBox");
     if (MMMX != IntPtr.Zero)
     {
         SendMessage(MMMX, WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
     }
 }
密码隐藏
     private void main_Load(object sender, EventArgs e)
     {
         //textBox1.ReadOnly = true;
         textBox1.UseSystemPasswordChar = true;
         //textBox2.ReadOnly = true;
         textBox2.UseSystemPasswordChar = true;
     }
开启相应的LostFocus和GotFocus功能
  // textBox2
  // 
  this.textBox2.Location = new System.Drawing.Point(92, 18);
  this.textBox2.Margin = new System.Windows.Forms.Padding(2);
  this.textBox2.Name = "textBox2";
  this.textBox2.Size = new System.Drawing.Size(124, 25);
  this.textBox2.TabIndex = 1;
  this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged_1);
  this.textBox2.GotFocus += new System.EventHandler(this.textBox2_GotFocus);
  this.textBox2.LostFocus += new System.EventHandler(this.textBox2_LostFocus);
  // 
  
 // textBox1
 // 
 this.textBox1.Location = new System.Drawing.Point(92, 24);
 this.textBox1.Margin = new System.Windows.Forms.Padding(2);
 this.textBox1.Name = "textBox1";
 this.textBox1.Size = new System.Drawing.Size(124, 25);
 this.textBox1.TabIndex = 1;
 this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
 this.textBox1.GotFocus += new System.EventHandler(this.textBox1_GotFocus);
 this.textBox1.LostFocus += new System.EventHandler(this.textBox1_LostFocus);
 // 
  textBox代码
private void textBox1_LostFocus(object sender, EventArgs e)
{
    if (textBox1.Text == "")
    {
        textBox1.Text = "用户名已隐藏";
        textBox1.ForeColor = Color.Gray;
        //textBox1.ReadOnly = true;
        textBox1.UseSystemPasswordChar = true;
    }
    else
    {
        //textBox1.ReadOnly = true;
        textBox1.UseSystemPasswordChar = true;
        textBox1.ForeColor = Color.Black;
    }
}
private void textBox1_GotFocus(object sender, EventArgs e)
{
    if (textBox1.Text == "用户名已隐藏")
    {
        textBox1.Text = "";
        // textBox1.ReadOnly = true;
        textBox1.UseSystemPasswordChar = true;
        textBox1.ForeColor = Color.Black;
    }
}
private void textBox2_LostFocus(object sender, EventArgs e)
{
    if (textBox2.Text == "")
    {
        textBox2.Text = "密码已隐藏";
        textBox2.ForeColor = Color.Gray;
        // textBox2.ReadOnly = true;
        textBox2.UseSystemPasswordChar = true;
    }
    else
    {
        //textBox2.ReadOnly = true;
        textBox2.UseSystemPasswordChar = true;
        textBox2.ForeColor = Color.Black;
    }
}
private void textBox2_GotFocus(object sender, EventArgs e)
{
    if (textBox2.Text == "密码已隐藏")
    {
        textBox2.Text = "";
        //textBox2.ReadOnly = true;
        textBox2.UseSystemPasswordChar = true;
        textBox2.ForeColor = Color.Black;
    }
}

2.2 窗体显示信息

执行处理的信息,返回给窗体,在窗体中显示,超过一定时间自动清除。

在这里插入图片描述

IP地址查询代码
 try
 {
     string ipAddress = textBox1.Text;
     // 创建ProcessStartInfo对象,设置要执行的命令及参数
     ProcessStartInfo startInfo = new ProcessStartInfo();
 startInfo.FileName = "ping.exe";//要执行的命令
 startInfo.Arguments = $"-n 1 {ipAddress}";
 startInfo.UseShellExecute = false;//不使用外壳程序执行
 startInfo.RedirectStandardOutput = true;//将输出重定向到Process.StandardOutput属性
 startInfo.CreateNoWindow = true;//不创建新的窗口
                                 //创建并启动进程
 using (Process process = new Process())
 {
     process.StartInfo = startInfo;
     process.Start();
     //读取进程的输出
     string output = process.StandardOutput.ReadToEnd();
     //在窗体中显示输出结果
     richTextBox1.Text = output;
     Console.ReadLine();
     richTextBox1.Text = output;

 }

 }
 catch (Exception ex)
 {
     MessageBox.Show("SimpleToolBox:" + ex.Message);
 }

2.3 窗体中文乱码

执行操作返回的数据编码一般为GBK编码,而RichTextBox编码为UTF-8编码,因为在接收信息时,会出现中文乱码情况。
在这里插入图片描述

缓和解决方案
    using (Process process = new Process())
    {
        process.StartInfo = startInfo;
        process.Start();
        //读取进程的输出
        string output = process.StandardOutput.ReadToEnd();
        byte[] gbkBytes = Encoding.GetEncoding("GBK").GetBytes(output);
        string utf8String = Encoding.UTF8.GetString(gbkBytes);
        //在窗体中显示输出结果
        richTextBox1.Text = utf8String;
        Console.ReadLine();
        richTextBox1.Text = utf8String;

    }

2.4 TabPage美化

TabPage选项卡添加图标,显示字体大小。

在这里插入图片描述

代码如下:

 private void tabControl1_SelectedIndexChanged_1(object sender, EventArgs e)
 {
     if (s[tabControl1.SelectedIndex] == 0)
     {
         btnX_Click(sender, e);
     }
 }
private void btnX_Click(object sender, EventArgs e)
{
    string formClass = ((TabControl)sender).SelectedTab.Tag.ToString();

    GenerateForm(formClass, sender);
}

 //设置选项卡标签图标
 tabControl1.ImageList = imageList1;
 tabPage1.ImageIndex = 0;
 tabPage2.ImageIndex = 1;
 tabPage3.ImageIndex = 2;
 tabPage4.ImageIndex = 3;

imageList操作
在这里插入图片描述

2.5 界面统一化处理

界面统一化处理,整体一致,隔裂化不强。

在这里插入图片描述
窗体反射处理

 //反射生成窗体
 Form fm = (Form)Assembly.GetExecutingAssembly().CreateInstance(form);
 //设置窗体没有边框,加入到选项卡中
 fm.FormBorderStyle = FormBorderStyle.None;
 fm.TopLevel = false;
 fm.Parent = ((TabControl)sender).SelectedTab;
 fm.ControlBox = false;
 fm.Dock = DockStyle.Fill;
 fm.Show();
 s[((TabControl)sender).SelectedIndex] = 1;

三、设计结果验证

64位测试

通过测试界面显示的IP地址信息,未出现中文乱码,且10秒后信息自动清除。

在这里插入图片描述

通过Ping IP地址操作,可以返回信息。

在这里插入图片描述

在应用安装程序具备时,软件可自动下载安装,受本地网络影响,下载速度不一样。

在这里插入图片描述

32位测试

需要联网操作,软件可进行搜索,根据搜索后获取的ID,可执行自动安装或手动安装操作。

在这里插入图片描述

以搜索JDK为例,支持竖直和水平滚动。

在这里插入图片描述
在这里插入图片描述
进行手动下载或自动安装操作时,受电脑性能影响,请稍后即可。
在这里插入图片描述
在这里插入图片描述

手动安装默认下载到C盘Downloads目录下,进行双击安装,自动安装下载完后无需用户操作自动安装,安装在C盘。
在这里插入图片描述
ARM64位测试

电脑将启动平衡模式,弹窗1秒后自动关闭。

在这里插入图片描述

禁止系统更新后,会提示重启操作,用户点击是,5秒后自动重启,点击否,在下一次开机时生效。

在这里插入图片描述

Windows已被禁止更新,点击恢复重启电脑可恢复更新,禁止系统更新默认会禁止,系统搜索、用户信息反馈与收集等服务。
在这里插入图片描述

总结

目前可以进行一些操作,解决一些生活中遇到的问题,相应的功能,后续在维护和更新中进行完善。软件可免费下载,免费使用,严禁第三方以付费等行为向用户收取费用。

软件官方版本
安装教程必看
账户和密码

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

喾颛顼

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值