Jump to content

Alarm clock


Recommended Posts

Hi guys, im building a program and i want to have as part of that program some "alarm clock".
So what i want to do is selecting values A (as hours - $hourcount) and B  (as minutes - $minutecount) and then activate those clock by confirming activation mark.

So if time values will be same as values in windows time, and alarm clock mark will be ON, then msg "works" appears (then it will be replaced with sound ofc)

So i wanted something like this:

If $alarmclockmark = 1 and @HOUR = $hourcount and @MIN = $minutecount Then
MsgBox(0, "Works", "Works")
EndIf

But it not works...any ideas?

Ps.: Try it explain very simple...im stupid. :D

Edited by Lukepro2315
Link to comment
Share on other sites

I just searched the forum and got a lot of hits for "alarm clock". So I'm sure you'll find what you need when searching for it :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

No, it dont work.
 Ill attach my script here, and i need this - when u click on "Alarm off", it should change to "alarm on" and it should show time that is set...and after reaching set time, it should show msgbox with "work".

But instead it shows only numbers 6 and 8 and nothing else happens.

Any ideas?

Preview.au3

Link to comment
Share on other sites

Your usage of AdlibRegister in functionTimeshowfrequency is wrong. AdlibRegister should only be called once in a script. Check the help file for AdlibRegister.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Hello,

try this

Global $Alarm
Global $Alarmset
Global $Alarmhour
Global $Alarmset
Global $Quit
Global $time
Global $GUI_CHECKED



Local $sFont = "Consolas"

GUICreate("Alarm clock", 800, 600)
GUISetState(@SW_SHOW)

;-------------------Exit-------------------

$Quit = GUICtrlCreateButton("Exit", 740, 0, 60, 20)

;-------------------Time--------------------

GUICtrlCreateLabel("Actual time:", 500, 5, 80, 15)
GUISetFont(9, 400, 0, $sFont)
GUISetFont(15)
$time = GUICtrlCreateLabel("", 600, 0, 100, 30)

Timeshowfrequency()

Func Timeshowfrequency()
    AdlibRegister("_SetTime", 1000)
EndFunc   ;==>Timeshowfrequency

;-------------------Alarm--------------------

GUISetFont(8.5, 400, 0)
$Alarmhour = GUICtrlCreateInput("0", 120, 30, 40, 20)
GUICtrlCreateUpdown(-1)
GUICtrlSetLimit(-1, 23)
GUICtrlSetState(1, $GUI_CHECKED)
$Alarmminutes = GUICtrlCreateInput("0", 200, 30, 40, 20)
GUICtrlCreateUpdown(-1)
GUICtrlSetLimit(-1, 60)
$Alarm = GUICtrlCreateCheckbox("Alarm off", 10, 30, 110, 20)
GUICtrlSetState(1, $GUI_CHECKED)
GUICtrlSetBkColor($Alarm, 0xCCCCCC)
GUICtrlCreateLabel("hours", 170, 34, 30, 20)
GUICtrlCreateLabel("minutes", 250, 34, 40, 20)

While 1

    Switch GUIGetMsg()
        Case $Alarm
            If $Alarmset = 0 Then
                $Alarmset = 1
                GUICtrlSetBkColor($Alarm, 0x00FF00)
                GUICtrlSetData($Alarm, "Alarm set on " & int(GUICtrlRead($Alarmhour)) & ":" & int(GUICtrlRead($Alarmminutes)) & "")
            Else
                $Alarmset = 0
                GUICtrlSetBkColor($Alarm, 0xCCCCCC)
                GUICtrlSetData($Alarm, "Alarm off")
            EndIf

        Case $Quit
            Exit
    EndSwitch

    If $Alarmset = 1 And @HOUR = int(GUICtrlRead($Alarmhour)) And @MIN = int(GUICtrlRead($Alarmminutes)) Then
        MsgBox(0, "Works", "Works")
    EndIf

WEnd


Func _SetTime()
    GUICtrlSetData($time, "" & @HOUR & ":" & @MIN & ":" & @SEC & "")
EndFunc

Use GuiCtrlRead to get the value from InputControl and the if-statement for alarm control must defined outside form switch statement.

greetings
bernd


I hacked 127.0.0.1 -> pcfred6.gif

Link to comment
Share on other sites

Your usage of AdlibRegister in functionTimeshowfrequency is wrong. AdlibRegister should only be called once in a script. Check the help file for AdlibRegister.

​This is only part of script i used there While 1 so i needed to put that time on Adlib register...but there is not problem - clock works fine, problem is in that alarm. :D

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