Jump to content

Script ideas for personal reminders message boxs?


Recommended Posts

Hello,

I'm trying to make a "reminder script", that will pop up the message box with personal reminders to myself at various times throughout the day, week month, and year.

Can anyone show me a script idea that will do this...or refer me to something I could not find in my search of this forum.

I began to sort of throw something like this together that sort of works, but seems a bit tedious, and I'm sure there must be a better way.

#include <Date.au3>

While 1

    ; Show current local time
    $tCur = _Date_Time_GetLocalTime()
    _Date_Time_SystemTimeToDateTimeStr($tCur)


    ;returns 0 if the strings are the same
    ;these are the reminder times
    $959pm_10 = StringCompare("06/29/2010 21:59:10", _Date_Time_SystemTimeToDateTimeStr($tCur))
    $959pm_20 = StringCompare("06/29/2010 21:59:20", _Date_Time_SystemTimeToDateTimeStr($tCur))
    $959pm_30 = StringCompare("06/29/2010 21:59:30", _Date_Time_SystemTimeToDateTimeStr($tCur))
    $959pm_40 = StringCompare("06/29/2010 21:59:40", _Date_Time_SystemTimeToDateTimeStr($tCur))
    $1007pm_05 = StringCompare("06/29/2010 22:07:05", _Date_Time_SystemTimeToDateTimeStr($tCur))
    $1012pm_15 = StringCompare("06/29/2010 22:12:15", _Date_Time_SystemTimeToDateTimeStr($tCur))
    $10_44pm = StringCompare("06/29/2010 22:44:00", _Date_Time_SystemTimeToDateTimeStr($tCur))
    
    
    

    ;if the strings are the same, then show the messagebox, etc.
    If $959pm_10 = 0 Then
        MsgBox(0, "Reminder", "Put Your Reminder Here")
    ElseIf $959pm_20 = 0 Then
        MsgBox(0, "Reminder", "Put Your Reminder Here")
    ElseIf $959pm_30 = 0 Then
        MsgBox(0, "Reminder", "Put Your Reminder Here")
    ElseIf $959pm_40 = 0 Then
        MsgBox(0, "Reminder", "Put Your Reminder Here")
    ElseIf $1007pm_05 = 0 Then
        MsgBox(0, "Reminder", "Put Your Reminder Here")
    ElseIf $1012pm_15 = 0 Then;play this wav file...ha!
        ShellExecute("C:\wav\sound_1.wav")
    ElseIf $10_44pm = 0 Then;play this wav file...ha!
        ShellExecute("C:\wav\sound_2.wav")



    EndIf




    Sleep(1000);sleep one second for low CPU usage, and because my reminders only set for minutes

WEnd

Thanks for any ideas,

frew

Link to comment
Share on other sites

#include <Date.au3>

Global $aMyReminders[1][3] = [[0, 0, 0]] ; Name, Date, Reminder

_AddReminder("1", "06/30/2010 23:57:40", "This is a test")

While 1
    ; Show current local time
    $tCur = _Date_Time_GetLocalTime()
    $tCur = _Date_Time_SystemTimeToDateTimeStr($tCur)

    For $i = 1 To $aMyReminders[0][0]
        If $tCur = $aMyReminders[$i][1] Then MsgBox(0, "Reminder: " & $aMyReminders[$i][0], $aMyReminders[$i][2])
    Next

    Sleep(700);sleep one second for low CPU usage, and because my reminders only set for minutes
WEnd


Func _AddReminder($sName, $sDate, $sReminder)
    ReDim $aMyReminders[UBound($aMyReminders) + 1][3]
    $aMyReminders[0][0] += 1

    $aMyReminders[$aMyReminders[0][0]][0] = $sName
    $aMyReminders[$aMyReminders[0][0]][1] = $sDate
    $aMyReminders[$aMyReminders[0][0]][2] = $sReminder
EndFunc

Use the _AddReminder function to add reminders :mellow:

Link to comment
Share on other sites

Thanks so much Mat.

I have to see if I can figure out how to use this, since I cannot use arrays well yet.

I'll work with this a bit and post again to let you know how it goes.

Thanks again,

frew

Link to comment
Share on other sites

Heres another one, possibly more useful. * is the wildcard, so: "**/01/**** 12:00:00" alerts on the first day of every month at midday.

#include <Date.au3>

Global $aMyReminders[1][3] = [[0, 0, 0]] ; Name, Date, Reminder

_AddReminder("1", "**/01/2010 00:18:20", "This is a test")

While 1
    ; Show current local time
    $tCur = _Date_Time_GetLocalTime()
    $tCur = _Date_Time_SystemTimeToDateTimeStr($tCur)

    For $i = 1 To $aMyReminders[0][0]
        If StringRegExp($tCur, $aMyReminders[$i][1]) Then MsgBox(0, "Reminder: " & $aMyReminders[$i][0], $aMyReminders[$i][2])
    Next

    Sleep(700);sleep one second for low CPU usage, and because my reminders only set for minutes
WEnd


Func _AddReminder($sName, $sDate, $sReminder)
    ReDim $aMyReminders[UBound($aMyReminders) + 1][3]
    $aMyReminders[0][0] += 1

    $aMyReminders[$aMyReminders[0][0]][0] = $sName
    $aMyReminders[$aMyReminders[0][0]][1] = StringReplace($sDate, "*", ".")
    $aMyReminders[$aMyReminders[0][0]][2] = $sReminder
EndFunc

Edit: Did not see the reply. It's all fairly simple as far as arrays go - and it's probably good stuff to learn from... ReDim is probably the hardest bit there.

Edited by Mat
Link to comment
Share on other sites

Nice...thanks for that idea. I was wondering if wildcards could be used here.

Otherwise I suppose a separate _AddReminder for every day of the year would be needed for each reminder if I wanted to have the alarm go off at a certain time every day?

Thanks again,

frew

Link to comment
Share on other sites

Thanks so much Mat.

This works very well.

Here's a little tester that pops up a reminder throughout each minute, as a test...not that it's very useful,

unless one needs this kind of constant reminder I suppose....utoh, what was that...oh yes, thanks for the reminder...wait, what was that again...oh yes, I see, good idea, thanks...(sorry for the ramble).

Again, thank you so much for this very useful code. Very much appreciated.

#include <Date.au3>

Global $aMyReminders[1][3] = [[0, 0, 0]] ; Name, Date, Reminder

_AddReminder("1", "**/01/2010 00:18:20", "This is a test")

;test
;MsgBox at top of each minute
;and at each 5 seconds thereafter in each minute
_AddReminder("00", "**/**/**** **:**:00", "This is a test")
_AddReminder("05", "**/**/**** **:**:05", "This is a test")
_AddReminder("10", "**/**/**** **:**:10", "This is a test")
_AddReminder("15", "**/**/**** **:**:15", "This is a test")
_AddReminder("20", "**/**/**** **:**:20", "This is a test")
_AddReminder("25", "**/**/**** **:**:25", "This is a test")
_AddReminder("30", "**/**/**** **:**:30", "This is a test")
_AddReminder("35", "**/**/**** **:**:35", "This is a test")
_AddReminder("40", "**/**/**** **:**:40", "This is a test")
_AddReminder("45", "**/**/**** **:**:45", "This is a test")
_AddReminder("50", "**/**/**** **:**:50", "This is a test")
_AddReminder("55", "**/**/**** **:**:55", "This is a test")



While 1
    ; Show current local time
    $tCur = _Date_Time_GetLocalTime()
    $tCur = _Date_Time_SystemTimeToDateTimeStr($tCur)

    For $i = 1 To $aMyReminders[0][0]
        If StringRegExp($tCur, $aMyReminders[$i][1]) Then MsgBox(0, "Reminder: " & $aMyReminders[$i][0], $aMyReminders[$i][2])
    Next

    Sleep(700);sleep one second for low CPU usage, and because my reminders only set for minutes
    ;Sleep(100);just for now for the seconds test above
WEnd


Func _AddReminder($sName, $sDate, $sReminder)
    ReDim $aMyReminders[UBound($aMyReminders) + 1][3]
    $aMyReminders[0][0] += 1

    $aMyReminders[$aMyReminders[0][0]][0] = $sName
    $aMyReminders[$aMyReminders[0][0]][1] = StringReplace($sDate, "*", ".")
    $aMyReminders[$aMyReminders[0][0]][2] = $sReminder
EndFunc

frew

Link to comment
Share on other sites

This will also pop up a message box at each 00, 10, 20, 30, 40, and 50 seconds of each minute

_AddReminder("Reminder", "**/**/**** **:**:*0", "Paint the rest of the attic room")

Rather than all the

_AddReminder("00", "**/**/**** **:**:00", "This is a test")
_AddReminder("05", "**/**/**** **:**:05", "This is a test")
_AddReminder("10", "**/**/**** **:**:10", "This is a test")
_AddReminder("15", "**/**/**** **:**:15", "This is a test")
_AddReminder("20", "**/**/**** **:**:20", "This is a test")

...etc...that I had worked out.

Bye the way, is there a way to have multiple message boxes pop up, (for example, when I go away from the computer, and, let's say, a number of various reminders may have happened while I was away), or must we close an open message box before any other message boxes will pop up? I notice succeeding messages will not pop up until I click okay

to a message box that is already up.

Thanks for any ideas about that.

frew

Link to comment
Share on other sites

Also, is there a way perhaps to get this reminder:

_AddReminder("Reminder", "**/**/**** **:*0:**", "Go to bed by 11pm, for so many good reasons!")

to happen every ten minutes starting at 8:00pm?

I suppose another If/Then needs to be put in somewhere...If it's "**/**/**** 20:00:00" then MsgBox(), or something?

This may get a little more complex than anyone wants to get into at this point, but if you should find it interesting, and/or if perhaps you should happen to see another way to get these kinds of results, it seems like somehow just a little more tweaking may turn this into a very useful and flexible little reminders script.

Thanks for any ideas about this.

frew

Link to comment
Share on other sites

Also, is there a way perhaps to get this reminder:

_AddReminder("Reminder", "**/**/**** **:*0:**", "Go to bed by 11pm, for so many good reasons!")

to happen every ten minutes starting at 8:00pm?

I suppose another If/Then needs to be put in somewhere...If it's "**/**/**** 20:00:00" then MsgBox(), or something?

This may get a little more complex than anyone wants to get into at this point, but if you should find it interesting, and/or if perhaps you should happen to see another way to get these kinds of results, it seems like somehow just a little more tweaking may turn this into a very useful and flexible little reminders script.

Thanks for any ideas about this.

frew

"**/**/**** 2[0-3]:*0:00"

That will do it :mellow: That only works because 8pm 9pm 10pm and 11pm all start with a 2 (20 21 22 23).

You can cheat and use more complex regex patterns but I don't think there is any way to check a numerical value within a regex. You are going to have to do some research and possibly end up writing your own comparer...

This does work though (if you want to send a message at 6am or 8pm: "**/**/**** (06|20):00:00"

The (##|##) is the 'or' bit or regex, and you could also use a set to get a range: "[0-6]" for example. I recommend trying to learn regex as it is very useful stuff, the helpfile is pretty good at explaining it.

Edit: New version, should be better:

#include <Date.au3>

Global $aMyReminders[1][3] = [[0, 0, 0]] ; Name, Date, Reminder

_AddReminder("1", "**/01/2010 **:42:30", "This is a test")

AdlibRegister("_CheckReminders", 1000)
While 1
    Sleep(100)
WEnd

Func _CheckReminders()
    ; Show current local time
    $tCur = _Date_Time_GetLocalTime()
    $sCur = _Date_Time_SystemTimeToDateTimeStr($tCur)

    For $i = 1 To $aMyReminders[0][0]
        If StringRegExp($sCur, $aMyReminders[$i][1]) Then MsgBox(0, "Reminder: " & $aMyReminders[$i][0], $aMyReminders[$i][2])
    Next
EndFunc

Func _AddReminder($sName, $sDate, $sReminder)
    ReDim $aMyReminders[UBound($aMyReminders) + 1][3]
    $aMyReminders[0][0] += 1

    $aMyReminders[$aMyReminders[0][0]][0] = $sName
    $aMyReminders[$aMyReminders[0][0]][1] = StringReplace($sDate, "*", ".")
    $aMyReminders[$aMyReminders[0][0]][2] = $sReminder
EndFunc
Edited by Mat
Link to comment
Share on other sites

I've worked with this a bit but it does not seem to allow one reminder to come up, then another one, while the previous one remains up. It seems I have to close the reminder that pops up, in order for the next reminder to come up.

Ideally I'd like to be able to have multiple reminders show up, without having to close each one in order to allow the next one to pop up.

Oh well, this is just a little experiment. I do appreciate your wonderful ideas. They provide me with some good things to study too.

One other quick question. If I wanted to have an audio file play as a reminder, would it be complicated to make an adjustment to the script you gave, so that something like this:

ShellExecute("C:\sounds\test.wav")

could be played, rather than a message box popping up?

Thanks for any ideas about this.

frew

Link to comment
Share on other sites

I've worked with this a bit but it does not seem to allow one reminder to come up, then another one, while the previous one remains up. It seems I have to close the reminder that pops up, in order for the next reminder to come up.

Ideally I'd like to be able to have multiple reminders show up, without having to close each one in order to allow the next one to pop up.

Oh well, this is just a little experiment. I do appreciate your wonderful ideas. They provide me with some good things to study too.

One other quick question. If I wanted to have an audio file play as a reminder, would it be complicated to make an adjustment to the script you gave, so that something like this:

ShellExecute("C:\sounds\test.wav")

could be played, rather than a message box popping up?

Thanks for any ideas about this.

frew

Here is a lovely little (if a bit dirty) fix. Instead of the MsgBox statement use this:

Run('"' & @AutoItExe & '" /AutoIt3ExecuteLine  "MsgBox(0, ''Reminder: ' & $aMyReminders[$i][0] & ''', ''' & $aMyReminders[$i][2] & ''')"')

That will start a new process that will show the message box. There is a better way to do it, but I can't get it to work.

As to the next point, yes. Where the MsgBox is at the moment you can put whatever. You could even make a special syntax for it so that you can enter "play:test.wav" or "msg:This is a message" and the script will decide what to do... I don't know how complex you want to make it, but play around until you find something you like. I wrote something simple that should be easy to add to.

#include <Date.au3>
#include <Array.au3>

Global $aMyReminders[1][3] = [[0, 0, 0]] ; Name, Date, Reminder

_AddReminder("1", "**/**/**** **:**:30", "This is a test")
_AddReminder("2", "**/**/**** **:**:40", "play:C:\sounds\test.wav")
_AddReminder("3", "**/**/**** **:**:50", "msg:This is a test (using msg:)")

_ArrayDisplay($aMyReminders)

AdlibRegister("_CheckReminders", 700)
While 1
    Sleep(100)
WEnd

Func _CheckReminders()
    $hTimer = TimerInit()
    ; Show current local time
    Local $tCur = _Date_Time_GetLocalTime()
    Local $sCur = _Date_Time_SystemTimeToDateTimeStr($tCur)

    For $i = 1 To $aMyReminders[0][0]
        If StringRegExp($sCur, $aMyReminders[$i][1]) Then ; Lets give a reminder:
            If StringInStr($aMyReminders[$i][2], ":") Then
                ; Here the user has used our special syntax.
                Local $sBefore = StringLeft($aMyReminders[$i][2], StringInStr($aMyReminders[$i][2], ":") - 1)
                Local $sAfter = StringTrimLeft($aMyReminders[$i][2], StringLen($sBefore) + 1)

                Switch $sBefore
                    Case "play"
                        ShellExecute($sAfter)
                    Case "msg"
                        Run('"' & @AutoItExe & '" /AutoIt3ExecuteLine  "MsgBox(0, ''Reminder: ' & $aMyReminders[$i][0] & ''', ''' & $sAfter & ''')"')
                EndSwitch
            Else
                Run('"' & @AutoItExe & '" /AutoIt3ExecuteLine  "MsgBox(0, ''Reminder: ' & $aMyReminders[$i][0] & ''', ''' & $aMyReminders[$i][2] & ''')"')
            EndIf
        EndIf
    Next
EndFunc

Func _AddReminder($sName, $sDate, $sReminder)
    ReDim $aMyReminders[UBound($aMyReminders) + 1][3]
    $aMyReminders[0][0] += 1

    $aMyReminders[$aMyReminders[0][0]][0] = $sName
    $aMyReminders[$aMyReminders[0][0]][1] = StringReplace($sDate, "*", ".")
    $aMyReminders[$aMyReminders[0][0]][2] = $sReminder
EndFunc

Mat

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...