Jump to content

Alarm time with BEEP


sak
 Share

Recommended Posts

Set the alarm time with BEEP of the computer.

If your computer does not anyone do not hear the BEEP sound be modified to do something else.

You can set the time from 1 minute to 1 hour :)

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

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

Global $hForm, $Lbl_hour, $Lbl_min, $Lbl_sec, $Combo_settime, $Btn_start
Global $exititem, $timecount, $stringtime, $i, $j, $x

$hForm = GUICreate("Timer Beep Alarm Counter [Min]", 204, 131, -1, -1, _
BitOR($WS_MINIMIZEBOX,$WS_CAPTION,$WS_POPUP,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS), _
BitOR($WS_EX_OVERLAPPEDWINDOW,$WS_EX_WINDOWEDGE))
GUISetBkColor(0xC0DCC0)
GUICtrlCreateGraphic(8, 8, 188, 85, BitOR($SS_CENTER,$SS_NOTIFY,$SS_SUNKEN))
GUICtrlSetBkColor(-1, 0x575C64)
GUICtrlCreateLabel("H", 38, 16, 15, 20, BitOR($SS_CENTER,$SS_SUNKEN))
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlCreateLabel("M", 92, 16, 16, 20, $SS_SUNKEN)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlCreateLabel("S", 147, 16, 14, 20, BitOR($SS_CENTER,$SS_SUNKEN))
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lbl_hour = GUICtrlCreateLabel("00", 24, 45, 42, 41, $SS_CENTER)
GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lbl_min = GUICtrlCreateLabel("00", 78, 45, 42, 41, $SS_CENTER)
GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lbl_sec = GUICtrlCreateLabel("00", 135, 45, 42, 41, $SS_CENTER)
GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlCreateLabel(":", 64, 42, 14, 41, $SS_CENTER)
GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlCreateLabel(":", 122, 42, 14, 41, $SS_CENTER)
GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Combo_settime = GUICtrlCreateCombo("0", 144, 104, 49, 25, _
BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL), _
BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|20|30|40|50|60")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Btn_start = GUICtrlCreateButton("Start", 8, 104, 131, 23, _
BitOR($BS_CENTER,$WS_GROUP), $WS_EX_STATICEDGE)
GUICtrlSetOnEvent(-1, 'btn_start')
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetCursor(-1, 0)
GUISetState(@SW_SHOW)

TrayCreateItem("")
$exititem = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1,"ExitScript")
TraySetToolTip("Right-click to close.")
TrayTip("", "Right-click to close.", 3)
Sleep(5000)
TrayTip("", "", 3)
TraySetState()

While 1
Sleep(100)
WEnd

Func btn_start()
    $timecount = GUICtrlRead($Combo_settime)
    If GUICtrlRead($Combo_settime) = 0 Then
        MsgBox(0, "", "Please set the time.", 5, $hForm)
    Else
        $stringtime = StringReplace($timecount, "/", @CRLF)
        For $i = 0 To 60
        If $j >= $stringtime Then ExitLoop
        For $j = 0 To 60
        If $j >= $stringtime Then ExitLoop
        For $x = 0 To 59
            GUICtrlSetData($Lbl_hour, $i)
            GUICtrlSetData($Lbl_min, $j)
            GUICtrlSetData($Lbl_sec, $x)
            Sleep(1000)
        Next
        Next
        Next
        GUICtrlSetData($Lbl_min, $stringtime)
        GUICtrlSetData($Lbl_sec, 0)
        Beep(800, 200)
        Beep(800, 200)
        Beep(800, 100)  ;<-write script control here.-<<<
        Sleep(500)
        Beep(800,  100)
    EndIf
EndFunc

Func ExitScript()
    GUIDelete($hForm)
    Exit
EndFunc
Edited by sak
Link to comment
Share on other sites

This is an example of programmable timer Connect and DisConnect.Network Connections. :)

Anyone to view help me analyze this statement.

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

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

Global $hForm, $Lbl_hour, $Lbl_min, $Lbl_sec, $Combo_settime, $Btn_start
Global $exititem, $timecount, $stringtime, $trigtime, $i, $j, $x, $pid, $google = 'www.Google.co.th'

$hForm = GUICreate("Timer Beep Alarm Counter [Min]", 204, 131, -1, -1, _
BitOR($WS_MINIMIZEBOX,$WS_CAPTION,$WS_POPUP,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS), _
BitOR($WS_EX_OVERLAPPEDWINDOW,$WS_EX_WINDOWEDGE))
GUISetBkColor(0xC0DCC0)
GUICtrlCreateGraphic(8, 8, 188, 85, BitOR($SS_CENTER,$SS_NOTIFY,$SS_SUNKEN))
GUICtrlSetBkColor(-1, 0x575C64)
GUICtrlCreateLabel("H", 38, 16, 15, 20, BitOR($SS_CENTER,$SS_SUNKEN))
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlCreateLabel("M", 92, 16, 16, 20, $SS_SUNKEN)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlCreateLabel("S", 147, 16, 14, 20, BitOR($SS_CENTER,$SS_SUNKEN))
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lbl_hour = GUICtrlCreateLabel("00", 24, 45, 42, 41, $SS_CENTER)
GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lbl_min = GUICtrlCreateLabel("00", 78, 45, 42, 41, $SS_CENTER)
GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lbl_sec = GUICtrlCreateLabel("00", 135, 45, 42, 41, $SS_CENTER)
GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlCreateLabel(":", 64, 42, 14, 41, $SS_CENTER)
GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$trigtime = GUICtrlCreateLabel(":", 122, 42, 14, 41, $SS_CENTER)
GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Combo_settime = GUICtrlCreateCombo("0", 144, 104, 49, 25, _
BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL), _
BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|20|30|40|50|60")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Btn_start = GUICtrlCreateButton("Start", 8, 104, 131, 23, _
BitOR($BS_CENTER,$WS_GROUP), $WS_EX_STATICEDGE)
GUICtrlSetOnEvent(-1, 'btn_start')
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetCursor(-1, 0)
GUISetState(@SW_SHOW)

TrayTip("", "Right-click to close.", 5)
Sleep(3000)
TrayTip("endtraytip", "", 5)
TrayCreateItem("")
$exititem = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1,"ExitScript")
TraySetToolTip("Right-click to close.")
TraySetState()

While 1
Sleep(100)
WEnd

Func btn_start()
    $timecount = GUICtrlRead($Combo_settime)
    If GUICtrlRead($Combo_settime) = 0 Then
        MsgBox(0, "", "Please set the time.", 5, $hForm)
    Else
        $stringtime = StringReplace($timecount, "/", @CRLF)
        For $i = 0 To 60
        If $j >= $stringtime Then ExitLoop
        For $j = 0 To 60
        If $j >= $stringtime Then ExitLoop
        For $x = 0 To 59
            GUICtrlSetData($Lbl_hour, $i)
            GUICtrlSetData($Lbl_min, $j)
            GUICtrlSetData($Lbl_sec, $x)
            Sleep(1000)
        Next
        Next
        Next
        GUICtrlSetData($Lbl_min, $stringtime)
        GUICtrlSetData($Lbl_sec, 0)
        GUICtrlSetState($trigtime, $GUI_HIDE)
        Sleep(250)
        GUICtrlSetState($trigtime, $GUI_SHOW)
        Sleep(250)
        GUICtrlSetState($trigtime, $GUI_HIDE)
        Sleep(250)
        GUICtrlSetState($trigtime, $GUI_SHOW)
        Sleep(250)
        Beep(800, 200)
        Beep(800, 200)
        Beep(800, 100)  ;<-write script control here.-<<<
        Sleep(500)
        Beep(800,  100)
        connections()
    EndIf
EndFunc

Func connections()
If @IPAddress1 = '127.0.0.1' Then
    TrayTip("", "Connecting..", 5)
    $pid = Run(@ComSpec & " /C " & 'rasphone.exe', "", @SW_HIDE)
    WinWaitActive("Network Connections", "Choose a network connection:", 1)
    Send("{ENTER}")
    If ProcessWaitClose($pid) Then
        WinClose("Network Connections")
                ShellExecute($google)
        TrayTip("", "Online.", 5)
        Sleep(5000)
        TrayTip("endtraytip", "", 5)
    EndIf
Else
    $pid = Run(@ComSpec & " /C " & 'rasdial /disconnect', "", @SW_HIDE)
    If ProcessWaitClose($pid) Then
        WinClose("Network Connections")
        TrayTip("", "DisConnect.", 5)
        Sleep(3000)
        TrayTip("", "Offline.", 5)
        Sleep(5000)
        TrayTip("endtraytip", "", 5)
    EndIf
EndIf
EndFunc

Func ExitScript()
    GUIDelete($hForm)
    Exit
EndFunc
Edited by sak
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...