Sign in to follow this  
Followers 0
Merrik

Loop Help

7 posts in this topic

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

Share this post


Link to post
Share on other sites



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

M23

P.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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Adding a small

Sleep(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?

Share this post


Link to post
Share on other sites

Hi Merrik,

why are you not using scheduled tasks? :)


Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

Share this post


Link to post
Share on other sites

Hi Merrik,

why are you not using scheduled tasks? :)

I was hoping to turn this into an NT service.

Share this post


Link to post
Share on other sites

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 game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

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