心血来潮,开发了定时工具
如果你要下载某些东西,网速慢要熬夜怎么办?那就让电脑定时关机
之前在某论坛看到了用易语言开发的一个定时工具,
自己就用WinForm开发了一个玩玩,测试了好多次,可以哇{:10_256:}
代码示例->注意控件哦
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 定时关机
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
//加背景图
//this.BackgroundImage = Image.FromFile(@"D: \\");
}
//确定按钮
private void button2_Click(object sender, EventArgs e)
{
try
{
//立即重启
if (radioButton_Restar2.Checked)
{
//美化点
DialogResult dr = MessageBox.Show("是否立即重启?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
if (dr == DialogResult.OK)
{
System.Diagnostics.Process.Start("shutdown.exe", "-r -f -t 0");
}
}
//立即关机
else if (radioButton_Shutdown2.Checked)
{
//美化点
DialogResult dr = MessageBox.Show("是否立即关机?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
if (dr == DialogResult.OK)
{
System.Diagnostics.Process.Start("shutdown.exe", "-s -f -t 0");
}
}
//立即注销
else if (radioButton_Cancellation2.Checked)
{
//美化点
DialogResult dr = MessageBox.Show("是否立即注销?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
if (dr == DialogResult.OK)
{
System.Diagnostics.Process.Start("shutdown.exe", "-l"); ;
}
}
//读取文本框的值触发定时
else
{
//将时间转为数字
int m_Hour = Convert.ToInt32(textBox1.Text);
int m_Min = Convert.ToInt32(textBox2.Text);
int m_Second = Convert.ToInt32(textBox3.Text);
int m_Time = m_Hour * 3600 * 1000 + m_Min * 60 * 1000 + m_Second * 1000;
//开始倒计时
timer1.Enabled = true;
timer1.Interval = m_Time;
//美化点
DialogResult dr = MessageBox.Show("定时开启!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
if (dr == DialogResult.OK)
{
}
}
}
catch
{
//MessageBox.Show("输入有误");
//美化点
DialogResult dr = MessageBox.Show("输入有误,请重新输入", "提⽰", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (dr == DialogResult.OK)
{
}
}
}
private void timer1_Tick(object sender, EventArgs e)
{
/*--------------------
功能实现:
根据各按钮执行各功能
---------------------*/
//重启
if (radioButton_Restar1.Checked)
{
System.Diagnostics.Process.Start("shutdown.exe", "-r-f -t 0");
}
if (radioButton_Shutdown1.Checked)
{
System.Diagnostics.Process.Start("shutdown.exe", "-s -f -t 0");
}
if (radioButton_Cancellation1.Checked)
{
System.Diagnostics.Process.Start("shutdown.exe", "-l");
}
}
// 取消 进程
private void button1_Click(object sender, EventArgs e)
{
timer1.Enabled = false;
//MessageBox.Show("进程已取消");
//美化点
DialogResult dr = MessageBox.Show("进程已取消!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
if (dr == DialogResult.OK)
{
System.Diagnostics.Process.Start("shutdown.exe", "-a");
}
}
// 关于 按钮
private void button5_Click(object sender, EventArgs e)
{
//MessageBox.Show("———————感谢支持———————\n创作者:一路狂奔的乌龟\n联系QQ:75156591\n");
//美化点
DialogResult dr = MessageBox.Show("创作者:一路狂奔的乌龟\n联系QQ:75156591\n", "感谢支持", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
if (dr == DialogResult.OK)
{
}
}
// 退出 按钮
private void button6_Click(object sender, EventArgs e)
{
//美化点
DialogResult dr = MessageBox.Show("退出?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
if (dr == DialogResult.OK)
{
Application.Exit();
}
}
}
}
软件需要的放这里了
链接:https://pan.baidu.com/s/18xEBtcFSUjF67_vhw_E_pA
提取码:6982
这是C#开发的{:10_256:} {:10_275:} 不错,不错{:9_236:} {:5_108:} 小伤口 发表于 2022-8-22 22:57
不错,不错
弄着玩的{:10_256:} 厉害{:10_257:}
页:
[1]