| View previous topic :: View next topic |
| Author |
Message |
AHKPNH
Joined: 17 Feb 2006 Posts: 35
|
Posted: Mon Sep 17, 2007 10:35 am Post subject: Hotkeys letters Keyboard problem! |
|
|
Xairete.
When I press the "c" button in the keyboard I want to play a sound.
I do this
| Code: |
~c:: SoundPlay, %A_ScriptDir%\sounds\beep.wav
|
what if i want for all the keys when pressed play this sound? i have to write all this?
| Code: |
~a:: SoundPlay, %A_ScriptDir%\sound\beep.wav
~b:: SoundPlay, %A_ScriptDir%\sound\beep.wav
~c:: SoundPlay, %A_ScriptDir%\sound\beep.wav
~d:: SoundPlay, %A_ScriptDir%\sound\beep.wav
~e:: SoundPlay, %A_ScriptDir%\sound\beep.wav
~f:: SoundPlay, %A_ScriptDir%\sound\beep.wav
~g:: SoundPlay, %A_ScriptDir%\sound\beep.wav
~h:: SoundPlay, %A_ScriptDir%\sound\beep.wav
.
.
.
.
|
Is there quick and short method of doing this?
Thanks. |
|
| Back to top |
|
 |
tonne
Joined: 06 Jun 2006 Posts: 1162 Location: Denmark
|
Posted: Mon Sep 17, 2007 10:38 am Post subject: |
|
|
| Code: | #persistent
loop 26
{
ch := Chr(Asc("a")+A_Index-1)
HotKey, ~%ch%, dohotkey
}
dohotkey:
SoundPlay, %A_ScriptDir%\sound\beep.wav
return |
_________________ there's a dog barking close within the range of my ear
sounds like he wants to escape the chain
he would probably bite me to death if he could
but the chain lets me spit in his face
- Kashmir |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 5890
|
Posted: Mon Sep 17, 2007 10:50 am Post subject: |
|
|
a bit shortened:
| Code: | Loop 26
HotKey, % "~" Chr( 64 + A_Index ), SoundPlay
Return
SoundPlay:
SoundPlay, *-1
Return |
 |
|
| Back to top |
|
 |
AHKPNH
Joined: 17 Feb 2006 Posts: 35
|
Posted: Mon Sep 17, 2007 10:52 am Post subject: |
|
|
thank you both..................  |
|
| Back to top |
|
 |
AHKPNH
Joined: 17 Feb 2006 Posts: 35
|
Posted: Mon Sep 17, 2007 11:00 am Post subject: |
|
|
what about the numbers, the numpad... etc?
Is there a way? |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 5890
|
Posted: Mon Sep 17, 2007 11:09 am Post subject: |
|
|
| AHKPNH wrote: | | Is there a way? |
You may use Input command instead.  |
|
| Back to top |
|
 |
AHKPNH
Joined: 17 Feb 2006 Posts: 35
|
Posted: Mon Sep 17, 2007 11:14 am Post subject: |
|
|
xm... in the script I am developing I want to asign to all the keyboard keys a sound. So you can imagine that i have to write lots of repeating code.
All the letters, the numbers, the !@#$$%&**(),./;'][[.......
Function keys.......
That is what i want to avoid. |
|
| Back to top |
|
 |
BoBoĻ Guest
|
|
| Back to top |
|
 |
BoBoĻ Guest
|
|
| Back to top |
|
 |
AHKPNH
Joined: 17 Feb 2006 Posts: 35
|
Posted: Mon Sep 17, 2007 11:31 am Post subject: |
|
|
| Thanks BoBo'' but it wasn`t as much helpful as I wanted. |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 5890
|
Posted: Mon Sep 17, 2007 11:37 am Post subject: |
|
|
| AHKPNH wrote: | All the letters, the numbers, the !@#$$%&**(),./;'][[.......
Function keys....... |
I suggested Input command ?!
Try the following snippet as a standalone script.
| Quote: | Loop {
Input, SingleKey, L1 V, {LControl}{RControl}{LAlt}{RAlt}{LShift}{RShift}{LWin}{RWin}{AppsKey}{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}{Del}{Ins}{BS}{Capslock}{Numlock}{PrintScreen}{Pause}
SoundPlay *-1
} |
I chose to "quote" it to avoid horizontal scrolling!
 |
|
| Back to top |
|
 |
BoBoĻ Guest
|
Posted: Mon Sep 17, 2007 11:39 am Post subject: |
|
|
My last attempt. Promised . Look at that cool stuff from good ol' minnesotan jonny ...[Music functions]
Have fun  |
|
| Back to top |
|
 |
AHKPNH
Joined: 17 Feb 2006 Posts: 35
|
Posted: Mon Sep 17, 2007 11:45 am Post subject: |
|
|
Thanks Skan you are the man.........
Thank you BoBo''.... |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 5890
|
Posted: Mon Sep 17, 2007 11:50 am Post subject: |
|
|
| AHKPNH wrote: | | Thanks Skan |
Excluding the V in the options, I took that from AHK Doc example for Input command.
 |
|
| Back to top |
|
 |
|