Jump to content

Recommended Posts

Posted
#include <AutoItConstants.au3>

Global $hour, $min, $sec, $msec

While 1 ;endless loop so script will continually check computer clock/time
    Sleep(100)
    WEnd

$hour = @HOUR
$min = @MIN

If @HOUR = 07 And @MIN = 22 Then ;time to fire beep
    Beep (500, 3000)
EndIf

HotKeySet("{ESC}", "On_Exit") ;quick way out if something goes wrong
Func On_Exit()
    Exit
EndFunc

When computer clock hits set time I am not hearing a beep. Also, in the AutoIt icon in the task tray I am seeing that the script is paused. Would anyone have some suggestions as to what I am doing incorrectly?

Thank you in advance for any help,
yeto

Posted (edited)

It’s probably because you’re stuck in the while loop sleeping. This is getting really annoying. You need to add debugging code to your programs 

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Posted

Hi,

try (currently untested):

HotKeySet("{ESC}", "On_Exit") ;quick way out if something goes wrong

While 1 ;endless loop so script will continually check computer clock/time
    Sleep(100)

    If @HOUR = 07 And @MIN = 22 Then ;time to fire beep
        Beep (500, 3000)
    EndIf

Wend

Func On_Exit()
    Exit
EndFunc

Hotkeyset at the beginning. Wenn at the end of the Loop including the if clause.

Regards, Simpel

 

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Posted
54 minutes ago, Simpel said:

Hi,

try (currently untested):

HotKeySet("{ESC}", "On_Exit") ;quick way out if something goes wrong

While 1 ;endless loop so script will continually check computer clock/time
    Sleep(100)

    If @HOUR = 07 And @MIN = 22 Then ;time to fire beep
        Beep (500, 3000)
    EndIf

Wend

Func On_Exit()
    Exit
EndFunc

Hotkeyset at the beginning. Wenn at the end of the Loop including the if clause.

Regards, Simpel

 

Yes, thank you, that worked. If you have time for teaching why did having HotKey at end prevent script from working? Also, am I correct in my line of thinking that I need the continually loop so that the script will keep checking the computer clock so as to know when to beep?

Thank you for taking time to help,
yeto

 

Posted
55 minutes ago, FrancescoDiMuro said:

The code is executed line by line, so, if you put something that will cause the program to idle, you can't use something that is declared or executed further :)

Thank you. That is helpful. 

I saw a post that said ScriptWriter is good to use. I am currently using SciTE. Would you reccomend that a newbie use ScriptWriter (which I couldn't find in the download)?

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