Jump to content

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

Share this post


Link to post
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 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-10-09 - Version 0.9.0.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

works for me:

; prepare environment

$alarmclockmark = 1
$hourcount = @HOUR
$minutecount = @MIN

; run your code

If $alarmclockmark = 1 And @HOUR = $hourcount And @MIN = $minutecount Then

    MsgBox(0, "Works", "Works")
EndIf

 


UDF: _SingleScript()                                        If you like my post, just click the like button :)        here -->

Share this post


Link to post
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

Share this post


Link to post
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 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-10-09 - Version 0.9.0.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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.

Share this post


Link to post
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

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

×
×
  • Create New...