Jump to content

Timed Shutdown?


Recommended Posts

Hi All,

I am new to auto it and i love it! I Ike to make backups each night at my work. (i burn them to CDS) the problem is my boss gets mad at me when i leave the computer on. I was looking for a way to shut down the computer after a time i set.

This is what i have

$timer = InputBox("Shutdown", "When would you like to shutdown?")

sleep ("$timer")

shutdown (1)

I think something is wrong with the sleep ("$timer") but i do not know how else to do it. Can someone just point me in the right direction?

Thanks

Hard work never killed anyone but why take the chance?

Link to comment
Share on other sites

Oops I was trying to edit the post and I accidently deleted it lol, doing too many thingd at once

For anyone interested the fix was to change:

sleep("$timer") to sleep($timer)

Since a variable should not be send to a function as a string :)

Dave

PS if you want a bit of code to make your program allow you to enter the time u want the computer to shut down consider looking at the macros @HOUR, @MIN, @SEC. if you need the method let me know

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------"I don't need to know everything, I just need to know where to find it when I need it"....EinsteinAnd in our case... That's the AutoIT helpfile ;) Please read before posting!!!

Link to comment
Share on other sites

Since a variable should not be send to a function as a string

you cannot use "" to a variable , without declaring it so..

$timer = InputBox("Shutdown", "When would you like to shutdown?")
sleep ($timer) 
shutdown (1)oÝ÷ Ù©l¢'ò¢ì(ºWeG­ç²'«Êjw+^j¢~â­jëh×6$timer = Guictrlcreateinput("" ,....................)
sleep (Guictrlread($timer)) 
shutdown (1)

use autoit quotes the next time.....

Link to comment
Share on other sites

you cannot use "" to a variable , without declaring it so..

$timer = InputBox("Shutdown", "When would you like to shutdown?")
sleep ($timer) 
shutdown (1)oÝ÷ Ù©l¢'ò¢ì(ºWeG­ç²'«Êjw+^j¢~â­jëh×6$timer = Guictrlcreateinput("" ,....................)
sleep (Guictrlread($timer)) 
shutdown (1)

use autoit quotes the next time.....

if i wanted to spoon feed him i would have.. i was just given him an example of how it could be done
Link to comment
Share on other sites

check this out

#include <GUIConstants.au3>
$main = GUICreate ("example",130,60)
GUICtrlCreateLabel ("Please enter time",10,7)
$time = GUICtrlCreateInput ("",10,30,50)
$ok = GUICtrlCreateButton ("Sleep",65,30,50,20)
GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $ok Then
        GUISetState (@SW_HIDE , $main)
        MsgBox(-1,"info","Shutdown after "&GUICtrlRead ($time)&" second")
        Sleep (GUICtrlRead ($time)*1000)
        Shutdown (1)
    EndIf
WEnd

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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