Jump to content
Sign in to follow this  
CounterCraft

First basic script help

Recommended Posts

CounterCraft

Hi everyone! programmer wannabe here...

I made this script with basic knowledge to keep me alert.

I think it's fine as it is but I want opinion from experienced scripters

while 1 = 1

$min = @MIN

$sec = @SEC

if $min = 0 then

if $sec = 0 Then

Beep (1500, 1000)

Sleep (1000)

Beep (1500, 1000)

Sleep (1000)

Beep (1500, 1000)

Sleep (1000)

Beep (1500, 1000)

Sleep (1000)

Beep (1500, 1000)

msgbox (0, "Time to turn outdoor sign?", "Is it time to turn on the outdoor sign?")

Beep (1500, 1000)

Sleep (1000)

Beep (1500, 1000)

Sleep (1000)

Beep (1500, 1000)

Sleep (1000)

Beep (1500, 1000)

Sleep (1000)

Beep (1500, 1000)

EndIf

EndIf

WEnd

Is it necessary for me to put $min = @MIN and $sec = @SEC after while 1 = 1?

Share this post


Link to post
Share on other sites
Andreik

Hi everyone! programmer wannabe here...

I made this script with basic knowledge to keep me alert.

I think it's fine as it is but I want opinion from experienced scripters

Is it necessary for me to put $min = @MIN and $sec = @SEC after while 1 = 1?

Tell us what you want to do.

PS: Is more simple to use directly

if @MIN = 0 then

and

if @SEC = 0 then

When the words fail... music speaks

Share this post


Link to post
Share on other sites
CounterCraft

Tell us what you want to do.

PS: Is more simple to use directly

if @MIN = 0 then

and

if @SEC = 0 then
It makes beep sound and popup notice every hour so I don't forget to light up the outdoor sign

Share this post


Link to post
Share on other sites
Andreik

It makes beep sound and popup notice every hour so I don't forget to light up the outdoor sign

I understand, but a loop without sleep is not a good idea and in this case is possible that you can not catch the exact second 0. If you use only @MIN you know when is a new hour.

This should be a code for what you want to do:

While 1
    If @MIN = "00" Then
        MySound()
        MsgBox(0, "Time to turn outdoor sign?", "Is it time to turn on the outdoor sign?")
        MySound()
    EndIf
    Sleep(25)
WEnd

Func MySound()
Beep (1500, 1000)
Sleep (1000)
Beep (1500, 1000)
Sleep (1000)
Beep (1500, 1000)
Sleep (1000)
Beep (1500, 1000)
Sleep (1000)
Beep (1500, 1000)
EndFunc

When the words fail... music speaks

Share this post


Link to post
Share on other sites
Glyph

While 1
    If @MIN = "00" Then
        MySound(5)
        MsgBox(0, "Time to turn outdoor sign?", "Is it time to turn on the outdoor sign?")
        MySound(5)
    EndIf
    Sleep(25)
WEnd

Func MySound($times)
$i=0
do
$i+=1
Beep (1500, 1000)
sleep(1000)
until  $i = $times
EndFunc

Edited by Glyph

tolle indicium

Share this post


Link to post
Share on other sites
CounterCraft

While 1

If @MIN = "00" Then

MySound(5)

$canExit = InputBox ("Is it time to turn outdoor sign?", "Type YES to terminate the program, else press ok")

if $canExit = "YES" then

Exit

EndIf

Sleep(60000)

EndIf

WEnd

Func MySound($times)

while $times > 0

$times = $times - 1

Beep (1500, 1000)

sleep (1000)

WEnd

EndFunc

Little more organized, but how do script distinguish between OK and Cancel button?

Edited by CounterCraft

Share this post


Link to post
Share on other sites
oMBRa

#include <Date.au3>

Global $sNewDate = _DateAdd('h', 1, _NowCalc())

While 1
    If _NowCalc() = $sNewDate Then
        MySound(1)
        $ID = MsgBox(4, "Time to turn outdoor sign?", "Is it time to turn on the outdoor sign?")
        If $ID = 6 Then
            Exit
        EndIf
    EndIf
    Sleep(10)
WEnd

Func MySound($times)
    Local $i = 0
    Do
        $i += 1
        Beep(1500, 1000)
        Sleep(1000)
    Until $i = $times
    $sNewDate = _DateAdd('h', 1, _NowCalc())
EndFunc ;==>MySound

Edited by oMBra

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.