I'm working with Sikuli, which (I think) is build on Jython. I want to make a script that does a small gentle beep to attract the user's attention. (This is on Windows.)
How can I do this? I see that the winsound
module is not available on Jython.
(Note that I want to use the sound card, not the built-in beeper.)
If its Jython, then just use any of the Java classes that play sound. There are tons of them.
from java import net from java.applet.Applet import newAudioClip from java import io url = io.File("fileName").toURL() audio = newAudioClip(url) audio.play()
import sun.audio
import java.io
inputStream = java.io.FileInputStream("test.wav")
audioStream = sun.audio.AudioStream(inputStream)
sun.audio.AudioPlayer.player.start(audioStream)
You may do the fllowing using command line:
Execute "copy con beep.txt" type [ctrl+G] as input and then [ctrl+Z] followed by [Enter] to exit
Then run "type beep.txt" and you will hear a beep.
You may place "type beep.txt" in a batch file or use Ctrl+G directly in batch (which would produce error in command line with sound)
Since we have access to the Java level in Sikuli (thanks to Jython), this should principally work:
import java.awt.Toolkit # only once per script
java.awt.Toolkit.getDefaultToolkit().beep()
Test passed on windows 7. You may get some detailed explanation here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With