Sign in to follow this  
Followers 0
onedayillpay

alarm clock

14 posts in this topic

im durt poor

cant afford a clock

so ill make one

one proble...

#include <Date.au3>
MsgBox(0,'',"The time is:" & _NowTime())
While 1
    if _NowTime = 05:30:00 Then ; "05:30:00, {05:30:00, (05:30:00, tryed all differnt kinds of combinations, 05 * 30 * 00
        MsgBox(0,"wake","up")
    EndIf

WEnd

Share this post


Link to post
Share on other sites



try this:

#include <Date.au3>
MsgBox(0,'',"The time is:" & _NowTime())
While 1
    if _NowTime() = "05:30:00" Then ; "05:30:00, {05:30:00, (05:30:00, tryed all differnt kinds of combinations, 05 * 30 * 00
        MsgBox(0,"wake","up")
    EndIf

WEnd

Share this post


Link to post
Share on other sites

still wont work... maybe you have to add "05:30:00 PM" or use

return
or something...

i have been looking threw the Date.au3 file to see if i can find the proper way to do this... but all i can realy do is try randum things, no luck at all :P

Share this post


Link to post
Share on other sites

#include <Date.au3>

While 1
    
    If _NowTime(4) = "21:31" Then       ; added the 4 parameter, to exclude the seconds(i dont think if you wake one second later makes any difference :P)
        MsgBox(0,"wake","up")
    EndIf
    
    Sleep(100)
    
WEnd

Though I bet you a million that you wont wake from a messagebox :P

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Though I bet you a million that you wont wake from a messagebox :D

tRue... some music will work tho...

:P

lol "18:00" would be 8:00 oclock right... :">

Edited by onedayillpay

Share this post


Link to post
Share on other sites

tRue... some music will work tho...

:P

lol 18:00 would be 8:00 oclock right... :">

20:00 is 8:00


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Voila! An alarm clock, no speaker required even :-)

#include <Date.au3>
Alarm()

Func Alarm()
    sleep(6000) ;so that the alarm does not go off again when you press space
    HotKeySet("{SPACE}")
    While 1
        If _NowTime(4) = "21:31" Then       ; added the 4 parameter, to exclude the seconds(i dont think if you wake one second later makes any difference tongue.gif)
            While 1
                HotKeySet("{SPACE}", "Alarm") ;resets alarm
                Beep(500, 500)
                Beep(1000, 500);dont have to remeber to turn speakers on :-)
                Beep(1500, 500)
                Beep(1500, 500)
                Beep(1000, 500)
                Beep(500, 500)
            WEnd
        EndIf
        Sleep(100)
    WEnd
EndFunc

play with the lengths and frequencys of the beeps, find the most annoying thing possible :-)

Edited by smstroble

MUHAHAHAHAHA

Share this post


Link to post
Share on other sites

I made this for mycelf & im pretty happy with it at the moment,try it out.

#include <GUIConstants.au3>
#include <Date.au3>
Opt("TrayMenuMode",1)   ; Default tray menu items (Script Paused/Exit) will not be shown
global $song, $Go, $Tray_exititem_item, $Secs, $Mins, $Hour, $time_,$rest_time_window

;~ Gui 1
;~ -------------------------------------------------------------------------------------------------------
$mainwindow = GUICreate("Alarm", 400, 100)
$slider = GUICtrlCreateSlider (190,70,200,20,$TBS_NOTICKS) ;Slider
GUICtrlSetLimit(-1,100,0)   ; change min/max value
GUICtrlSetData(-1,_SoundGetWaveVolume()) ; set cursor
;~ -------------------------------------------------------------------------------------------------------
$browse = GUICtrlCreateButton("Browse", 5, 10, 50, 20)   ;Browse Button
$start = GUICtrlCreateButton("Start", 5, 34, 50, 20)   ;Browse Button
$e1 = GUICtrlCreateInput("", 60, 10, 330, 20)      ;Are Where the chosen song is displayed
;~ -------------------------------------------------------------------------------------------------------
$iniread_Hour = IniRead("C:\myfile.ini", "Alarm", "hour","")
$iniread_Min = IniRead("C:\myfile.ini", "Alarm", "min","")

$input_ALARM_data = GUICtrlCreateCombo ($iniread_Hour, 60,70,40, 20) ; create first item
GUICtrlSetData(-1,"00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24",$iniread_Hour) ; add other item snd set a new default
$input_ALARM_data2 = GUICtrlCreateCombo ($iniread_Min, 100,70,40, 20) ; create first item
GUICtrlSetData(-1,"|00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60",$iniread_Min) ; add other item snd set a new default
;~ -------------------------------------------------------------------------------------------------------
$Checkbox_RestReminder = GUICtrlCreateCheckbox("Remind to rest every 1.H", 60, 38)
GUISetState(@SW_SHOW)   ; makes Gui Visible

;~ Gui 2
;~ -------------------------------------------------------------------------------------------------------
$rest_time_window = GUICreate("RestReminder", 400, 100)
$font="Comic Sans MS"
GUISetFont (30, 400, 1, $font)   ; will display underlined characters
GUICtrlCreateLabel ("TIME TO REST !!!",35,20)
GUICtrlSetColor(-1,0xff) ;blue
GUISetState(@SW_HIDE)   ; makes Gui Visible
;~ *********************************************************************************************************

;~ Tray MENU
;~ ---------------------------------------------------------------------------------------------------------
$Tray_Maximize_item     = TrayCreateItem("Maximize")
$settingsitem   = TrayCreateMenu("Rest opt.")
$Enable   = TrayCreateItem("Enable", $settingsitem)
$Disnable   = TrayCreateItem("Disable", $settingsitem)
TrayCreateItem("")
$Tray_exititem_item       = TrayCreateItem("Exit")
TraySetState(@SW_HIDE)

if GUICtrlRead($Checkbox_RestReminder) = $GUI_UNCHECKED Then TraySetState(4)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func _SoundGetWaveVolume() ; get the et Wav Sound Volume (Author gafrost)
    Local $WaveVol = -1, $p, $ret
    Const $MMSYSERR_NOERROR = 0
    $p = DllStructCreate ("dword")
    If @error Then
        SetError(2)
        Return -2
    EndIf
    $ret = DllCall("winmm.dll", "long", "waveOutGetVolume", "long", -1, "long", DllStructGetPtr ($p))
    If ($ret[0] == $MMSYSERR_NOERROR) Then
        $WaveVol = Round(Dec(StringRight(Hex(DllStructGetData ($p, 1), 8), 4)) / 0xFFFF * 100)
    Else
        SetError(1)
    EndIf
    $Struct=0 
    Return $WaveVol
EndFunc;==>_SoundGetWaveVolume

While 1  
    SoundSetWaveVolume(GUICtrlRead($slider)) ; set slider to current volume value
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
    $msg = GUIGetMsg()
    $msg1 = TrayGetMsg()
    Select
    Case $msg1 = $Tray_exititem_item
        Exit
    Case $msg = $GUI_EVENT_MINIMIZE
        GUISetState(@SW_HIDE,$mainwindow)
        GUISetState(@SW_HIDE,$rest_time_window)
;~ ---------------------------------------------------------------------------------------------------------
    Case $msg = $GUI_EVENT_CLOSE
        _CLOSEClicked() ; call _CLOSEClicked() funtion
;~ ---------------------------------------------------------------------------------------------------------
    Case $msg1 = $Tray_Maximize_item
        GUISetState(@SW_SHOW,$mainwindow)
        GUISetState(@SW_RESTORE,$mainwindow)
;~ --------------------------------------------------------------
;~ Changing Tray icon modes , Blinking & not blinking
case $msg1 = $Enable
        TraySetState(8)
        GUICtrlSetState($Checkbox_RestReminder,$GUI_CHECKED)
    case $msg1 = $Disnable
        TraySetState(4)
        GUICtrlSetState($Checkbox_RestReminder,$GUI_UNCHECKED)
;~ --------------------------------------------------------------
    Case $msg = $Checkbox_RestReminder And BitAND(GUICtrlRead($Checkbox_RestReminder), $GUI_CHECKED) = $GUI_CHECKED
        TraySetState(8)
    Case $msg = $Checkbox_RestReminder And BitAND(GUICtrlRead($Checkbox_RestReminder), $GUI_UNCHECKED) = $GUI_UNCHECKED
        TraySetState(4)
;~ --------------------------------------------------------------
    Case $msg = $browse
        _Browse() ; call _Browse() funtion
    Case $msg = $start
        GUISetState(@SW_HIDE,$mainwindow)
        AdlibEnable("_CheckTime", 60000) ; checks time every 1 minute (calls _CheckTime() function )
    EndSelect
WEnd

Func _CLOSEClicked()   ;Exit GUI function
        $Hwnd = WinGetHandle('')
        If $Hwnd = $rest_time_window Then
            GUISetState(@SW_HIDE,$rest_time_window)
        ElseIf $Hwnd = $mainwindow Then
            Exit
        EndIf
;~     SoundSetWaveVolume(50)  ;if u close GUI
    Sleep(100)        
EndFunc 

Func _Browse()
    ;opens desktop after pressing Browse button & lets u choose files
    $song = FileOpenDialog("Play MP3/WAV sound", @DesktopDir, "MP3 sound (*.mp3;*.wav;*.wma)", 1 + 4)

    ;~ SoundSetWaveVolume(0)   ; setting volume
    $mid = $song
    While 1
        $songstr = StringInStr($mid, "\")
        If $songstr = 0 Then ExitLoop
        $mid = StringMid($mid, $songstr + 1)
    WEnd
    $sk = $mid
    ;Sets chosen song name into the Are Where the chosen song is displayed
    GUICtrlSetData($e1, $sk)
;~  AdlibEnable("_CheckTime", 60000) ; checks time every 1 minute
EndFunc   ;==>Browse

;Alarm settings
Func _CheckTime()
    IniWrite("C:\myfile.ini", "Alarm", "hour",GUICtrlRead($input_ALARM_data))
    IniWrite("C:\myfile.ini", "Alarm", "min",GUICtrlRead($input_ALARM_data2))
    
    $hour = @HOUR
    $minute = @MIN
    $time_ = $hour & ":" & $minute
    
if GUICtrlRead($Checkbox_RestReminder) = $GUI_CHECKED Then ; Reast reminder time matching
If $time_ = "00:00" Then _play_it()
If $time_ = "01:00" Then _play_it()
If $time_ = "02:00" Then _play_it()
If $time_ = "03:00" Then _play_it()
If $time_ = "04:00" Then _play_it()
If $time_ = "05:00" Then _play_it()
If $time_ = "06:00" Then _play_it()
If $time_ = "07:00" Then _play_it()
If $time_ = "08:00" Then _play_it()
If $time_ = "09:00" Then _play_it()
If $time_ = "10:00" Then _play_it()
If $time_ = "11:00" Then _play_it()
If $time_ = "12:00" Then _play_it()
If $time_ = "13:00" Then _play_it()
If $time_ = "14:00" Then _play_it()
If $time_ = "15:00" Then _play_it()
If $time_ = "16:00" Then _play_it()
If $time_ = "17:00" Then _play_it()
If $time_ = "18:00" Then _play_it()
If $time_ = "19:00" Then _play_it()
If $time_ = "20:00" Then _play_it()
If $time_ = "21:00" Then _play_it()
If $time_ = "22:00" Then _play_it()
If $time_ = "23:00" Then _play_it()
EndIf

If $time_ = GUICtrlRead($input_ALARM_data) & ":" & GUICtrlRead($input_ALARM_data2) Then  ; if time matches play the sound
;~   -------------------------------------
        GUICtrlSetData($slider,100) ; set slider to 100 & Volume = 100 then
        GUICtrlRead($song); read the song
        SoundPlay($song) ; play it
;~   -------------------------------------
    EndIf
EndFunc 

Func _play_it()
;~   ----------------------------------------------------------------------------------------
        GUISetState(@SW_SHOW,$rest_time_window)
        GUISetState(@SW_RESTORE,$rest_time_window)
        GUICtrlSetData($slider,100) ; set slider to 100 & Volume = 100 then
        GUICtrlRead($song); read the song
        SoundPlay($song) ; play it
        Sleep(5000)
        if WinExists("RestReminder") Then GUISetState(@SW_HIDE,$rest_time_window)
;~   ----------------------------------------------------------------------------------------
EndFunc

Share this post


Link to post
Share on other sites

Voila! An alarm clock, no speaker required even :-)

Errr, yes, a speaker is required. The speaker just happens to typically be in the case.

Share this post


Link to post
Share on other sites

Errr, yes, a speaker is required. The speaker just happens to typically be in the case.

Bah, your so picky. you still dont have to turn it on or anything, and i cant think of a computer that doesnt have one.

So :P (need an angry looking one) lol.


MUHAHAHAHAHA

Share this post


Link to post
Share on other sites

Bah, your so picky. you still dont have to turn it on or anything, and i cant think of a computer that doesnt have one.

So :P (need an angry looking one) lol.

Well... mine doesn't have one, for example. Neither does a PC I was sent.

Share this post


Link to post
Share on other sites

If you have speakers, blast up the volume and add this to your script:

SoundPlay(@WindowsDir & "\media\NOTIFY.WAV",1)
Sleep(1000)
SoundPlay(@WindowsDir & "\media\NOTIFY.WAV",1)
Sleep(1000)
SoundPlay(@WindowsDir & "\media\NOTIFY.WAV",1)
Sleep(1000)
SoundPlay(@WindowsDir & "\media\NOTIFY.WAV",1)

Also, add a TimerInit so if you end up falling back to sleep, it will wait 10 minutes and replay the sounds.

Hope that helps,

Kurt


Awaiting Diablo III..

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

May not be the best code you've ever read, but I just made this last night and fixed a time issue i was getting with the _Now() function, this evening. Simple & Practical. Anywho, my only issue with it right now, is when I start the alarm clock, and then click cancel, it takes multiple clicks and/or a few second wait for it to actually recognize the user input. I realize i have the adlib command set to 2000 (2 seconds) but even without that it's slow, is there a better way to do this?

#include <GuiConstants.au3>
#include <date.au3>

$Window = GUICreate("iTunes Alarm Clock", 350, 175) ; will create a dialog box that when displayed is centered
$WindowTitle = "iTunes Alarm Clock"
GUISetState () 

;;Labels
GuictrlcreateLabel( "Alarm Set Time:", 25, 30)
GUICtrlCreateLabel("Path to Folder: ", 25, 55)
GUICtrlCreateLabel("SearchMusic:", 25, 80)

;;Inputs
$InputAlarmTime = GUICtrlCreateInput( _Now(), 100, 25, 125)
$InputProgPath = GUICtrlCreateInput( "C:\Program Files (x86)\Utilities\iTunes", 100, 50, 225)
$InputProgExe = guictrlRead($InputProgPath)  & "\itunes.exe"
$InputProgPathname = GUICtrlRead($InputProgPath)
$InputFind = GUICtrlCreateInput("", 100, 75, 100)
$Cancel = GUICtrlCreateButton("&Cancel", 210, 115)
$SetAlarm = GUICtrlCreateButton("&Set Alarm", 85, 115)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
            
        Case $msg = $Cancel
            Exit
         
        Case $msg = $SetAlarm
            AdlibEnable( "TerminateCheck",2000)
            $AlarmTime = GuiCtrlRead($InputAlarmTime)
                $FindPlay = GUICtrlRead($InputFind)
                
                Do
                    winsetstate($WindowTitle, "", @sw_Minimize)
                    $Now = _Now() 
                    If $Now >= $AlarmTime Then
                        Run($InputProgExe,$InputProgPathname)
                        sleep(4000)
                        ControlFocus("iTunes", "", 101)
                        sleep(1000)
                        Send($FindPlay)
                        Send(@CR & @CR & @TAB)
                        sleep(5000)
                        ControlFocus("iTunes", "", 101)
                        ControlSend("iTunes", "", 101, " ")
                        Exit
                    EndIf
                Until $Now > $AlarmTime + 1
         
    EndSelect

WEnd

Func TerminateCheck()
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then
            Exit
        ElseIf $msg = $Cancel Then
            Exit
    EndIf
EndFunc
Edited by funcwtf

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