Jump to content

time manupilation problem


camilla
 Share

Recommended Posts

hello everybody, i need your help please it a simple script , i want to run a message box in the next day from this day.

example:

- i took the current day as refernce

- add one day to it

-make a condition to see if it is the new day

- if it is true run a message box

this is my code nee some help

 

#include <Date.au3>
#include <MsgBoxConstants.au3>
; Add 1 days to today
$sDate = @YEAR & "/" & @MON & "/" & @MDAY ; the current date;
$sNewDate = _DateAdd('d', 1, $sDate); we add one day to the current day;
Sleep(2000);we wait for 2 seconds
While 1
If $sDate = $sNewDate Then ; condition to check if the current date equals our newDate
Sleep(5000)
    MsgBox($MB_SYSTEMMODAL, "", "Today + 1 days:" & $sNewDate); if the condition is true then message popup
EndIf
WEnd

 

thank you in advance

there is one small problem which is the CPU when i run my code it is 100/100 need to low it

Edited by camilla
Link to comment
Share on other sites

You aren't updating your $sDate, so it will always be yesterday.

While 1
    If @YEAR & "/" & @MON & "/" & @MDAY = $sNewDate Then ; condition to check if the current date equals our newDate
        MsgBox($MB_SYSTEMMODAL, "", "Today + 1 days:" & $sNewDate); if the condition is true then message popup
    EndIf
    Sleep(5000)
 WEnd
Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

How about this idea?  It's something to work from.

#include <MsgBoxConstants.au3>

#include <Date.au3>

Global $current_mday = @MDAY

Do
  If $current_mday <> @MDAY Then ; condition to check if the current date equals our newDate
    $current_mday = @MDAY
    MsgBox($MB_SYSTEMMODAL, "", "Today + 1 days: " & _DateAdd('d', 1, @YEAR & "/" & @MON & "/" & @MDAY)) ; if the condition is true then message popup
  EndIf
Until False

Edit: code addition

Every time I change my computer's date by one day the msgbox pops up.

Edited by jaberwacky
Link to comment
Share on other sites

yes, but as i said the result of new day after appears in the message  box you use @MDAY and add one day to it in the message box

look at my script

take current day

add one day to it

if it is the new day

message box appears

it may add more than one day

and it may not just open message box also you can run ccleaner  have you got the idea

Link to comment
Share on other sites

The best way would be to schedule a task for the $sNewDate.

The scheduled task cmd can be a one-liner, like:

consolewrite(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(0, ''Hello World!'', ''Hi!'')"')

note: grab the output of the consolewrite for the actual task command.

That would use 0 cpu/ram

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

 

jdelaney

The best way would be to schedule a task for the $sNewDate.

The scheduled task cmd can be a one-liner, like:

@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(0, ''Hello World!'', ''Hi!'')"'

That would use 0 cpu/ram

 

yes i agree with you, but schedule a task always have problem in the different OS windows7/windows8

Link to comment
Share on other sites

....

there is one small problem which is the CPU when i run my code it is 100/100 need to low it

camilla,

Addressing the high usage of the CPU problem only.

Note jdelaney's script of post #2 - The sleep function is outside of the If...Then...EndIf function, but inside of the While...Wend loop (where it is supposed to be). This is the correct placement of the Sleep function.

Your script of post #1 has the Sleep function, but it is inside of the If...EndIf which is only accessed when the If statement is true.   

Notice jaberwacky's script of post #3. This script, when run, causes a higher than necessary CPU usage because of the absence of a Sleep function within the Do...Until loop.

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

×
×
  • Create New...