TheFridgeMaster Posted October 13, 2008 Share Posted October 13, 2008 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. Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 13, 2008 Share Posted October 13, 2008 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 appreciatedcheers,Kyle.In the current Beta: _Timer_GetIdleTime() 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 More sharing options...
TheFridgeMaster Posted October 13, 2008 Author Share Posted October 13, 2008 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 Link to comment Share on other sites More sharing options...
spudw2k Posted October 13, 2008 Share Posted October 13, 2008 (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+timei 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 noobWe can tell by the number of posts. We all gotta start somewhere. Welcome. Edited October 13, 2008 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 BuilderMisc 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 ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF  Link to comment Share on other sites More sharing options...
TheFridgeMaster Posted October 13, 2008 Author Share Posted October 13, 2008 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? Link to comment Share on other sites More sharing options...
enaiman Posted October 13, 2008 Share Posted October 13, 2008 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 More sharing options...
TheFridgeMaster Posted October 13, 2008 Author Share Posted October 13, 2008 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 More sharing options...
enaiman Posted October 13, 2008 Share Posted October 13, 2008 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 More sharing options...
TheFridgeMaster Posted October 13, 2008 Author Share Posted October 13, 2008 thankyou so so much now my dad wont crack the shits at the power bill because of my power supply Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now