Sign in to follow this  
Followers 0
TheFridgeMaster

Idle Shutdown

9 posts in this topic

hey guys,

i want to make a simple program that will shutdown my pc after being on idle for 2 hours...

i have no idea as to what code to use for idle...

some help would be greatfully appreciated

cheers,

Kyle.

Share this post


Link to post
Share on other sites



hey guys,

i want to make a simple program that will shutdown my pc after being on idle for 2 hours...

i have no idea as to what code to use for idle...

some help would be greatfully appreciated

cheers,

Kyle.

In the current Beta: _Timer_GetIdleTime()

:P


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

i just had a little play around and i dont know how i can use it...

oh.. probably should have pointed out i'm an autoIT noob

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

In the current Beta: _Timer_GetIdleTime()

:(

or for those who don't use beta.

http://www.autoitscript.com/forum/index.ph...mp;hl=idle+time

i just had a little play around and i dont know how i can use it...

oh.. probably should have pointed out i'm an autoIT noob

We can tell by the number of posts. :P We all gotta start somewhere. Welcome. Edited by spudw2k

Share this post


Link to post
Share on other sites

soooo could you give me some help with some example scripts on how you would shutdown a pc with an idle time of 2 hours?

Share this post


Link to post
Share on other sites

Some questions:

Q1: do you want to learn AutoIt?

A: Start with something easier: http://www.autoitscript.com/autoit3/docs/. Have a look at Tutorials. After that do a search for "shutdown" in the forum. Once you find something useful get back to this post and follow the link spudw2k provided.

Q2: do you want to shut down the computer after 2 hours?

A: have a look at "Power Options" in your Display Properties - you can do alot of things there without need to employ AutoIt.

Q3: do you want to do both?

A: See the answer for Q1


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

Answer 1: i dont wanna fully get into autoIT, its just a handy tool sometimes when you need it. i have made a couple of simple apps that help my day to day work

Answer 2: yes, i want the computer to shut down after being idle for 2 hours, the power settings were the first place i looked.

Answer 3: meh

i've been searching the net all morning for a program and cant find one, then i thought of autoIT and was hoping it was and easy piece of code to achieve :S

Share this post


Link to post
Share on other sites

While 1
    Sleep (1000)
    If _Timer_GetIdleTime() > 1000*60*60*2 Then  Shutdown(9)
WEnd

Func _Timer_GetIdleTime()
; Get ticks at last activity
    Local $tStruct = DllStructCreate("uint;dword");
    DllStructSetData($tStruct, 1, DllStructGetSize($tStruct));
    DllCall("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr($tStruct))

; Get current ticks since last restart
    Local $avTicks = DllCall("Kernel32.dll", "int", "GetTickCount")

; Return time since last activity, in ticks (approx milliseconds)
    Local $iDiff = $avTicks[0] - DllStructGetData($tStruct, 2)
    If $iDiff >= 0 Then
   ; Normal return
        Return $iDiff
    Else
   ; Rollover of ticks counter has occured
        Return SetError(0, 1, $avTicks[0])
    EndIf
EndFunc ;==>_Timer_GetIdleTime


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

thankyou so so much :P

now my dad wont crack the shits at the power bill because of my power supply :(

Share this post


Link to post
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
Sign in to follow this  
Followers 0