Sign in to follow this  
Followers 0
mrgreggklein

sound play when left mouse click

5 posts in this topic

i searched but could not find help on;

i would like for the computer to play a sound file every time I left click or every time I hold left mouse button down. and drag

can anyone be any help.

thanks!

Share this post


Link to post
Share on other sites



Try this:

#include <Misc.au3>
#include <Sound.au3>

HotKeySet("{ESC}","Quit") ; Press ESC to quit

While True
    If _IsPressed('01') Then
        $Sound = _SoundOpen(@WindowsDir & "Mediading.wav")
        Do
            _SoundPlay($Sound,True)
            Sleep(10)
        Until Not _IsPressed('01')
        _SoundClose($Sound)
    EndIf
    Sleep(10)
WEnd

Func Quit()
    Exit
EndFunc

When the words fail... music speaks

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

andreik,

When I run this I get return = 0 and @error = 1 for _soundopen...Google search for MCI error deals with 3rd party install problems. Have not installed anything directly related to sound.

NE ideas?

kylomas

Edit: also tried changing sound scheme to heritage without effect.

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

@error1= MCI open error, I don't know what would be the reason, I didn't install something special to run the example above. Anyway you can try this example using native AutoIt function:

#include <Misc.au3>

HotKeySet("{ESC}","Quit") ; Press ESC to quit

While True
    If _IsPressed('01') Then
        Do
            SoundPlay(@WindowsDir & "Mediading.wav",True)
            Sleep(10)
        Until Not _IsPressed('01')
    EndIf
    Sleep(10)
WEnd

Func Quit()
    Exit
EndFunc

When the words fail... music speaks

Share this post


Link to post
Share on other sites

@error1= MCI open error, I don't know what would be the reason, I didn't install something special to run the example above. Anyway you can try this example using native AutoIt function:

#include <Misc.au3>

HotKeySet("{ESC}","Quit") ; Press ESC to quit

While True
    If _IsPressed('01') Then
        Do
            SoundPlay(@WindowsDir & "Mediading.wav",True)
            Sleep(10)
        Until Not _IsPressed('01')
    EndIf
    Sleep(10)
WEnd

Func Quit()
    Exit
EndFunc

IT works perfect thanks

Share this post


Link to post
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
Sign in to follow this  
Followers 0