Sign in to follow this  
Followers 0
Saroset

Alarm Clock (Unfinished)

3 posts in this topic

Ok, so I needed a computer alarm clock and couldn't find one that was free and worked. This is my unfinished version. I'd love it if someone more experienced would take what I've done and add on to it. I've run out of free time to work on this. It currently is partially functional, given that you have to edit the actual file that needs to run within the script. The time entered works, I think. I cant remember if the whole AM/PM thing works or not.

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.10.0
 Author:         Alex Jordan

 Script Function:
    Alarm Clock.

Wrote this because I cant seem to find any free alarm clocks that will
run something or open a file at a givin time. Found a few trial versions
but nothing free or functional. If you want something done right....

#ce ----------------------------------------------------------------------------

; Script Start

#include <GUIConstants.au3>

;Variables.
$GUITIMEH = "0" ;Variable for hour section of time control.
$GUITIMEM = "0" ;Variable for minute section of time control.
$GUITIMES = "0" ;Variable for second section of time control.
$TIMEREADH = "00" ;Stores value of hour.
$TIMEREADM = "00" ;Stores value of minute.
$TIMEREADS = "00" ;Stores value of second.
$TIMEH = "00" ;Actual system hour.
$TIMEM = "00" ;Actual system minute.
$TIMES = "00" ;Actual system second.
$GUISTATE = "00" ;GUIGetMsg.
$AMPM = "00" ;AM/PM combo.
$PATHEDIT = "00" ;File path control var.
$FILEPATH = "C:/" ;File path.
$FILEREAD = "C:/" ;Stores file path.
$DEBUGCHECK = "0" ;Debug check ctrl.
$DEBUGREAD = "0" ;Read.
$TOGGLE = "0" ;Prevent debug from being spammed.

;Create GUI.
GUICreate("Alarm Clock", 500, 300, 300, 300)

;Descriptive labels.

;Edit boxes to pull alarm time from.
$GUITIMEH = GUICtrlCreateEdit("HH", 20, 70, 50, 20)
$GUITIMEM = GUICtrlCreateEdit("MM", 70, 70, 50, 20)
$GUITIMES = GUICtrlCreateEdit("SS", 120, 70, 50, 20)

;AM/PM combo.
$AMPM = GUICtrlCreateCombo( "", 170, 70, 50, 20)
GUICtrlSetData($AMPM, "AM|PM", "AM")

;File path edit
$PATHEDIT = GUICtrlCreateEdit("File Path", 20, 100, 300, 20)

$DEBUGCHECK = GUICtrlCreateCheckbox("Debug", 20, 150)

GUISetState()

$FILEEXIST = FileExists("C:/AlarmSettings.txt")


while 1
    
    $GUISTATE = GUIGetMsg()
    $TIMEH = @HOUR
    $TIMEM = @MIN
    $TIMES = @SEC
    
    ;retrieve value of entered time.
    $TIMEREADH = GUICtrlRead($GUITIMEH)
    $TIMEREADM = GUICtrlRead($GUITIMEM)
    $TIMEREADS = GUICtrlRead($GUITIMES)
    
    
    
    ;retrieve entered file for ring.
    $FILEREAD = GUICtrlRead($PATHEDIT)
    
    ;Check to see if current time is the alarm time.
    if $TIMEH == $TIMEREADH Then
        if $TIMEM == $TIMEREADM Then
            if $TIMES == $TIMEREADS Then
            
            fRINGALARM()
            
            EndIf
        Else
        EndIf
    Else
    EndIf
    
    
    $DEBUGREAD = GUICtrlRead($DEBUGCHECK)
    ;GUICtrlSetData($GUITIMEH, $DEBUGREAD)
    
if $DEBUGREAD == 1 Then
    if $TOGGLE == 0 Then
        $TOGGLE = 1
        fDEBUG()
    Else
    EndIf
Else
EndIf

    
    select
        Case $GUISTATE = $GUI_EVENT_CLOSE
        
            exit
    
    EndSelect
WEnd

Func fRINGALARM()
    
    WinActivate("Windows Media Player")
    WinWaitActive("Windows Media Player")
    MouseClick("Left", 24, 970)
    
    
EndFunc

Func fDEBUG()
    
$TEXTDEBUG = FileOpen("AlarmDebug.txt", 1)

If $TEXTDEBUG = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

FileWrite($TEXTDEBUG, @HOUR & ":" & @MIN & ":" & @SEC & @CRLF)
FileWrite($TEXTDEBUG, "GUITIMEH: " & $GUITIMEH & @CRLF)
FileWrite($TEXTDEBUG, "GUITIMEM: " & $GUITIMEM & @CRLF)
FileWrite($TEXTDEBUG, "GUITIMES: " & $GUITIMES & @CRLF)
FileWrite($TEXTDEBUG, "$TIMEREADH: " & $TIMEREADH & @CRLF)
FileWrite($TEXTDEBUG, "$TIMEREADM: " & $TIMEREADM & @CRLF)
FileWrite($TEXTDEBUG, "$TIMEREADS: " & $TIMEREADS & @CRLF)
FileWrite($TEXTDEBUG, "TIMEH: " & $TIMEH & @CRLF)
FileWrite($TEXTDEBUG, "TIMEM: " & $TIMEM & @CRLF)
FileWrite($TEXTDEBUG, "TIMES: " & $TIMES & @CRLF)
FileWrite($TEXTDEBUG, "GUISTATE: " & $GUISTATE & @CRLF)
FileWrite($TEXTDEBUG, "AMPM: " & $AMPM & @CRLF)
FileWrite($TEXTDEBUG, "PATHEDIT: " & $PATHEDIT & @CRLF)
FileWrite($TEXTDEBUG, "FILEPATH: " & $FILEPATH & @CRLF)
FileWrite($TEXTDEBUG, "FILEREAD: " & $FILEREAD & @CRLF)
FileWrite($TEXTDEBUG, "DEBUGCHECK: " & $DEBUGCHECK & @CRLF)
FileWrite($TEXTDEBUG, "DEBUGREAD: " & $DEBUGREAD & @CRLF)
FileWrite($TEXTDEBUG, "TOGGLE: " & $TOGGLE & @CRLF)
FileWrite($TEXTDEBUG, @CRLF)



FileClose($TEXTDEBUG)

endfunc

Share this post


Link to post
Share on other sites



Ok, so I needed a computer alarm clock and couldn't find one that was free and worked. This is my unfinished version. I'd love it if someone more experienced would take what I've done and add on to it. I've run out of free time to work on this. It currently is partially functional, given that you have to edit the actual file that needs to run within the script. The time entered works, I think. I cant remember if the whole AM/PM thing works or not.

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.10.0
 Author:         Alex Jordan

 Script Function:
    Alarm Clock.

Wrote this because I cant seem to find any free alarm clocks that will
run something or open a file at a givin time. Found a few trial versions
but nothing free or functional. If you want something done right....

#ce ----------------------------------------------------------------------------

; Script Start

#include <GUIConstants.au3>

;Variables.
$GUITIMEH = "0" ;Variable for hour section of time control.
$GUITIMEM = "0" ;Variable for minute section of time control.
$GUITIMES = "0" ;Variable for second section of time control.
$TIMEREADH = "00" ;Stores value of hour.
$TIMEREADM = "00" ;Stores value of minute.
$TIMEREADS = "00" ;Stores value of second.
$TIMEH = "00" ;Actual system hour.
$TIMEM = "00" ;Actual system minute.
$TIMES = "00" ;Actual system second.
$GUISTATE = "00" ;GUIGetMsg.
$AMPM = "00" ;AM/PM combo.
$PATHEDIT = "00" ;File path control var.
$FILEPATH = "C:/" ;File path.
$FILEREAD = "C:/" ;Stores file path.
$DEBUGCHECK = "0" ;Debug check ctrl.
$DEBUGREAD = "0" ;Read.
$TOGGLE = "0" ;Prevent debug from being spammed.

;Create GUI.
GUICreate("Alarm Clock", 500, 300, 300, 300)

;Descriptive labels.

;Edit boxes to pull alarm time from.
$GUITIMEH = GUICtrlCreateEdit("HH", 20, 70, 50, 20)
$GUITIMEM = GUICtrlCreateEdit("MM", 70, 70, 50, 20)
$GUITIMES = GUICtrlCreateEdit("SS", 120, 70, 50, 20)

;AM/PM combo.
$AMPM = GUICtrlCreateCombo( "", 170, 70, 50, 20)
GUICtrlSetData($AMPM, "AM|PM", "AM")

;File path edit
$PATHEDIT = GUICtrlCreateEdit("File Path", 20, 100, 300, 20)

$DEBUGCHECK = GUICtrlCreateCheckbox("Debug", 20, 150)

GUISetState()

$FILEEXIST = FileExists("C:/AlarmSettings.txt")


while 1
    
    $GUISTATE = GUIGetMsg()
    $TIMEH = @HOUR
    $TIMEM = @MIN
    $TIMES = @SEC
    
    ;retrieve value of entered time.
    $TIMEREADH = GUICtrlRead($GUITIMEH)
    $TIMEREADM = GUICtrlRead($GUITIMEM)
    $TIMEREADS = GUICtrlRead($GUITIMES)
    
    
    
    ;retrieve entered file for ring.
    $FILEREAD = GUICtrlRead($PATHEDIT)
    
    ;Check to see if current time is the alarm time.
    if $TIMEH == $TIMEREADH Then
        if $TIMEM == $TIMEREADM Then
            if $TIMES == $TIMEREADS Then
            
            fRINGALARM()
            
            EndIf
        Else
        EndIf
    Else
    EndIf
    
    
    $DEBUGREAD = GUICtrlRead($DEBUGCHECK)
    ;GUICtrlSetData($GUITIMEH, $DEBUGREAD)
    
if $DEBUGREAD == 1 Then
    if $TOGGLE == 0 Then
        $TOGGLE = 1
        fDEBUG()
    Else
    EndIf
Else
EndIf

    
    select
        Case $GUISTATE = $GUI_EVENT_CLOSE
        
            exit
    
    EndSelect
WEnd

Func fRINGALARM()
    
    WinActivate("Windows Media Player")
    WinWaitActive("Windows Media Player")
    MouseClick("Left", 24, 970)
    
    
EndFunc

Func fDEBUG()
    
$TEXTDEBUG = FileOpen("AlarmDebug.txt", 1)

If $TEXTDEBUG = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

FileWrite($TEXTDEBUG, @HOUR & ":" & @MIN & ":" & @SEC & @CRLF)
FileWrite($TEXTDEBUG, "GUITIMEH: " & $GUITIMEH & @CRLF)
FileWrite($TEXTDEBUG, "GUITIMEM: " & $GUITIMEM & @CRLF)
FileWrite($TEXTDEBUG, "GUITIMES: " & $GUITIMES & @CRLF)
FileWrite($TEXTDEBUG, "$TIMEREADH: " & $TIMEREADH & @CRLF)
FileWrite($TEXTDEBUG, "$TIMEREADM: " & $TIMEREADM & @CRLF)
FileWrite($TEXTDEBUG, "$TIMEREADS: " & $TIMEREADS & @CRLF)
FileWrite($TEXTDEBUG, "TIMEH: " & $TIMEH & @CRLF)
FileWrite($TEXTDEBUG, "TIMEM: " & $TIMEM & @CRLF)
FileWrite($TEXTDEBUG, "TIMES: " & $TIMES & @CRLF)
FileWrite($TEXTDEBUG, "GUISTATE: " & $GUISTATE & @CRLF)
FileWrite($TEXTDEBUG, "AMPM: " & $AMPM & @CRLF)
FileWrite($TEXTDEBUG, "PATHEDIT: " & $PATHEDIT & @CRLF)
FileWrite($TEXTDEBUG, "FILEPATH: " & $FILEPATH & @CRLF)
FileWrite($TEXTDEBUG, "FILEREAD: " & $FILEREAD & @CRLF)
FileWrite($TEXTDEBUG, "DEBUGCHECK: " & $DEBUGCHECK & @CRLF)
FileWrite($TEXTDEBUG, "DEBUGREAD: " & $DEBUGREAD & @CRLF)
FileWrite($TEXTDEBUG, "TOGGLE: " & $TOGGLE & @CRLF)
FileWrite($TEXTDEBUG, @CRLF)



FileClose($TEXTDEBUG)

endfunc
I think you should know whether your script works or not if you are posting in example scripts.

If you can't remember if a function works or not then you should find out. It takes less time to find out if it works than to make the post, so how come you have enough free time to make your post but not enough time to find out if it works?

This change is needed to get the times to compare

;retrieve value of entered time.
    $TIMEREADH = Number(GUICtrlRead($GUITIMEH))
    $TIMEREADM = Number(GUICtrlRead($GUITIMEM))
    $TIMEREADS = Number(GUICtrlRead($GUITIMES))

otherwise you are comparing a string to a number.

There is nothing that I can see to allow for a 12 hour or 24 hour clock; saying you can't remember if that part works is silly.

The script assumes that WMP is already running and if it isn't the script will hang at the line WinWaitActive("Windows Media Player").

I think you should put more effort into getting the script to work using help from the support forums where the sort of errors you have made would be more kindly dealt with.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

I think you should know whether your script works or not if you are posting in example scripts.

If you can't remember if a function works or not then you should find out. It takes less time to find out if it works than to make the post, so how come you have enough free time to make your post but not enough time to find out if it works?

This change is needed to get the times to compare

;retrieve value of entered time.
    $TIMEREADH = Number(GUICtrlRead($GUITIMEH))
    $TIMEREADM = Number(GUICtrlRead($GUITIMEM))
    $TIMEREADS = Number(GUICtrlRead($GUITIMES))

otherwise you are comparing a string to a number.

There is nothing that I can see to allow for a 12 hour or 24 hour clock; saying you can't remember if that part works is silly.

The script assumes that WMP is already running and if it isn't the script will hang at the line WinWaitActive("Windows Media Player").

I think you should put more effort into getting the script to work using help from the support forums where the sort of errors you have made would be more kindly dealt with.

o.O I must have edited it before I posted it. The media player part was probably something I was tinkering around with and didn't finish. As it stands, I know it will call that function at the correct time. Like I said, I don't have the free time to really go through all of it to get it working absolutely correctly. I'm not saying you have to do it, but if someone wants this partially functioning base, it's there.

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