Sign in to follow this  
Followers 0
ahha

Simple popup 2009 calendar.

4 posts in this topic

Simple popup 2009 calendar.

Place the program '2009 Calendar v1d.exe' in your startup folder or manually start by clicking on '9' icon.

An icon with '9' will be placed in your tray.

Passing mouse over tray icon '9' will pop up calendar.

Calendar can be closed or minimized.

Clicking on tray icon '9' will allow you to Exit the program.

Enjoy - ahha

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=9.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;2009 Calendar
;author: ahha
$version = "v1d"
$debug = 0          ;1=on 0=off

#include <GUIConstantsEx.au3>
#include <Constants.au3>

Opt("TrayOnEventMode",1)    ;enable tray events
Opt("TrayMenuMode",1)       ;no default menu

Global $eventcount = 0      ;let's keep track of events

Global $calendar2009 = ""   ;define the 2009 Calendar and build it up below
$calendar2009 = $calendar2009 & "                                  2009                                    "& @CRLF
$calendar2009 = $calendar2009 & "                          (and Federal Holidays)                          "& @CRLF
$calendar2009 = $calendar2009 & "                                                                          "& @CRLF
$calendar2009 = $calendar2009 & "       January                   February                   March         "& @CRLF
$calendar2009 = $calendar2009 & "     (01/xx/2009)              (02/xx/2009)              (03/xx/2009)     "& @CRLF
$calendar2009 = $calendar2009 & " Su Mo Tu We Th Fr Sa      Su Mo Tu We Th Fr Sa      Su Mo Tu We Th Fr Sa "& @CRLF
$calendar2009 = $calendar2009 & "              1  2  3       1  2  3  4  5  6  7       1  2  3  4  5  6  7 "& @CRLF
$calendar2009 = $calendar2009 & "  4  5  6  7  8  9 10       8  9 10 11 12 13 14       8  9 10 11 12 13 14 "& @CRLF
$calendar2009 = $calendar2009 & " 11 12 13 14 15 16 17      15 16 17 18 19 20 21      15 16 17 18 19 20 21 "& @CRLF
$calendar2009 = $calendar2009 & " 18 19 20 21 22 23 24      22 23 24 25 26 27 28      22 23 24 25 26 27 28 "& @CRLF
$calendar2009 = $calendar2009 & " 25 26 27 28 29 30 31                                29 30 31             "& @CRLF
$calendar2009 = $calendar2009 & "                                                                          "& @CRLF
$calendar2009 = $calendar2009 & " 1  New Years Day        16 - Washingtons Birthday                     "& @CRLF
$calendar2009 = $calendar2009 & " 19 - Martin Luther King, Jr. Day                                         "& @CRLF
$calendar2009 = $calendar2009 & "                                                                          "& @CRLF
$calendar2009 = $calendar2009 & "       April                       May                      June          "& @CRLF
$calendar2009 = $calendar2009 & "     (04/xx/2009)              (05/xx/2009)              (06/xx/2009)     "& @CRLF
$calendar2009 = $calendar2009 & " Su Mo Tu We Th Fr Sa      Su Mo Tu We Th Fr Sa      Su Mo Tu We Th Fr Sa "& @CRLF
$calendar2009 = $calendar2009 & "           1  2  3  4                      1  2          1  2  3  4  5  6 "& @CRLF
$calendar2009 = $calendar2009 & "  5  6  7  8  9 10 11       3  4  5  6  7  8  9       7  8  9 10 11 12 13 "& @CRLF
$calendar2009 = $calendar2009 & " 12 13 14 15 16 17 18      10 11 12 13 14 15 16      14 15 16 17 18 19 20 "& @CRLF
$calendar2009 = $calendar2009 & " 19 20 21 22 23 24 25      17 18 19 20 21 22 23      21 22 23 24 25 26 27 "& @CRLF
$calendar2009 = $calendar2009 & " 26 27 28 29 30            24 25 26 27 28 29 30      28 29 30             "& @CRLF
$calendar2009 = $calendar2009 & "                           31                                             "& @CRLF
$calendar2009 = $calendar2009 & "                              25 - Memorial Day                           "& @CRLF
$calendar2009 = $calendar2009 & "                                                                          "& @CRLF
$calendar2009 = $calendar2009 & "        July                     August                   September       "& @CRLF
$calendar2009 = $calendar2009 & "     (07/xx/2009)             (08/xx/2009)               (09/xx/2009)     "& @CRLF
$calendar2009 = $calendar2009 & " Su Mo Tu We Th Fr Sa      Su Mo Tu We Th Fr Sa      Su Mo Tu We Th Fr Sa "& @CRLF
$calendar2009 = $calendar2009 & "           1  2  3  4                         1             1  2  3  4  5 "& @CRLF
$calendar2009 = $calendar2009 & "  5  6  7  8  9 10 11       2  3  4  5  6  7  8       6  7  8  9 10 11 12 "& @CRLF
$calendar2009 = $calendar2009 & " 12 13 14 15 16 17 18       9 10 11 12 13 14 15      13 14 15 16 17 18 19 "& @CRLF
$calendar2009 = $calendar2009 & " 19 20 21 22 23 24 25      16 17 18 19 20 21 22      20 21 22 23 24 25 26 "& @CRLF
$calendar2009 = $calendar2009 & " 26 27 28 29 30 31         23 24 25 26 27 28 29      27 28 29 30          "& @CRLF
$calendar2009 = $calendar2009 & "                           30 31                                          "& @CRLF
$calendar2009 = $calendar2009 & " 3-4 Independence Day                                                     "& @CRLF
$calendar2009 = $calendar2009 & "                                                                          "& @CRLF
$calendar2009 = $calendar2009 & "       October                  November                   December       "& @CRLF
$calendar2009 = $calendar2009 & "     (10/xx/2009)             (11/xx/2009)               (12/xx/2009)     "& @CRLF
$calendar2009 = $calendar2009 & " Su Mo Tu We Th Fr Sa      Su Mo Tu We Th Fr Sa      Su Mo Tu We Th Fr Sa "& @CRLF
$calendar2009 = $calendar2009 & "              1  2  3       1  2  3  4  5  6  7             1  2  3  4  5 "& @CRLF
$calendar2009 = $calendar2009 & "  4  5  6  7  8  9 10       8  9 10 11 12 13 14       6  7  8  9 10 11 12 "& @CRLF
$calendar2009 = $calendar2009 & " 11 12 13 14 15 16 17      15 16 17 18 19 20 21      13 14 15 16 17 18 19 "& @CRLF
$calendar2009 = $calendar2009 & " 18 19 20 21 22 23 24      22 23 24 25 26 27 28      20 21 22 23 24 25 26 "& @CRLF
$calendar2009 = $calendar2009 & " 25 26 27 28 29 30 31      29 30                     27 28 29 30 31       "& @CRLF
$calendar2009 = $calendar2009 & "                                                                          "& @CRLF
$calendar2009 = $calendar2009 & " 12  Columbus Day         11  Veterans Day         25  Christmas Day   "& @CRLF
$calendar2009 = $calendar2009 & "                           26  Thanksgiving Day                          "& @CRLF
$calendar2009 = $calendar2009 & "                                                                          "& @CRLF
$calendar2009 = $calendar2009 & "                                                                          "& @CRLF


$exit = TrayCreateItem("Exit 2009 Calendar")    ;show Exit option to user.  In fact only item shown.
TrayItemSetOnEvent($exit,"ExitEvent")           ;associate tray item with routine to invoke
TraySetState(1)                                 ;show the tray icon so user can operate on it or trigger it

TraySetOnEvent ($TRAY_EVENT_MOUSEOVER, "DisplayMessage")    ;careful as this sends zillions of events automatically, need to turn it off ASAP after triggering to cut the event generation off


While 1
    Sleep(2147483647 )  ; Idle loop - sleep for 24 days, basically sleep forever.
WEnd

Exit    


; =========================== Functions ===================================

Func DisplayMessage()
    TraySetOnEvent ($TRAY_EVENT_MOUSEOVER, "")  ;Turn it off immediately so that we cut down on multiple same events
    $eventcount = $eventcount + 1
    If $debug =1 Then Msgbox(0+262144,"DisplayMessage","About to Show2009Calendar().   $eventcount="&$eventcount)
    Show2009Calendar()  ;display it
    If $debug =1 Then Msgbox(0+262144,"DisplayMessage","Going to turn mouseover back on.  $eventcount="&$eventcount)
    Opt("TrayOnEventMode",1)    ;enable tray events
    TraySetOnEvent ($TRAY_EVENT_MOUSEOVER, "DisplayMessage")    ;re-enable events after calendar window closed since we are not hovering over tray icon
EndFunc


Func Show2009Calendar()
    GUICreate("2009 Calendar and Federal Holidays    ..by ahha                       "& $version, 540, 757)  ; create dialog box that when displayed is centered
    GUISetBkColor (0xFFFF00)        ;set the background color of the GUI window - good yellow - coded for color blind. (0x99CC32 = lime, 0x00CF00 = good green) 
    GUISetFont(9, 400, 0, "Courier New")    ; will display normal mono-spaced characters
    GUICtrlCreateLabel($calendar2009, 10, 20)
    GUISetState()   ;show the GUI window
    Opt("TrayOnEventMode",0)    ;turn OFF tray events so we can use TrayGetMsg to poll for event
    
    ;display GUI until closed
    While 1         
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then 
            If $debug =1 Then Msgbox(0+262144,"Show2009Calendar","Exiting window.  $eventcount="&$eventcount)
            GUIDelete()     ;destroy the window
            ExitLoop
        EndIf
        
        If TrayGetMsg() = $exit Then    ;check tray for Exit as well
            If $debug =1 Then Msgbox(0+262144,"Show2009Calendar","Tray Exiting window.  $eventcount="&$eventcount)
            GUIDelete()     ;destroy the window
            Exit            ;out of entire program
            ;ExitLoop
        EndIf
    WEnd
    
EndFunc   ;Show2009Calendar



Func ExitEvent()
    If $debug =1 Then Msgbox(0+262144,"ExitEvent","About to exit program.  $eventcount="&$eventcount)
    Exit
EndFunc

2009_Calendar_v1d.exe

Share this post


Link to post
Share on other sites



Wow, you can made this on very easy way :(

Btw, never mind, good job for newbie :mellow:


[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Share this post


Link to post
Share on other sites

I havn't tried your code but as n3nE said, the code can be improved alot and shorten down.

Some of the things:

Instead of $var = $var & "" use $var &= ""

Loop the days with _DateDaysInMonth()

Sleep(10) will have the same effect.

If $debug =1 Then

can be shorten down to:

If $debug Then

What is the reason with 0+262144?

0+262144=262144

Share this post


Link to post
Share on other sites

I havn't tried your code but as n3nE said, the code can be improved alot and shorten down.

Some of the things:

Instead of $var = $var & "" use $var &= ""

Loop the days with _DateDaysInMonth()

Sleep(10) will have the same effect.

If $debug =1 Then

can be shorten down to:

If $debug Then

What is the reason with 0+262144?

0+262144=262144

Yes I can use the C construct for concatenation, however a newbie may not understand what's going on and if the AU3 compiler is worth it's salt there is no difference in the code or the execution.

Not sure how _DateDaysInMonth() helps me as I need to dump this into a GUI and having the number of days in a month is the least of my issues.

Yes, on the debug. However, I often have different levels of debug and so code 0 for off, 1 for all on, 2 for entry/exit from routines, etc.

Yes, the Sleep can be near anything. I set it at max to give me an indication that the code is really interrupt driven not polled at that point.

The 0+262144 is because I pick the MsgBox options and just have them add together rather than me doing it manually, so I start with 0 and add from there.

You can help me with determining how in the GUI to highlight the current date. That would be helpful. I realize it needs to loop looking for a date change at midnight, but am not sure if I should muck with the GUI on a fixed width basis or try an X,Y approach. Any suggestions appreciated.

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