Jump to content

How to use the computer beep to initiate/ stop script


Recommended Posts

Hey there

I'm trying to harness the beep function of the PC to my script conditional activation. I mean that when a certain process in the computer stops (lets say when a USB device is formatted), a beep is played and only then I want to activate my script.

Any ideas how to do it?

Thanks!

Link to comment
Share on other sites

you joined party kind of late... pc's don't use beeping for that purpose for the last 20 years or so. it's WAV files now.

start here:

'?do=embed' frameborder='0' data-embedContent>>

alternatively, you can formulate a way to detect the condition that initiated the sound, instead of the sound itself. that's where i'd go.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

I generated the following code:

************************************************************

#include <Sound.au3>

Local $File_path = "C:WINDOWSMediaWindows XP Exclamation.wav"

Local $aSound = _SoundOpen($File_path)

While StringCompare(_SoundStatus($aSound), "playing") <>0

       Sleep(200)

       _SoundPlay($File_path)

       Consolewrite("Sound: " & _SoundStatus($aSound) & @CRLF)

WEnd

MsgBox(0,"","Playing")

_SoundClose($aSound)

 

************************************************************

But I cannot get out of the loop. Can you tell me what is wrong here?

*Its not my final code. It's just something to test the ability to detect when the computer is using wav files.

Edited by shahino007
Link to comment
Share on other sites

  • 1 month later...

by the help file, _SoundPlay() requires the ID from _SoundOpen() as a parameter, not the file name.

also put some error checking in your script (see the _SoundOpen() example in the help file) - it will help you troubleshoot.

and of course, when you post code to the forum, use the code tags (the "A" button in the toolbar, tooltip "Code").

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

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

×
×
  • Create New...