AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Hotkeys letters Keyboard problem!

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
AHKPNH



Joined: 17 Feb 2006
Posts: 35

PostPosted: Mon Sep 17, 2007 10:35 am    Post subject: Hotkeys letters Keyboard problem! Reply with quote

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
View user's profile Send private message
tonne



Joined: 06 Jun 2006
Posts: 1162
Location: Denmark

PostPosted: Mon Sep 17, 2007 10:38 am    Post subject: Reply with quote

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
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 5890

PostPosted: Mon Sep 17, 2007 10:50 am    Post subject: Reply with quote

a bit shortened:

Code:
Loop 26
  HotKey, % "~" Chr( 64 + A_Index ), SoundPlay
Return

SoundPlay:
 SoundPlay, *-1
Return


Smile
Back to top
View user's profile Send private message
AHKPNH



Joined: 17 Feb 2006
Posts: 35

PostPosted: Mon Sep 17, 2007 10:52 am    Post subject: Reply with quote

thank you both.................. Very Happy Very Happy
Back to top
View user's profile Send private message
AHKPNH



Joined: 17 Feb 2006
Posts: 35

PostPosted: Mon Sep 17, 2007 11:00 am    Post subject: Reply with quote

what about the numbers, the numpad... etc?
Is there a way?
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 5890

PostPosted: Mon Sep 17, 2007 11:09 am    Post subject: Reply with quote

AHKPNH wrote:
Is there a way?


You may use Input command instead. Rolling Eyes
Back to top
View user's profile Send private message
AHKPNH



Joined: 17 Feb 2006
Posts: 35

PostPosted: Mon Sep 17, 2007 11:14 am    Post subject: Reply with quote

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
View user's profile Send private message
BoBoĻ
Guest





PostPosted: Mon Sep 17, 2007 11:19 am    Post subject: Reply with quote

[Virtual button-accordion with PC-Speaker]
Might be of interest too. Smile
Back to top
BoBoĻ
Guest





PostPosted: Mon Sep 17, 2007 11:21 am    Post subject: Reply with quote

or that ... [Soundplant [GUI]]
Back to top
AHKPNH



Joined: 17 Feb 2006
Posts: 35

PostPosted: Mon Sep 17, 2007 11:31 am    Post subject: Reply with quote

Thanks BoBo'' but it wasn`t as much helpful as I wanted.
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 5890

PostPosted: Mon Sep 17, 2007 11:37 am    Post subject: Reply with quote

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!

Smile
Back to top
View user's profile Send private message
BoBoĻ
Guest





PostPosted: Mon Sep 17, 2007 11:39 am    Post subject: Reply with quote

My last attempt. Promised Wink. Look at that cool stuff from good ol' minnesotan jonny ...[Music functions]

Have fun Cool
Back to top
AHKPNH



Joined: 17 Feb 2006
Posts: 35

PostPosted: Mon Sep 17, 2007 11:45 am    Post subject: Reply with quote

Thanks Skan you are the man.........

Thank you BoBo''....
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 5890

PostPosted: Mon Sep 17, 2007 11:50 am    Post subject: Reply with quote

AHKPNH wrote:
Thanks Skan


Excluding the V in the options, I took that from AHK Doc example for Input command.

Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group