私は、(私が思うに) Jython 上に構築された Sikuli を使用しています。ユーザーの注意を引くために、小さな穏やかなビープ音を鳴らすスクリプトを作成したいと考えています。(これは Windows の場合です。)
これどうやってするの?このwinsound
モジュールは Jython では使用できないようです。
(組み込みのブザーではなく、サウンド カードを使用することに注意してください。)
Jython の場合は、サウンドを再生する Java クラスのいずれかを使用してください。それらのトンがあります。
Javaインポートネットから from java.applet.Applet import newAudioClip Javaインポートioから url = io.File("ファイル名").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)
SikuliのJavaレベルにアクセスできるので(Jythonのおかげで)、これは主に機能するはずです。
import java.awt.Toolkit # only once per script
java.awt.Toolkit.getDefaultToolkit().beep()
Windows 7でテストに合格しました。ここで、詳細な説明が得られる場合があります。
If you run Sikuli scripts from the command line, rather than through the IDE, then you can simply write the BEL
character to the console and it will beep. This also works through RDP.
Edit: on Windows 7, this will now beep through the sound card, as you asked for. On Windows XP it will beep to the internal speaker (if present).
E.g. the following beeps twice:
print("\007\007")
Sikuli を使用しているので、次のことができます。
Windows マシンのデスクトップに .mp3 などのメディアファイルを追加し、そのファイルをメディア プレーヤーに関連付けます。画像をキャプチャし、以下を含めます。
click(pattern(desktopnoiseicon.png)
別の方法として、openApp(C:\noise.mp3) で同じタスクを実行することもできます。
Sikuli を使用すると、多数の回避策を見つけることができます
SikuluXrc2 では、バンドル パスを設定する必要なく、コードから URL を指すことさえできます