Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / [share] shutdown timer

Author
Message
zero32
7
Years of Service
User Offline
Joined: 28th Jul 2016
Location:
Posted: 5th Mar 2018 06:55
Hi,
i needed a tool that can shutdown my pc so i can put on some music and the pc shuts down reliably while i sleep. i did not want some random bloated tool from the internet that needs to run in the background the whole time so i made my own.

here it is (sourcecode and project folder as zip file for download):



you just open the tool, click on shutdown in 1h and it will shutdown in one hour. you can close the tool anytime.
if you want to stop it, just run the tool again and click cancel shutdown.
"It is only slightly easier than changing all sugar in a cake into stevia after it has already been baked" -Bisqwit

Attachments

Login to view attachments
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 5th Mar 2018 14:45 Edited at: 5th Mar 2018 14:47
I won't step on this post by offering code.

I did a similar thing where I can pick when the shutdown occurs. Then I added it to steam and now I can remotely shut down my computer when I'm done with it.
So picture Steam in home streaming from a beefy computer to a laptop, a little Skyrim before bed. Then no need to get out of bed and turn off the computer downstairs.

I also made a remote process kill program for steam games that freeze. Otherwise I'd have to get up and go to the computer and fix it.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 5th Mar 2018 15:20 Edited at: 5th Mar 2018 15:21
Zero32

Which version of DBPro did you use to compile that exe? I ask because I'm using 9Ex Build 2017-06-04 and all I see is a black window when I compile and run your code.

Your exe works fine though.
zero32
7
Years of Service
User Offline
Joined: 28th Jul 2016
Location:
Posted: 5th Mar 2018 18:11
i still use u7.6.

if you look at the code, you will find that i only rebuild the screen once before the do loop. this is fine because the screen does not change during the loop but as far as i know this does not work on the 9Ex build. adding a sync in the loop should fix this.
"It is only slightly easier than changing all sugar in a cake into stevia after it has already been baked" -Bisqwit
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 6th Mar 2018 12:04
Yep, it should. Thanks.

Neat example by the way. Seems to work fine.
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 6th Mar 2018 12:46
Not to try to squash fun stuff in dbpro or anything, but wouldn't it be simpler to just put shutdown /s /t 3600 in a .bat file?
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 6th Mar 2018 18:45
Ptobably - but then you'd need another one to cancel it wouldn't you? Personally I prefer the "fun" solution.
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 6th Mar 2018 19:32
Ortu is correct, just the idea I presented is 2 things:

1. DBP is useful for giving it a menu.

2. As a program, you can add it to Steam and use In-Home Streaming to remotely launch it on the computer. This allows you to schedule a computer to turn off without actually going to the computer.
zero32
7
Years of Service
User Offline
Joined: 28th Jul 2016
Location:
Posted: 6th Mar 2018 20:48 Edited at: 6th Mar 2018 20:53
new version:

added a text field to input time. it will store the input in a text file. you can input the time in seconds, minutes, hours, days, weeks and years. just write 1m for 1 minute, 1h for 1 hour and so on. 10 years is the maximum.
i added some checks, but you are responsible to not make any weird entries.
copy, cut and paste is possible with ctrl+c,v,x



now it makes a bit more sense but the code is a bit bloated
"It is only slightly easier than changing all sugar in a cake into stevia after it has already been baked" -Bisqwit

Attachments

Login to view attachments
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 6th Mar 2018 22:55
I will make a small suggestion:


Should be changed to:


You will notice that when you schedule a shutdown with Windows, you cannot schedule another shutdown until the previous one is aborted. So always send an abort command before scheduling. There is no consequence to sending an abort command when no shutdown was previously scheduled.
zero32
7
Years of Service
User Offline
Joined: 28th Jul 2016
Location:
Posted: 7th Mar 2018 07:41
Nice idea, Mage. Thank you.

i added it to my code and it will be in the next update.
"It is only slightly easier than changing all sugar in a cake into stevia after it has already been baked" -Bisqwit

Login to post a reply

Server time is: 2024-03-29 14:55:56
Your offset time is: 2024-03-29 14:55:56