WolfWorld Posted April 16, 2009 Share Posted April 16, 2009 (edited) Very simple, all file needed included in the rar expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.0.0 Author: Athiwat Chunlakhan Script Function: Delay startup, It will run program one by one. First it will wait for the CPU to idle then run the first one then wait then run the second one and so on. This allow you to work right away on your PC without needing to wait for the startup program to load. Settings: c:\settings.ini create this file and hide it if you want Settings Format: [run] 1=first program full path 2=.... Install: Drag this file in to the startup folder, COMPILE IT FIRST! And delete all the startup program shortcut Note: WLM 2009 should be put in the first place as it got its own function which is similar to this. #ce ---------------------------------------------------------------------------- #include 'Spring_Framework.au3' Global $filedir = 'c:\settings.ini', $output For $i = 1 To 9999 while _Get() > 20 sleep(5000) wend _('ired.$filedir.run.$i.-1.&output') If $output = '-1' Then ExitLoop ShellExecute($output) Sleep(2000) Next Func _Get() $process = _ProcessListProperties() Local $cpu For $i = 1 To $process[0][0] If $process[$i][4] = 0 Then $cpu = $process[$i][6] ExitLoop EndIf Next Return 100 - $cpu EndFunc ;==>_Get ;=============================================================================== ; Function Name: _ProcessListProperties() ; Description: Get various properties of a process, or all processes ; Call With: _ProcessListProperties( [$Process [, $sComputer]] ) ; Parameter(s): (optional) $Process - PID or name of a process, default is "" (all) ; (optional) $sComputer - remote computer to get list from, default is local ; Requirement(s): AutoIt v3.2.4.9+ ; Return Value(s): On Success - Returns a 2D array of processes, as in ProcessList() ; with additional columns added: ; [0][0] - Number of processes listed (can be 0 if no matches found) ; [1][0] - 1st process name ; [1][1] - 1st process PID ; [1][2] - 1st process Parent PID ; [1][3] - 1st process owner ; [1][4] - 1st process priority (0 = low, 31 = high) ; [1][5] - 1st process executable path ; [1][6] - 1st process CPU usage ; [1][7] - 1st process memory usage ; [1][8] - 1st process creation date/time = "MM/DD/YYY hh:mm:ss" (hh = 00 to 23) ; [1][9] - 1st process command line string ; ... ; [n][0] thru [n][9] - last process properties ; On Failure: Returns array with [0][0] = 0 and sets @Error to non-zero (see code below) ; Author(s): PsaltyDS at http://www.autoitscript.com/forum ; Date/Version: 07/02/2008 -- v2.0.2 ; Notes: If an integer PID or string process name is provided and no match is found, ; then [0][0] = 0 and @error = 0 (not treated as an error, same as ProcessList) ; This function requires admin permissions to the target computer. ; All properties come from the Win32_Process class in WMI. ; To get time-base properties (CPU and Memory usage), a 100ms SWbemRefresher is used. ;=============================================================================== Func _ProcessListProperties($Process = "", $sComputer = ".") Local $sUserName, $sMsg, $sUserDomain, $avProcs, $dtmDate Local $avProcs[1][2] = [[0, ""]], $n = 1 ; Convert PID if passed as string If StringIsInt($Process) Then $Process = Int($Process) ; Connect to WMI and get process objects $oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy}!\\" & $sComputer & "\root\cimv2") If IsObj($oWMI) Then ; Get collection processes from Win32_Process If $Process = "" Then ; Get all $colProcs = $oWMI.ExecQuery("select * from win32_process") ElseIf IsInt($Process) Then ; Get by PID $colProcs = $oWMI.ExecQuery("select * from win32_process where ProcessId = " & $Process) Else ; Get by Name $colProcs = $oWMI.ExecQuery("select * from win32_process where Name = '" & $Process & "'") EndIf If IsObj($colProcs) Then ; Return for no matches If $colProcs.count = 0 Then Return $avProcs ; Size the array ReDim $avProcs[$colProcs.count + 1][10] $avProcs[0][0] = UBound($avProcs) - 1 ; For each process... For $oProc In $colProcs ; [n][0] = Process name $avProcs[$n][0] = $oProc.name ; [n][1] = Process PID $avProcs[$n][1] = $oProc.ProcessId ; [n][2] = Parent PID $avProcs[$n][2] = $oProc.ParentProcessId ; [n][3] = Owner ;If $oProc.GetOwner($sUserName, $sUserDomain) = 0 Then $avProcs[$n][3] = $sUserDomain & "\" & $sUserName ; [n][4] = Priority $avProcs[$n][4] = $oProc.Priority ; [n][5] = Executable path $avProcs[$n][5] = $oProc.ExecutablePath ; [n][8] = Creation date/time $dtmDate = $oProc.CreationDate If $dtmDate <> "" Then ; Back referencing RegExp pattern from weaponx Local $sRegExpPatt = "\A(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(?:.*)" $dtmDate = StringRegExpReplace($dtmDate, $sRegExpPatt, "$2/$3/$1 $4:$5:$6") EndIf $avProcs[$n][8] = $dtmDate ; [n][9] = Command line string $avProcs[$n][9] = $oProc.CommandLine ; increment index $n += 1 Next Else SetError(2); Error getting process collection from WMI EndIf ; release the collection object $colProcs = 0 ; Get collection of all processes from Win32_PerfFormattedData_PerfProc_Process ; Have to use an SWbemRefresher to pull the collection, or all Perf data will be zeros Local $oRefresher = ObjCreate("WbemScripting.SWbemRefresher") $colProcs = $oRefresher.AddEnum($oWMI, "Win32_PerfFormattedData_PerfProc_Process" ).objectSet $oRefresher.Refresh ; Time delay before calling refresher Local $iTime = TimerInit() Do Sleep(20) Until TimerDiff($iTime) >= 100 $oRefresher.Refresh ; Get PerfProc data For $oProc In $colProcs ; Find it in the array For $n = 1 To $avProcs[0][0] If $avProcs[$n][1] = $oProc.IDProcess Then ; [n][6] = CPU usage $avProcs[$n][6] = $oProc.PercentProcessorTime ; [n][7] = memory usage $avProcs[$n][7] = $oProc.WorkingSet ExitLoop EndIf Next Next Else SetError(1); Error connecting to WMI EndIf ; Return array Return $avProcs EndFunc;==>_ProcessListPropertiesStartDelay.rar Edited April 17, 2009 by athiwatc Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets! Link to comment Share on other sites More sharing options...
WideBoyDixon Posted April 16, 2009 Share Posted April 16, 2009 I'm not sure I agree with the description here. There's no checks for CPU idleness; it simply waits 7 seconds and then 2 seconds between each program run. Also, isn't the "Spring Framework" a bit superfluous here? Surely this entire script could be re-written:Global $filedir = @ScriptDir & '\settings.ini', $output Sleep(7000) $aPrograms = IniReadSection($filedir, "run") For $i = 1 To $aPrograms[0][0] ShellExecute($aPrograms[$i][1]) Sleep(2000) NextAlso, for this kind of functionality, I prefer to use Glary Utilities Portable since it offers me a whole host of other useful functionality WBD [center]Wide by name, Wide by nature and Wide by girth[u]Scripts[/u]{Hot Folders} {Screen Calipers} {Screen Crosshairs} {Cross-Process Subclassing} {GDI+ Clock} {ASCII Art Signatures}{Another GDI+ Clock} {Desktop Goldfish} {Game of Life} {3D Pie Chart} {Stock Tracker}[u]UDFs[/u]{_FileReplaceText} {_ArrayCompare} {_ToBase}~ My Scripts On Google Code ~[/center] Link to comment Share on other sites More sharing options...
WolfWorld Posted April 17, 2009 Author Share Posted April 17, 2009 (edited) Just wait I posted the wrong version I will update it as soon as I go home Update: Updated! I'm not sure I agree with the description here. There's no checks for CPU idleness; it simply waits 7 seconds and then 2 seconds between each program run. Also, isn't the "Spring Framework" a bit superfluous here? Surely this entire script could be re-written: Global $filedir = @ScriptDir & '\settings.ini', $output Sleep(7000) $aPrograms = IniReadSection($filedir, "run") For $i = 1 To $aPrograms[0][0] ShellExecute($aPrograms[$i][1]) Sleep(2000) Next Also, for this kind of functionality, I prefer to use Glary Utilities Portable since it offers me a whole host of other useful functionality WBD Edited April 17, 2009 by athiwatc Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets! Link to comment Share on other sites More sharing options...
storme Posted August 17, 2009 Share Posted August 17, 2009 G'day athiwatc YEAH I know OLD thread. Just wondering if you've explanded on this script any more? I tried the Glary verison of this and it just lost all the start up items I'd selected to delay. >_< Thanks for the great script Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E Link to comment Share on other sites More sharing options...
WolfWorld Posted August 28, 2009 Author Share Posted August 28, 2009 G'day athiwatc YEAH I know OLD thread. Just wondering if you've explanded on this script any more? I tried the Glary verison of this and it just lost all the start up items I'd selected to delay. Thanks for the great scriptYes, Sorry I did not see the thread. Did you get it working? Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets! 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