Jump to content

TrayAlarm


jvanegmond
 Share

Recommended Posts

TrayAlarm

Description:

TrayAlarm is a a lightweight alarm clock application that minimizes to the tray. It's very simple to set up.

Posted Image

When the alarm goes off the following things happen:

  • A sound is played repeatedly to warn you, even when you are not at your PC.
  • A big window pops up to warm you the alarm is going off, even when your sound is off.
You have to click a button to stop the alarm.

In the new version, the main window minimizes to the tray.. in stead of sticking to your desktop.

2011 edit: Since this is quite old, but I still use it frequently. Some public service announcements:

- The original source has been lost. The icons used, the compiled executable: All gone.

- I reposted the original source in the original post. The source was also a few posts down.

- I have fixed the original source code posted to work with AutoIt v3.3.6.1

- Project name changed from Mini Alarm to TrayAlarm because it fits better.

#NoTrayIcon

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

Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 1)

TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "Minimize")

Dim $AlarmON = 0, $FirstTime = 1

$GUI = GUICreate("Mini Alarm", 169, 63, @DesktopWidth * (2 / 3), 0)
GUISetFont(10, 400, 0, "Verdana")
$Label1 = GUICtrlCreateLabel("Alarm Time:", 5, 8, 82, 20)
$Input1 = GUICtrlCreateInput(@HOUR & ":" & @MIN, 90, 5, 76, 24, BitOR($ES_CENTER, $ES_AUTOHSCROLL))
$Button1 = GUICtrlCreateButton("Set Alarm Time", 5, 35, 160, 25)
GUISetState(@SW_SHOW, $GUI)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_MINIMIZE
            GUISetState(@SW_HIDE, $GUI)
            TraySetState(1)
            If $FirstTime Then
                TrayTip("Mini Alarm", "Mini Alarm is minimized to the tray. Click on the tray icon here to restore the window.", 10)
                $FirstTime = 0
            EndIf
        Case $Button1
            If Not $AlarmON Then
                GUICtrlSetState($Input1, $GUI_DISABLE)
                GUICtrlSetData($Button1, "Cancel Alarm")
                $AlarmON = 1
            Else
                GUICtrlSetState($Input1, $GUI_ENABLE)
                GUICtrlSetData($Button1, "Set Alarm Time")
                $AlarmON = 0
            EndIf
    EndSwitch
    If $AlarmON And (GUICtrlRead($Input1) = @HOUR & ":" & @MIN) Then
        GUICtrlSetState($Button1, $GUI_DISABLE)
        Alarm()
        GUICtrlSetState($Input1, $GUI_ENABLE)
        GUICtrlSetState($Button1, $GUI_ENABLE)
        GUICtrlSetData($Button1, "Set Alarm Time")
        $AlarmON = 0
        Minimize()
    EndIf
WEnd

Func Alarm()
    $GUIAlarm = GUICreate("Alarm!!", 294, 77, -1, -1, BitXOR($GUI_SS_DEFAULT_GUI,$WS_MINIMIZEBOX))
    $Button2 = GUICtrlCreateButton("Stop Alarm", 5, 40, 285, 30, 0)
    GUICtrlSetFont(-1, 10, 400, 0, "Verdana")
    GUICtrlCreateLabel("ALARM!! ALARM!! ALARM!!", 5, 5, 285, 29)
    GUICtrlSetFont(-1, 16, 400, 0, "Verdana")
    GUISetState(@SW_SHOW, $GUIAlarm)

    WinSetOnTop($GUIAlarm, "", 1)

    $Beep = 0
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE, $Button2
                ExitLoop
        EndSwitch
        If TimerDiff($Beep) > 1300 Then
            SoundPlay(@WindowsDir & "\media\ringout.wav", 0)
            $Beep = TimerInit()
        EndIf
    WEnd

    GUIDelete($GUIAlarm)
EndFunc   ;==>Alarm

Func Minimize()
    TraySetState(2)
    GUISetState(@SW_SHOW, $GUI)
    GUISetState(@SW_RESTORE, $GUI)
EndFunc   ;==>Minimize
Edited by Manadar
Link to comment
Share on other sites

Nice, thanks for sharing.

Btw, where do you get the skin ?

[u]My Projects[/u]:General:WinShell (Version 1.6)YouTube Video Downloader Core (Version 2.0)Periodic Table Of Chemical Elements (Version 1.0)Web-Based:Directory Listing Script Written In AutoIt3 (Version 1.9 RC1)UDFs:UnicodeURL UDFHTML Entity UDF[u]My Website:[/u]http://dhilip89.hopto.org/[u]Closed Sources:[/u]YouTube Video Downloader (Version 1.3)[quote]If 1 + 1 = 10, then 1 + 1 ≠ 2[/quote]

Link to comment
Share on other sites

I downloaded WindowBlinds 5.5 for free and got the Acrylic skin.

I don't use WB because my PC has only 128MB of RAM.

[u]My Projects[/u]:General:WinShell (Version 1.6)YouTube Video Downloader Core (Version 2.0)Periodic Table Of Chemical Elements (Version 1.0)Web-Based:Directory Listing Script Written In AutoIt3 (Version 1.9 RC1)UDFs:UnicodeURL UDFHTML Entity UDF[u]My Website:[/u]http://dhilip89.hopto.org/[u]Closed Sources:[/u]YouTube Video Downloader (Version 1.3)[quote]If 1 + 1 = 10, then 1 + 1 ≠ 2[/quote]

Link to comment
Share on other sites

Thanks for the compliments.

I mainly made it because I needed this for a game where you have to push a button at random times. Like 15:21, so I would just set up the alarm and done! <_<

The link seems to be broken to download this. Can someone post it again?

Or can Manadar or someone post the source in a message?

Thanks

Link to comment
Share on other sites

The link seems to be broken to download this. Can someone post it again?

Or can Manadar or someone post the source in a message?

Thanks

I just tried the link and it worked. It has worked for others. Maybe it was down, but now it is up again.

Anyway, I'll post the source here, although it becomes cooler when you use the icon. <_<

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=icon.ico
#AutoIt3Wrapper_outfile=MiniAlarm.exe
#AutoIt3Wrapper_Res_Comment=Made by Manadar on 19 oktober 2007
#AutoIt3Wrapper_Res_Description=This is a mini alarm made for the AutoIt community.
#AutoIt3Wrapper_Res_LegalCopyright=Free to copy, including source.
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#Region AutoIt3Wrapper directives section
#EndRegion


#include <Constants.au3>
#include <GUIConstants.au3>

Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 1)

TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "Minimize")

Dim $AlarmON = 0, $FirstTime = 1

$GUI = GUICreate("Mini Alarm", 169, 63, @DesktopWidth * (2 / 3), 0)
GUISetFont(10, 400, 0, "Verdana")
$Label1 = GUICtrlCreateLabel("Alarm Time:", 5, 8, 82, 20)
$Input1 = GUICtrlCreateInput(@HOUR & ":" & @MIN, 90, 5, 76, 24, BitOR($ES_CENTER, $ES_AUTOHSCROLL))
$Button1 = GUICtrlCreateButton("Set Alarm Time", 5, 35, 160, 25)
GUISetState(@SW_SHOW, $GUI)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_MINIMIZE
            GUISetState(@SW_HIDE, $GUI)
            TraySetState(1)
            If $FirstTime Then
                TrayTip("Mini Alarm", "Mini Alarm is minimized to the tray. Click on the tray icon here to restore the window.", 10)
                $FirstTime = 0
            EndIf
        Case $Button1
            If Not $AlarmON Then
                GUICtrlSetState($Input1, $GUI_DISABLE)
                GUICtrlSetData($Button1, "Cancel Alarm")
                $AlarmON = 1
            Else
                GUICtrlSetState($Input1, $GUI_ENABLE)
                GUICtrlSetData($Button1, "Set Alarm Time")
                $AlarmON = 0
            EndIf
    EndSwitch
    If $AlarmON And (GUICtrlRead($Input1) = @HOUR & ":" & @MIN) Then
        GUICtrlSetState($Button1, $GUI_DISABLE)
        Alarm()
        GUICtrlSetState($Input1, $GUI_ENABLE)
        GUICtrlSetState($Button1, $GUI_ENABLE)
        GUICtrlSetData($Button1, "Set Alarm Time")
        $AlarmON = 0
        Minimize()
    EndIf
WEnd

Func Alarm()
    $GUIAlarm = GUICreate("Alarm!!", 294, 77, -1, -1, BitXOR($GUI_SS_DEFAULT_GUI,$WS_MINIMIZEBOX))
    $Button2 = GUICtrlCreateButton("Stop Alarm", 5, 40, 285, 30, 0)
    GUICtrlSetFont(-1, 10, 400, 0, "Verdana")
    GUICtrlCreateLabel("ALARM!! ALARM!! ALARM!!", 5, 5, 285, 29)
    GUICtrlSetFont(-1, 16, 400, 0, "Verdana")
    GUISetState(@SW_SHOW, $GUIAlarm)
    
    WinSetOnTop($GUIAlarm, "", 1)
    
    $Beep = 0
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE, $Button2
                ExitLoop
        EndSwitch
        If TimerDiff($Beep) > 1300 Then
            SoundPlay(@WindowsDir & "\media\ringout.wav", 0)
            $Beep = TimerInit()
        EndIf
    WEnd
    
    GUIDelete($GUIAlarm)
EndFunc   ;==>Alarm

Func Minimize()
    TraySetState(2)
    GUISetState(@SW_SHOW, $GUI)
    GUISetState(@SW_RESTORE, $GUI)
EndFunc   ;==>Minimize
Link to comment
Share on other sites

hi Manadar,

nice script there. good job!

however, i have modified your codes a little so that the Alarm has the "purpose" fucntion.

you may be using it for your games, but i believe for most of us we need the alarm to remind us why the alarm was set in the first place. i m a little busy at work and the "purpose" function will definitely be a big help.

edit : big help....not bug help.

Edited by iceberg

mouse not found....scroll any mouse to continue.

Link to comment
Share on other sites

hi Manadar,

nice script there. good job!

however, i have modified your codes a little so that the Alarm has the "purpose" fucntion.

you may be using it for your games, but i believe for most of us we need the alarm to remind us why the alarm was set in the first place. i m a little busy at work and the "purpose" function will definitely be a big help.

edit : big help....not bug help.

<_< Nice little feature.
Link to comment
Share on other sites

  • 2 weeks later...

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