Hi, I'm looking, but I can't find a script that would detect the activity of the CAPS LOCK button and when entering any capital letter from A to Z, it would play the selected sound (path to the sound on the computer).
To recap:
1. CAPS LOCK is turned on - each time you enter any letter from A to Z, a sound is played.
2. CAPS LOCK is turned off - every time you enter any letter from a to z, no sound is played.
Play a sound when typing capital letters
Re: Play a sound when typing capital letters
This does not pay attention to Capslock, it just checks to see if the keyboard input is a capitalized ascii character. Do you need it to be specifically dependent upon the Capslock toggle state, as you stated? It can be tweaked to do that instead if needed. You should choose an audio clip that is very brief in duration/length.
This is AHKv1 which is the forum version where you posted your request.
This is AHKv1 which is the forum version where you posted your request.
Code: Select all
#Requires AutoHotkey 1.1.36+
#SingleInstance force
#Persistent
ih := InputHook("V"), ih.OnChar := Func("_OnChar"), ih.start()
return
^esc::ExitApp ; Ctrl+esc to end script
_OnChar(ih,char)
{
if (InStr("ABCDEFGHIJKLMNOPQRSTUVWXYZ", char, true))
SoundPlay % "C:\Windows\Media\Windows Information Bar.wav" ; Win7 standard audio clip
; Soundbeep, 1500, 50 ; alternative
}
Re: Play a sound when typing capital letters
Thank you very much, but for now there is something wrong with the script.
After pasting the script, the script doesn't seem to work. Other scripts work fine. Only when I press CTRL + ESC, the entire autohotkey with all Skype scripts closes completely (the icon next to the clock in the taskbar disappears).
I use Windows 10, Autohotkey 1.1.37.01, Avast Free Antivirus.
When the script is turned on, after some time the cursor gets stuck, typing letters is slow in all applications, and the process is "suspended" in the task manager.
After pasting the script, the script doesn't seem to work. Other scripts work fine. Only when I press CTRL + ESC, the entire autohotkey with all Skype scripts closes completely (the icon next to the clock in the taskbar disappears).
I use Windows 10, Autohotkey 1.1.37.01, Avast Free Antivirus.
When the script is turned on, after some time the cursor gets stuck, typing letters is slow in all applications, and the process is "suspended" in the task manager.
Re: Play a sound when typing capital letters
Try this one.
I removed the ^esc (which was there to exit the script, not to run it.). Now that it has been removed, you will need to end the script manually using the tray icon.
I also changed the method of inspecting the key that is pressed. It might be faster this way. I'm not sure.
I also removed the soundplay, and just using soundbeep. Playing an audio file could be causing an issue.
InputHook can act a little slow, but it's the most convenient way to watch for "any key" to be pressed (that I know of).
If this one causes issues, maybe someone else has another suggestion or approach.
I edited this on my phone, and am unable to test on computer at the moment.
I removed the ^esc (which was there to exit the script, not to run it.). Now that it has been removed, you will need to end the script manually using the tray icon.
I also changed the method of inspecting the key that is pressed. It might be faster this way. I'm not sure.
I also removed the soundplay, and just using soundbeep. Playing an audio file could be causing an issue.
InputHook can act a little slow, but it's the most convenient way to watch for "any key" to be pressed (that I know of).
If this one causes issues, maybe someone else has another suggestion or approach.
I edited this on my phone, and am unable to test on computer at the moment.
Code: Select all
#Requires AutoHotkey 1.1.36+
#SingleInstance force
#Persistent
ih := InputHook("V"), ih.OnChar := Func("_OnChar"), ih.start()
return
_OnChar(ih,char)
{
if(asc(char)>=65 and asc(char)<=90) ; A-Z
Soundbeep, 1500, 50 ; alternative
}
Re: Play a sound when typing capital letters
Unfortunately, there is no sound when clicking from A to Z. Of course, the script is pasted, reloaded and the remaining scripts work. The speakers work. ![Wink ;)](./images/smilies/icon_e_wink.gif)
![Wink ;)](./images/smilies/icon_e_wink.gif)
Re: Play a sound when typing capital letters
Ok... I'm not sure what the trouble is... I just tested it on my Win10 system, it works for me.
SoundBeep and SoundPlay are both very slow (like several hundredths of a second to execute), but I don't know of an alternative for the sound. Make sure that the SoundBeep is the first line following the if statement (must be directly under it, otherwise it will not execute). Or you can enclose it in braces, like this:
Code: Select all
if (InStr("ABCDEFGHIJKLMNOPQRSTUVWXYZ", char, true))
{
Soundbeep
}
Last edited by andymbody on 19 Oct 2023, 14:35, edited 1 time in total.
Re: Play a sound when typing capital letters
Script works fine here.