Jump to content

Recommended Posts

Posted

Hi guys. I wrote this just a minute ago and decided to post it. It's simple and plain but works great for me. I use it to watch movies at night in case i fall asleep. I want to dive into guis and see if I can come up with something a bit more complex. Have a good day.

$Value = InputBox ( "Sleep Timer", "How many minutes should I wait?", "120", "", 150, 150 )
$Smins = 60000 * $Value
Sleep($Smins)
Shutdown (9)
Posted (edited)

Hi trancexx. This is a timer that asks you how many minutes to wait until it shuts down your computer. Kinda like the sleep timer you'd find on a TV. It's plainly simple. A better one with a gui and more options will be out later today if I can get these loops down. Wish me luck:)

Edited by darknezz19
Posted (edited)

Starting to grasp loops and such. Here's a new version. Next I want to add reading of a video to automatically plug in the minutes. Suggestions and or criticism welcome.

*Edit* Rushed it out and didn't test it enough. There's bugs that need to be fixed.

#include <GUIConstantsEx.au3>

$Form1 = GUICreate("Sleep Timer", 200, 150)
$Input1 = GUICtrlCreateInput("Minutes to Sleep", 50, 80, 100, 21)
$Button1 = GUICtrlCreateButton("OK", 50, 110, 100, 30, 0)
$Check1 = GUICtrlCreateRadio("Shutdown", 50, 20)
$Check2 = GUICtrlCreateRadio("Sleep", 50, 40)
GUISetState(@SW_SHOW) ; set the gui state to show so you can see it 

$End = 0

While 1 ; start of loop
    $Msg = GUIGetMsg()  
    Select
        Case $Msg = $GUI_EVENT_CLOSE ; exit if the window is closed
            Exit            
        Case $Msg = $Input1 ; grab input of minutes and multiply by 60000 to get time in miliseconds
            $Mins = GUICtrlRead ($Input1)
            $Min = 60000 * $Mins            
        Case $Msg = $Check1 ; if shutdown is selected asign 1 to $End
            $End = 1
        Case $Msg = $Check2 ; if sleep is selected asign 2 to $End
            $End = 2
        Case $Msg = $Button1 ; run the sleep timer
            If $End = 0 Then
                MsgBox(0, "Oops", "Please pick Shutdown or Sleep")
            Sleep($Min)
            ElseIf $End = 1 Then
                Shutdown (9)
                Exit
            ElseIf $End = 2 Then
                Shutdown (64)
                Exit
            EndIf
    EndSelect
WEnd
Edited by darknezz19
Posted

Next I want to add reading of a video to automatically plug in the minutes. Suggestions and or criticism welcome.

Take a look at this Get Extended File Property UDF By Simucal

Its an old thread but the function still works, and will include the duration of a garden variety xvid avi, amongst other things.

To make your project a little more adventurous for you, you should look into having your gui launching the video too.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...