Merrik Posted March 14, 2011 Share Posted March 14, 2011 I'm trying to create a program that sits idle most of the time, but then each month on a certain day and at a certain time, performs an action. I'm new to this, but this what I have: While 1 If @WDAY = 2 Then Switch @MDAY Case 14 Switch @HOUR Case 11 Switch @MIN Case 19 ShellExecuteWait("notepad.exe") EndSwitch EndSwitch EndSwitch EndIf WEnd Problem: it continually loops waiting for the criteria to be met and takes up 50% CPU. I guessing someone knows how to do this and won't mind helping me out. Thanks Link to comment Share on other sites More sharing options...
kaotkbliss Posted March 14, 2011 Share Posted March 14, 2011 Adding a small Sleep(10) at the end (before Wend) might help reduce the CPU load. 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 14, 2011 Moderators Share Posted March 14, 2011 Merrik,Put a Sleep(10) line just before the WEnd - that way you give the CPU a chance to take a breath during the loop. M23P.S. When you post code please use Code tags. Put [autoit] before and [/autoit] after your posted code. Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Merrik Posted March 14, 2011 Author Share Posted March 14, 2011 Adding a smallSleep(10)at the end (before Wend) might help reduce the CPU load.Hey thanks guys,One issue I noticed. When I run the EXE it runs at 4,500K of memory and then after the criteria is met it jumps to 5,5000k of memory and stays there. I'm guessing over time it will continue to increase. Also I surprised it is using this much memory.Any thoughts? Link to comment Share on other sites More sharing options...
hannes08 Posted March 14, 2011 Share Posted March 14, 2011 Hi Merrik, why are you not using scheduled tasks? Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
Merrik Posted March 14, 2011 Author Share Posted March 14, 2011 Hi Merrik,why are you not using scheduled tasks? I was hoping to turn this into an NT service. Link to comment Share on other sites More sharing options...
kaotkbliss Posted March 14, 2011 Share Posted March 14, 2011 You can always try this function I found on the forums here (can't remember who wrote it) Func _ReduceMemory($i_PID = -1) If $i_PID <> -1 Then Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) Else $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) EndIf Return $ai_Return[0] EndFunc ;==>_ReduceMemory 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! 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