Jump to content

Idle Shutdown


Recommended Posts

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
Link to comment
Share on other sites

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
Spoiler

Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder
Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array
Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc
Cool Stuff: AutoItObject UDF â—Š Extract Icon From Proc â—Š GuiCtrlFontRotate â—Š Hex Edit Funcs â—Š Run binary â—Š Service_UDF

 

Link to comment
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 :)

Link to comment
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

Link to comment
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 :)

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...