camilla Posted January 24, 2014 Posted January 24, 2014 (edited) 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 January 24, 2014 by camilla
jdelaney Posted January 24, 2014 Posted January 24, 2014 (edited) 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 January 24, 2014 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.
jaberwacky Posted January 24, 2014 Posted January 24, 2014 (edited) 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 January 24, 2014 by jaberwacky Helpful Posts and Websites: AutoIt Wiki | Can't find what you're looking for on the Forum? My scripts: Guiscape | Baroque AU3 Code Formatter | MouseHoverCalltips | SciTe Customization GUI | ActiveWindowTrack Toy | Monitor Configuration UDF
camilla Posted January 24, 2014 Author Posted January 24, 2014 thank you for replay jdelaney i like your solution is there any idea about the burning CPU jaberwacky you use the result in the message box i need it to be true by means when i put my script in startup folder exactly after one day from it's execution the message appears
jaberwacky Posted January 24, 2014 Posted January 24, 2014 Have you seen my edit to the code. I forgot an important line. Helpful Posts and Websites: AutoIt Wiki | Can't find what you're looking for on the Forum? My scripts: Guiscape | Baroque AU3 Code Formatter | MouseHoverCalltips | SciTe Customization GUI | ActiveWindowTrack Toy | Monitor Configuration UDF
camilla Posted January 24, 2014 Author Posted January 24, 2014 jaberwacky 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
jdelaney Posted January 24, 2014 Posted January 24, 2014 (edited) 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 January 24, 2014 by jdelaney jaberwacky 1 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.
jaberwacky Posted January 24, 2014 Posted January 24, 2014 No, I don't, but the idea wasn't to provide a complete working solution. I just wanted to give you something to work with. Helpful Posts and Websites: AutoIt Wiki | Can't find what you're looking for on the Forum? My scripts: Guiscape | Baroque AU3 Code Formatter | MouseHoverCalltips | SciTe Customization GUI | ActiveWindowTrack Toy | Monitor Configuration UDF
camilla Posted January 24, 2014 Author Posted January 24, 2014 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
camilla Posted January 24, 2014 Author Posted January 24, 2014 jaberwacky thank you very much for your help i appreciate it, me too don't want complete solution just need to help others who may be in my case
kylomas Posted January 24, 2014 Posted January 24, 2014 camilla, Is your goal to run CCleaner once per day, just after midnight? kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
Malkey Posted January 25, 2014 Posted January 25, 2014 .... 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.
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