吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 4994|回复: 104
收起左侧

[原创工具] 非常实用的自动关机小软件(附源码)

  [复制链接]
mryouan 发表于 2024-12-23 21:37
开发背景:不知道大家有没有遇到这样的情况,在公司总有那么一两台电脑,是需要共享使用的,但是共享的电脑使用人如果要提前下班,最好的方式就是使用定时关机,系统自带的命令确实能够实现,但命令参数不是所有人能操控的了,网上的定时器也试用了好几个,要么是某软件附带的功能,要么是附带其他很多不用的功能,想找一款简单纯粹的定时软件,好像也成了难事,如是乎,我自己动手,写出一个功能单一的定时关机器,为了自己方便的同时,也分享给大家一起来方便。
软件特色:
最大的特色就是:带有关机倒计时,并且大屏显示,而不是定时后自己都不知道
软件界面:
mmexport1734958994809.png mmexport1734960742312.png
  • 首先,我想要的定时关机软件,必须有一个显示屏,显示还有多久关机;
  • 设置关机的时间必须有绝对时间和相对时间;
  • 有没有在执行定时必须有显示(执行时倒计时开始,并且执行按钮绿色背景)
  • 可以修改定时或取消定时

以上就是最实用的功能的完美定时器,吾爱破解论坛首发,非常的好用,不管你们用不用,反正我每天在用
软件下载:
https://mryouan.lanzouq.com/b00wm7e9ta
密码:9j3s
重要声明:软件使用pyinstaller生成的exe,不含任何添加剂,如何不放心,大家使用下面的python 3源码自己编译成exe
源码分享:
[Python] 纯文本查看 复制代码
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
089
090
091
092
093
094
095
096
097
098
099
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
import sys
import datetime
from PyQt6.QtWidgets import (QApplication, QMainWindow, QWidget, QVBoxLayout,
                            QHBoxLayout, QLabel, QPushButton, QRadioButton,
                            QDateTimeEdit, QTimeEdit, QMessageBox)
from PyQt6.QtCore import Qt, QTimer, QDateTime
from PyQt6.QtGui import QFont, QPalette, QColor
import subprocess
 
class ShutdownTimer(QMainWindow):
    def __init__(self):
        super().__init__()
        self.shutdown_time = None
        self.timer = QTimer()
        self.timer.timeout.connect(self.update_countdown)
        self.init_ui()
         
    def init_ui(self):
        # 设置窗口
        self.setWindowTitle('定时关机器V1.0 吾爱破解@mryouan')
        screen = QApplication.primaryScreen().geometry()
        self.setGeometry(screen.width()//4, screen.height()//4,
                        screen.width()//2, screen.height()//2)
         
        # 主布局
        central_widget = QWidget()
        self.setCentralWidget(central_widget)
        layout = QVBoxLayout(central_widget)
         
        # 倒计时显示区域
        self.countdown_label = QLabel('未设置定时关机')
        self.countdown_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
        self.countdown_label.setStyleSheet("""
            QLabel {
                background-color: black;
                color: red;
                padding: 20px;
                border: 2px solid gray;
                border-radius: 10px;
            }
        """)
        self.countdown_label.setFont(QFont('Arial', 40))
        layout.addWidget(self.countdown_label)
         
        # 设置区域
        settings_widget = QWidget()
        settings_layout = QHBoxLayout(settings_widget)
         
        # 时间设置部分
        time_widget = QWidget()
        time_layout = QVBoxLayout(time_widget)
         
        # 单选按钮
        self.absolute_radio = QRadioButton('绝对时间')
        self.relative_radio = QRadioButton('相对时间')
        self.absolute_radio.setChecked(True)
        time_layout.addWidget(self.absolute_radio)
        time_layout.addWidget(self.relative_radio)
         
        # 时间选择器
        self.datetime_edit = QDateTimeEdit()
        self.datetime_edit.setDateTime(
            QDateTime.currentDateTime().addSecs(3600))  # 默认一小时后
        self.time_edit = QTimeEdit()
        self.time_edit.setTime(self.time_edit.time().addSecs(3600))
         
        time_layout.addWidget(self.datetime_edit)
        time_layout.addWidget(self.time_edit)
        self.time_edit.hide()  # 默认隐藏相对时间
         
        settings_layout.addWidget(time_widget)
         
        # 按钮区域
        button_widget = QWidget()
        button_layout = QVBoxLayout(button_widget)
         
        self.execute_btn = QPushButton('执行')
        self.cancel_btn = QPushButton('取消')
         
        button_layout.addWidget(self.execute_btn)
        button_layout.addWidget(self.cancel_btn)
         
        settings_layout.addWidget(button_widget)
        layout.addWidget(settings_widget)
         
        # 信号连接
        self.absolute_radio.toggled.connect(self.toggle_time_input)
        self.execute_btn.clicked.connect(self.execute_shutdown)
        self.cancel_btn.clicked.connect(self.cancel_shutdown)
         
    def toggle_time_input(self):
        if self.absolute_radio.isChecked():
            self.datetime_edit.show()
            self.time_edit.hide()
        else:
            self.datetime_edit.hide()
            self.time_edit.show()
             
    def execute_shutdown(self):
        if self.absolute_radio.isChecked():
            shutdown_time = self.datetime_edit.dateTime().toPyDateTime()
            if shutdown_time <= datetime.datetime.now():
                QMessageBox.warning(self, '警告', '请选&#65533;&#65533;未来的时间!')
                return
        else:
            current_time = datetime.datetime.now()
            time_delta = datetime.timedelta(
                hours=self.time_edit.time().hour(),
                minutes=self.time_edit.time().minute(),
                seconds=self.time_edit.time().second()
            )
            shutdown_time = current_time + time_delta
             
        self.shutdown_time = shutdown_time
        seconds = int((shutdown_time - datetime.datetime.now()).total_seconds())
         
        # 设置关机命令
        subprocess.run(['shutdown', '/s', '/t', str(seconds)])
         
        # 更新UI
        self.execute_btn.setEnabled(False)
        self.execute_btn.setText('执行中')
        self.execute_btn.setStyleSheet('background-color: #90EE90; color: gray;')
         
        # 启动倒计时
        self.timer.start(1000)
         
    def cancel_shutdown(self):
        reply = QMessageBox.question(self, '确认', '是否要修改定时?',
                                   QMessageBox.StandardButton.Yes |
                                   QMessageBox.StandardButton.No)
         
        if reply == QMessageBox.StandardButton.Yes:
            # 取消当前关机命令
            subprocess.run(['shutdown', '/a'])
            self.reset_ui()
        else:
            subprocess.run(['shutdown', '/a'])
            self.close()
             
    def reset_ui(self):
        self.shutdown_time = None
        self.timer.stop()
        self.countdown_label.setText('未设置定时关机')
        self.execute_btn.setEnabled(True)
        self.execute_btn.setText('执行')
        self.execute_btn.setStyleSheet('')
         
    def update_countdown(self):
        if self.shutdown_time:
            remaining = self.shutdown_time - datetime.datetime.now()
            if remaining.total_seconds() <= 0:
                self.timer.stop()
                return
                 
            hours = remaining.seconds // 3600
            minutes = (remaining.seconds % 3600) // 60
            seconds = remaining.seconds % 60
             
            self.countdown_label.setText(
                f'距离关机还有{hours:02d}小时{minutes:02d}分{seconds:02d}秒')
 
if __name__ == '__main__':
    app = QApplication(sys.argv)
    app.setStyle('Fusion'# 使用 Fusion 风格,接近 Windows 10 风格
    window = ShutdownTimer()
    window.show()
    sys.exit(app.exec())


免费评分

参与人数 19吾爱币 +21 热心值 +19 收起 理由
a11487085 + 1 + 1 shutdiwn -s -t 1
poi8848328 + 1 + 1 谢谢@Thanks!
WJF12321 + 1 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
ljy583823 + 1 热心回复!
qinhp + 1 热心回复!
acksen + 1 + 1 谢谢@Thanks!
dingchaomin1314 + 1 + 1 我很赞同!
lywxzyt + 1 + 1 我很赞同!
15235109295 + 1 + 1 谢谢@Thanks!
gilliugen + 1 + 1 我很赞同!
jamesnow + 1 热心回复!
viconly + 1 + 1 谢谢@Thanks!
Jellyhang + 1 + 1 我很赞同!
ABCD00 + 1 我很赞同!
schtg + 1 + 1 谢谢@Thanks!
w2rt4 + 1 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
迎旭 + 1 + 1 谢谢@Thanks!
helideguaiyu + 1 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
风之暇想 + 7 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

dommy 发表于 2024-12-24 13:18
赞一个楼主精神,但cmd好像一句代码就能解决的吧
 楼主| mryouan 发表于 2024-12-26 22:07
dommy 发表于 2024-12-24 13:18
赞一个楼主精神,但cmd好像一句代码就能解决的吧

命令是可以实现定时关机, 但是本人离开电脑后,其他人知道这电脑设置有定时关机,有所以才需要有倒计时显示,可以随时修改,提前准备一些工作吧
netdna518 发表于 2024-12-24 11:25
LOUI55 发表于 2024-12-24 13:03
带源码就太好了
delphier 发表于 2024-12-24 13:54
太好了,我正好要学习怎么调用关机、重启的命令,谢谢分享
jhyzq 发表于 2024-12-24 14:21
这个软件实用,谢谢分享
kytor 发表于 2024-12-24 14:30
挺好的,日常使用中会用到,源代码公开,大家可以学习,不错
wa3456 发表于 2024-12-24 14:36
关机软件可以,很棒
xian54966 发表于 2024-12-24 15:12
shutdown 不好吗?
flight99 发表于 2024-12-24 15:14
dommy 发表于 2024-12-24 13:18
赞一个楼主精神,但cmd好像一句代码就能解决的吧

绝对时间可能要换算一下
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2025-3-18 08:09

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

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