Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Assign sounds to mouse clicks


  • Please log in to reply
20 replies to this topic
Dike
  • Members
  • 19 posts
  • Last active: Aug 29 2015 02:09 PM
  • Joined: 18 Dec 2014

I want to assign .wav sounds to mouse clicks -

 

Left mouse down - E:\sounds\ldown.wav

 

Similarly -

left mouse up - lup.wav

right down - rdown.wav

right up - rup.wav

middle mouse click - mclick.wav

middle mouse scroll up - mup.wav

middle mouse scroll down - mdown.wav

 

Was looking to download the software - Keyboard sounder v1.6, but am unable to find the downloadable setup file for the software.

 

How to do so? Thanks.



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

~LButton down::SoundPlay, E:\sounds\ldown.wav

 

Check out the Key List to find the names of the keys. I believe they are LButton, RButton, MButton, WheelUp, WheelDown.

 

The SoundPlay command can play a sound file for you. WAV should be the perfect format for this.

 

The ~ modifier in front of the button tells AHK to let the active window receive the keypress (or mouse button in this case) while still doing the AHK script. And the "down" modifier tells AHK to do this when the key is down. The counterpart to that is "up".



Dike
  • Members
  • 19 posts
  • Last active: Aug 29 2015 02:09 PM
  • Joined: 18 Dec 2014

I am getting the error -

 

Error at line 193.
Line Text: ~LButton down::SoundPlay, E:\SOUNDS FOR AHK\sound5.wav
Error: Invalid hotkey.
The script was not reloaded; the old version will remain in effect.



Jackie Sztuk _Blackholyman
  • Spam Officer
  • 3757 posts
  • Last active: Apr 03 2016 08:47 PM
  • Joined: 28 Feb 2012
~LButton::
SoundPlay, E:\sounds\ldown.wav
return
~LButton up::
SoundPlay, E:\sounds\lup.wav
return

Helping%20you%20learn%20autohotkey.jpg?d

[AHK] Version. 1.1+ [CLOUD] DropBox ; Copy [WEBSITE] Blog ; About

Dike
  • Members
  • 19 posts
  • Last active: Aug 29 2015 02:09 PM
  • Joined: 18 Dec 2014

Thanks exaskryz and blackholyman. Blackholyman, your script is working for all buttons.

 

But I am looking for some more now. I want that instead of just 1 selected .wav file, ~LButton plays randomly 1 out of 5 selected .wav files. Like ldown1.wav ... ldown5.wav. That way I will have random sounds for each click. Can it be made ? Thanks again.
 



Jackie Sztuk _Blackholyman
  • Spam Officer
  • 3757 posts
  • Last active: Apr 03 2016 08:47 PM
  • Joined: 28 Feb 2012

~LButton::
Random, random, 1, 5
SoundPlay, E:\sounds\ldown%random%.wav
return

Helping%20you%20learn%20autohotkey.jpg?d

[AHK] Version. 1.1+ [CLOUD] DropBox ; Copy [WEBSITE] Blog ; About

Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

My apologies, I was wrong about down being a modifier there. Thank you Black for making the correction.



Dike
  • Members
  • 19 posts
  • Last active: Aug 29 2015 02:09 PM
  • Joined: 18 Dec 2014

1. Blackholyman, will your script play all the sounds from 1 to 5, or only number 1 and number 5 ? I think all, but just wanted to confirm from you.

 

 

 

2.

Also, can anyone tell me what's wrong with this code -

 

~WheelDown::
SoundPlay, M:\HURHUR - FR GDRV\ITEMS FR OLD SAMSUNG PC\AHKSCRIPTS06 - YJan09\004\016 - FINALSCRIPTS - YDEC04\SOUNDS FOR AHK\01\T-CLOCK 2010\Waves\Buzzer.wav
Return

 

Where - the small path code is working (SoundPlay, E:\SOUNDS FOR AHK\Alarm.wav) but the above long path .wav file is not playing in the same script code.



Jackie Sztuk _Blackholyman
  • Spam Officer
  • 3757 posts
  • Last active: Apr 03 2016 08:47 PM
  • Joined: 28 Feb 2012

yes it will play them all but in no order, but as randomly as it gets in autohotkey at least

 

And as I don't have a file path like yours I can't say this works, but try something like this

~WheelDown::
filepath := "M:\HURHUR - FR GDRV\ITEMS FR OLD SAMSUNG PC\AHKSCRIPTS06 - YJan09\004\016 - FINALSCRIPTS - YDEC04\SOUNDS FOR AHK\01\T-CLOCK 2010\Waves\Buzzer.wav"
SoundPlay, %filepath%
return

Helping%20you%20learn%20autohotkey.jpg?d

[AHK] Version. 1.1+ [CLOUD] DropBox ; Copy [WEBSITE] Blog ; About

Dike
  • Members
  • 19 posts
  • Last active: Aug 29 2015 02:09 PM
  • Joined: 18 Dec 2014

I tried filepath code but it still just plays if the path is smaller than 128 characters as -

~WheelDown::
filepath := "E:\SOUNDS FOR AHK\Waves_2\sound1.wav"
SoundPlay, %filepath%
return
 

BUT doesn't play if path is this long -

 

~WheelDown::
filepath := "M:\HURHUR - FR GDRV\ITEMS FR OLD SAMSUNG PC\AHKSCRIPTS06 - YJan09\004\016 - FINALSCRIPTS - YDEC04\SOUNDS FOR AHK\01\T-CLOCK 2010\Waves\sound1.wav"
SoundPlay, %filepath%
return

 

 

While when working with autohotkey, this should not be any faulty code, as the path is way too short at even about 160 characters only (so less than 256 chars which is considered longpath).

 

 

And then I found that when the path is more than 128 chars long, viz 129 characters the sound doesn't play. And the same wav file plays when the path is smaller than 128 chars, for eg. 125 characters.

 

Can anyone guide ?



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

I wonder if you need a 64 bit AHK for this? (If one is out there).

 

Can you make a shortcut to these files, and then have SoundPlay target the shortcuts?



Dike
  • Members
  • 19 posts
  • Last active: Aug 29 2015 02:09 PM
  • Joined: 18 Dec 2014

Can you tell how to play a shortcut file with soundplay. And what's the extension for a shortcut - .LNK or .INK ?



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

I believe I'm on 64 bit AHK, and I do have the same problem as using a file path beyond 128 characters in SoundPlay.

 

I believe it's a .LNK file, as no other shortcut I've seen is capitalized like .Exe or .Jpg. Should be a matter of setting that .lnk file in SoundPlay. And unfortunately, I can't get link files to work in SoundPlay either. I keep getting an ErrorLevel of 1 and of course no sound. I am testing with a .wav as well, which does play if I stick it on the desktop and target that.



Dike
  • Members
  • 19 posts
  • Last active: Aug 29 2015 02:09 PM
  • Joined: 18 Dec 2014

I tried playing a .wav file, using shortcut (.LNK TO A .WAV FILE) as -

 

~WheelDown::
filepath := "E:\SOUNDS FOR AHK\Waves_2\Clock.LNK"
SoundPlay, %filepath%
return

 

 

but it didn't work either.

 

The path of shortcut is -

M:\HURHUR - FR GDRV\ITEMS FR OLD SAMSUNG PC\AHKSCRIPTS06 - YJan09\004\016 - FINALSCRIPTS - YDEC04\SOUNDS FOR AHK\01\T-CLOCK 2010\Waves\Clock.wav

 

 

Can anyone tell why my problem with path longer than 128 characters, to play with SoundPlay is not playing the sound ?



bobycom
  • Members
  • 40 posts
  • Last active: Apr 14 2019 07:50 AM
  • Joined: 25 Mar 2014

I just tested your script with a file path 175 characters long and it plays fine. I'm with the latest version of AHK on Windows XP 32bit if it matters.

 

Are you sure that you have drive M on your PC? Is it a removable or a network drive?