Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


How to Play beep sound in VBScript

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,1328
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> How to Play beep sound in VBScript
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1] 2   next >   >>
Login
Message << Older Topic   Newer Topic >>
 How to Play beep sound in VBScript - 9/7/2004 1:12:11 AM   
  swami

 

Posts: 1
Score: 0
Joined: 9/7/2004
From:
Status: offline
Hi,

How to Play beep sound in VBScript?

Thanks
Swami
 
 
Post #: 1
 
 Re: How to Play beep sound in VBScript - 9/7/2004 5:14:22 AM   
  mbouchard


Posts: 1814
Score: 12
Joined: 5/15/2003
From: USA
Status: offline
I do not think that this is possible to do in Vbs. You should be able to do it from the cmd prompt inside a script.

(in reply to swami)
 
 
Post #: 2
 
 Re: How to Play beep sound in VBScript - 12/7/2004 9:26:24 PM   
  MarineBoy

 

Posts: 1
Score: 0
Joined: 12/7/2004
From:
Status: offline
Personally, I'm still looking for a way to create a #beep# any way that I can - in Win2k/XP.

C'mon, we (collectively as programmers you understand ) can hack the Pentagon's computers - but we can't make a pc beep anymore?

Actually, there's got to be an 'exe' that exists which could be invoked.

(... continues searching ...)

(in reply to swami)
 
 
Post #: 3
 
 Re: How to Play beep sound in VBScript - 12/7/2004 11:57:59 PM   
  mbouchard


Posts: 1814
Score: 12
Joined: 5/15/2003
From: USA
Status: offline
I don't know how well this will post, but here is a script that I have that can be used to play a beep.


      

(in reply to swami)
 
 
Post #: 4
 
 Re: How to Play beep sound in VBScript - 12/12/2004 2:35:41 AM   
  bbcradiohead

 

Posts: 1
Score: 0
Joined: 12/12/2004
From: China
Status: offline
This is no useful. I have tried it.

(in reply to swami)
 
 
Post #: 5
 
 Re: How to Play beep sound in VBScript - 12/27/2004 5:46:18 AM   
  brycejohnson

 

Posts: 2
Score: 0
Joined: 12/27/2004
From:
Status: offline
I have a little beep.exe file that would work. I am looking for the same thing. You could obviously run the beep.exe through the VBScript.

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\beep.exe"

(in reply to swami)
 
 
Post #: 6
 
 Re: How to Play beep sound in VBScript - 12/27/2004 5:48:33 AM   
  brycejohnson

 

Posts: 2
Score: 0
Joined: 12/27/2004
From:
Status: offline
quote:
Originally posted by brycejohnson

I have a little beep.exe file that would work. I am looking for the same thing. You could obviously run the beep.exe through the VBScript.

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\beep.exe"




I forgot to mention, e-mail me if you need the beep.exe, i cannot find the link anymore.

brycej99@yahoo.com

(in reply to swami)
 
 
Post #: 7
 
 Re: How to Play beep sound in VBScript - 12/27/2004 6:25:55 AM   
  drbelden

 

Posts: 109
Score: 0
Joined: 12/21/2004
From: USA
Status: offline
The way mbouchard is suggesting seems to have the least overhead.

The beep is chr(007). You can perform this operation with the following code:


      

By using the ', 0' in the third line you prevent the DOS window from appearing as well.

(in reply to swami)
 
 
Post #: 8
 
 Re: How to Play beep sound in VBScript - 12/27/2004 7:21:26 AM   
  drbelden

 

Posts: 109
Score: 0
Joined: 12/21/2004
From: USA
Status: offline
On a similar note, I just seen this on Microsoft's site.
http://www.microsoft.com/technet/scriptcenter/resources/qanda/nov04/hey1103.mspx.
This script allows you to play a wave sound. Not exactly a beep, unless you have a beep.wav sound, but good to know.


      

(in reply to swami)
 
 
Post #: 9
 
 Re: How to Play beep sound in VBScript - 12/27/2004 11:23:37 PM   
  mbouchard


Posts: 1814
Score: 12
Joined: 5/15/2003
From: USA
Status: offline
quote:
Originally posted by drbelden

The beep is chr(007). You can perform this operation with the following code:



Thanks drbelden, didn't know what chr it was, just copied it from an old bat file.

(in reply to swami)
 
 
Post #: 10
 
 Re: How to Play beep sound in VBScript - 3/24/2005 10:34:45 AM   
  pringy

 

Posts: 6
Score: 0
Joined: 3/24/2005
From:
Status: offline
helpp!! i suck at this... i have no education in VB, just copying and attempting to modify codes..

so please be gentle on me...

i can't get this to work (this is my entire script!):


Option Explicit

sub PlaySound()
strSoundFile = "C:\Downloads\jad0057a.wav"
Set objShell = CreateObject("Wscript.Shell")
strCommand = "sndrec32 /play /close " & chr(34) & strSoundFile & chr(34)
objShell.Run strCommand, 0, True
End Sub


Do While True
PlaySound
WScript.Echo( "Sleeping ... " )
WScript.Sleep( 1000 )
Loop



quote:
Originally posted by drbelden

On a similar note, I just seen this on Microsoft's site.
http://www.microsoft.com/technet/scriptcenter/resources/qanda/nov04/hey1103.mspx.
This script allows you to play a wave sound. Not exactly a beep, unless you have a beep.wav sound, but good to know.


      


(in reply to swami)
 
 
Post #: 11
 
 Re: How to Play beep sound in VBScript - 3/24/2005 2:09:23 PM   
  tnoonan

 

Posts: 364
Score: 0
Joined: 12/14/2004
From:
Status: offline
Option Explicit
Dim strSoundFile, objShell, strCommand

sub PlaySound()
strSoundFile = "C:\Downloads\jad0057a.wav"
Set objShell = CreateObject("Wscript.Shell")
strCommand = "sndrec32 /play /close " & chr(34) & strSoundFile & chr(34)
objShell.Run strCommand, 0, True
End Sub


Do While True
PlaySound
WScript.Echo( "Sleeping ... " )
WScript.Sleep( 1000 )
Loop

(in reply to swami)
 
 
Post #: 12
 
 Re: How to Play beep sound in VBScript - 3/24/2005 9:10:42 PM   
  pringy

 

Posts: 6
Score: 0
Joined: 3/24/2005
From:
Status: offline
Genius :)

Thank you very much!

quote:
Originally posted by tnoonan

Option Explicit
Dim strSoundFile, objShell, strCommand

sub PlaySound()
strSoundFile = "C:\Downloads\jad0057a.wav"
Set objShell = CreateObject("Wscript.Shell")
strCommand = "sndrec32 /play /close " & chr(34) & strSoundFile & chr(34)
objShell.Run strCommand, 0, True
End Sub


Do While True
PlaySound
WScript.Echo( "Sleeping ... " )
WScript.Sleep( 1000 )
Loop


(in reply to swami)
 
 
Post #: 13
 
 Re: How to Play beep sound in VBScript - 3/25/2005 5:19:23 AM   
  kirrilian


Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status: offline
if you use Option Explicit you have to declare every single variable youre going to use the script.

(in reply to swami)
 
 
Post #: 14
 
 Re: How to Play beep sound in VBScript - 3/25/2005 5:34:08 AM   
  kirrilian


Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status: offline
a quick google search found these links,

http://www.flashtools.net/tutorials/vbs_files/send_a_beep2.vbs
http://support.microsoft.com/default.aspx?kbid=138857
http://www.blitzbasic.com/toolbox/toolbox.php?tool=25

(in reply to swami)
 
 
Post #: 15
 
 Re: How to Play beep sound in VBScript - 3/25/2005 9:12:07 AM   
  pringy

 

Posts: 6
Score: 0
Joined: 3/24/2005
From:
Status: offline
Thanks kirrilian, very useful!

I'm running my script from a cscript.exe window, and is there a way i can "save" certain outputs into a text file? i.e. once it has performed a particular action, it will record that action into a text file.

(in reply to swami)
 
 
Post #: 16
 
 Re: How to Play beep sound in VBScript - 3/25/2005 9:23:21 AM   
  kirrilian


Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status: offline
there are a couple of ways, look at the file system object on how to read/write/open files or you can just redirect your output from the command line.

eg.
cscript script.vbs > outputfile.txt

(in reply to swami)
 
 
Post #: 17
 
 Re: How to Play beep sound in VBScript - 3/26/2005 4:52:14 PM   
  pringy

 

Posts: 6
Score: 0
Joined: 3/24/2005
From:
Status: offline
mmm... still not quite sure how that works.. alright for example... recording the time the "action" was executed..

chkTime = Now()
ActionA

how would you record that "ActionA" with the Now() time in a txt file?

the script would be running continuously... looping.. until i stop it.. hence, i need the output to be recorded instantly and continuously, in one single log file, as various actions are triggered.

Thanks for your help =)

(in reply to swami)
 
 
Post #: 18
 
 Re: How to Play beep sound in VBScript - 3/28/2005 6:10:56 AM   
  didorno

 

Posts: 361
Score: 0
Joined: 2/12/2005
From:
Status: offline
About the Beep.
If you implement Dynawrap.dll, then you can have beeps with
frequency and duration as you wish.

' beep demo, jw 19Jan01

' instantiate DynaWrap...
Set oDW = CreateObject("DynamicWrapper")
' declare the api call...
oDW.Register "KERNEL32.DLL", "Beep", "i=ll", "f=s", "r=l"
' call the api (parameters are: frequency, duration)
f = 50
Do
f = f + 50
oDW.Beep f, 100
Loop Until f > 5000

Set oDW = nothing ' clean up
WScript.Echo "Ready"
WScript.Quit

This example is from Jim Warrington's site.
Dynawrap can be downloaded from BornCity (dynawrapnt.zip).

< Message edited by didorno -- 7/20/2005 7:56:38 AM >

(in reply to swami)
 
 
Post #: 19
 
 Re: How to Play beep sound in VBScript - 3/28/2005 6:32:37 AM   
  kirrilian


Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status: offline
then you would need to use filesystemobject to open/read/write to files

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/sgworkingwithfiles.asp

quote:
Originally posted by pringy

mmm... still not quite sure how that works.. alright for example... recording the time the "action" was executed..

chkTime = Now()
ActionA

how would you record that "ActionA" with the Now() time in a txt file?

the script would be running continuously... looping.. until i stop it.. hence, i need the output to be recorded instantly and continuously, in one single log file, as various actions are triggered.

Thanks for your help =)



(in reply to swami)
 
 
Post #: 20
 
 
Page:   [1] 2   next >   >>
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> How to Play beep sound in VBScript Page: [1] 2   next >   >>
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts