Python Production computer timer shutdown Office artifact, another two other ways, without programming!

Source: Internet
Author: User

I am currently in the computer in front of the work, often work until the early morning two or three points still struggling for their dreams. Sometimes in the office chair on the silly sleep, I believe that a lot of friends and I like, this is very bad. The first is bad for the body, the second is bad for the computer.

On the physical side, the small part can only say that when you are young, you must be good to yourself, especially in front of the computer to work friends, or later physical problems become more difficult to suffer. Like I was more than 20 years old, now sit two hours will be back numbness, the femoral vertebra there is also a slight pain, so friends must pay attention to this point.

Bad for the computer, although you are not using it, but the computer has been working, the cup has been running, it is like our brains have been thinking. The computer is still damaged, and if it is the company's machine, he will be forced to require you to close the work, and we often because the work is too busy, too tired to forget. Just like the small part yesterday forgot to turn off the electric fan to copy 20 times motto same ... I can't control the fan, but the computer, I'm a python programmer, can easily talk to it.

I am here to introduce three methods, the first two are suitable, no programming basis of friends, the last one by me to write Python code to achieve.

The first type:

Baidu download the relevant software, computer timer shutdown. Recommended no programming basis, the computer is not familiar with the use of friends, because the operation is simple, one download, life-long use.

The second type:

The first step: the keyboard Press "Win+r" at the same time, enter "cmd" in the window, pop up the DOS window, or right click on the bottom left of the screen Windows icon

The pop-up list selects run (R) and then output "cmd".

Step Two: Enter "Shutdown-s-t Time" in the new popup window, where the time is in seconds. For example Shutdown-s-T 60, then the computer shuts down automatically after 1 minutes.

If you want to shut down the machine, for example, if you want to set the 1 o'clock computer to shut down automatically, then enter "at time Shutdown-s", here the time format is "hours: minutes: Seconds". For example at the shutdown-s, it is 1 o'clock the whole computer automatically shut down.

This code is not good to explain, learned English know, at meaning is in, shutdown meaning to be ended, played the game friends will not be unfamiliar with this word. The operation is also very simple, the hands-on ability of the sophisticated is not high.

The third type:

Programmers who learn Python programming will definitely want to see this approach, rather than the previous two types of non-programming based people can use.

Since it is programming, it should not be too shabby, do not think small to do such a small software is so troublesome, we python programmer is graceful pronoun, should do still have to do.

Tool Preparation:

The UI required to complete the production with QT includes:

Label1234,lineedit12,pushbutton related components.

Two lineedit waiting for us to enter the time to set the computer to shut down automatically. The label displays information about the receipt after the operation. The UI was built successfully after the pushbutton submission command.

The second step: the UI is converted into a py file:

PYQT5 added environment variables, translated CMD commands, CD to the directory where the UI is located:

After the Python code executes, the shut.py file is generated in the same directory as the UI.

Step Three: Window display:

We directly generate the py. File run is not able to display the window, the top of the code add:

The final side is also added:

Run the shut.py window to display it.

Fourth step: Implement the function:

The Python program implements the function that is: Windows system computer shuts down automatically. The first to second method shows that the cmd command is a good choice. So let's see how Python Executes the cmd command:

Python Full source code:

Interface:

Run:

When you see that the task is already in the plan, remove refreshes the task schedule.

Removal task complete, to achieve the successful implementation of the function!

No. PY is not packaged and is not available to anyone who does not have Python installed, and is used in Windows without static compilation.

Fifth step: Packaging, static compilation:

Take advantage of the Python Pyinstaller component, then CD in the directory where the shut.py is located, and finally execute the cmd command:

In this case, three methods have been introduced. Python programmers do not need me to speak, no programming based on the first to second way is understandable.

Python Production computer timer shutdown Office artifact, another two other ways, without programming!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.