autoit180 Posted March 6, 2009 Share Posted March 6, 2009 Hi, Please help me to improve a script the purpose: playing sound every 16th minute of an hour what I wrote is that: $r=1 While $r=1 if @MIN = 16 Then SoundPlay("c:\1.wav") EndIf WEnd is there any better script? Link to comment Share on other sites More sharing options...
will88 Posted March 6, 2009 Share Posted March 6, 2009 whats the point in $r=1 While $r=1 when the value of $r never changes? While 1 If @MIN = 16 Then SoundPlay("C:\1.wav") EndIf WEnd Password-Keeper Link to comment Share on other sites More sharing options...
BinaryBrother Posted March 6, 2009 Share Posted March 6, 2009 (edited) Keep in mind with a loop like that, the script is going to consume massive CPU, as well as play the sound, (weather audible or not) MANY times in that 16th minute... I suggest something like... While 1 If @MIN = 16 Then SoundPlay("C:\test.wav",1) Sleep(60000) EndIf sleep(1000) WEnd That way the second it hits the 16th minute, you clearly hear the sound... and you don't hear it again until the next 16th minute... It doesn't consume CPU, and slower machines won't sound like a skipping record for 60 seconds... Edited March 6, 2009 by BinaryBrother SIGNATURE_0X800007D NOT FOUND Link to comment Share on other sites More sharing options...
BrettF Posted March 6, 2009 Share Posted March 6, 2009 My grossly over complicated addition... Global $minute = 16 Global $hour = -1;Any hour Global $played = 0 AdlibEnable("_Chimer", 1000) While 1 Sleep(100) WEnd Func _Chimer() Local $lhour, $lminute = @MIN If $hour = -1 Then $lhour = @HOUR If $lminute = $minute Then If Not $played Then SoundPlay(@WindowsDir & "\MEDIA\notify.WAV") $played = 1 ;I did this to test for more than one case... ;$minute += 1 EndIf Else $played = 0 EndIf EndFunc ;==>_Chimer Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
BinaryBrother Posted March 7, 2009 Share Posted March 7, 2009 Never thought someone could turn basic math into quantum physics... You probably just caused 'AutoIt180' to give up AutoIt forever... SIGNATURE_0X800007D NOT FOUND Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now