Jump to content

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

Avoid annoying sound using Control+C hotkey



  • Please log in to reply
6 replies to this topic
anelmuca
  • Members
  • 49 posts
  • Last active: Jul 10 2013 01:11 PM
  • Joined: 06 Oct 2011

Hi!

 

I have one script that I use a lot, and some colleagues use it too.

 

In my script I use the Appskey hotkey to send Control C. The problem is: when there is nothing to copy, Windows 7 makes an annoying sound. I haven't found a solution that can be implemented in the script, for anyone that uses my script.

 

I've been trying to do this with SoundSet, but I don't understand all the ComponentType and ControlType options. I've tried to turn the sound OFF before hitting Control C, and then turn it back ON, but this is too slow and what if the sound was already OFF? I wouldn't want to turn it ON.

 

Besides, SoundSet doesn`t work the same way in Windows 7, Windows XP and Vista. Maybe there's a better way.

 

 

Here is my script (simplified):

Appskey::
; SoundSet?????
Send ^c
ClipWait, 2
; SoundSet?????
Gui, Destroy
Gui, +AlwaysOnTop -MaximizeBox -MinimizeBox
Gui, Font, s12, Arial
Gui, Add, ComboBox, w500 vSearch r15 sort ym, One|Two|Three|Four|Five
GuiControl, Text, Search, %Clipboard%
Gui, Show,, Search
Return

Thanks.



C1ark
  • Members
  • 26 posts
  • Last active: Apr 18 2014 09:22 AM
  • Joined: 25 May 2013

This should work.

Appskey::
SoundGet, CurrentVolume
SoundSet, 0
Send ^c
ClipWait, 2
SoundSet, %CurrentVolume%
Gui, Destroy
Gui, +AlwaysOnTop -MaximizeBox -MinimizeBox
Gui, Font, s12, Arial
Gui, Add, ComboBox, w500 vSearch r15 sort ym, One|Two|Three|Four|Five
GuiControl, Text, Search, %Clipboard%
Gui, Show,, Search
Return


anelmuca
  • Members
  • 49 posts
  • Last active: Jul 10 2013 01:11 PM
  • Joined: 06 Oct 2011

Thanks a lot for the quick reply!

 

It does work, but it's too slow and too fast at the same time, I'll explain.

 

I use this Hotkey a lot, it's my only Hotkey, so I need this part of the code to be really fast.

 

I had to add Sleep 300 to your script. Without the sleep, the computer still made a little sound (only a little), it seems the computer needs more time to turn the sound to 0.

 

One question: how does Windows know when to make a sound? If there is text selected it doesn't make a sound, if there is nothing selected it makes the annoying sound. Can we do the same to turn the sound off or not?

 

Thank you very much again! I've added your suggestion to my script, I'm using this if there is not a better way.



vsub
  • Members
  • 1098 posts
  • Last active: Sep 28 2015 09:48 AM
  • Joined: 10 Nov 2011

What about disabling that sound effect from the Sound Scheme from the control panel?

You may also change the script like this

Appskey::
SoundGet, CurrentVolume
SoundSet, 0
KeyWait,Appskey



anelmuca
  • Members
  • 49 posts
  • Last active: Jul 10 2013 01:11 PM
  • Joined: 06 Oct 2011

Hi vsub.

 

I know how to disable system sounds manually in my computer, but that it not the solution I need. The script may be used in different computers. Besides, I don't want to disable the sounds completely, only when I hit Control C and there is nothing selected.

 

I have never used KeyWait so I tried it, but I didn't see any difference in this case. Thanks.



vsub
  • Members
  • 1098 posts
  • Last active: Sep 28 2015 09:48 AM
  • Joined: 10 Nov 2011
✓  Best Answer

Keywait wait for you to release the key,so using it like this,if you keep the key long enoung for the sound to be set to 0,when you release it,the sound will be set to 0 and you won't hear the effect it

 

Try it like this

Appskey::
SoundGet, CurrentVolume
SoundSet, 0
KeyWait,Appskey
Send ^c
ClipWait, 2
Gui, Destroy
Gui, +AlwaysOnTop -MaximizeBox -MinimizeBox
Gui, Font, s12, Arial
Gui, Add, ComboBox, w500 vSearch r15 sort ym, One|Two|Three|Four|Five
GuiControl, Text, Search, %Clipboard%
Gui, Show,, Search
Sleep,500
SoundSet, %CurrentVolume%
Return


anelmuca
  • Members
  • 49 posts
  • Last active: Jul 10 2013 01:11 PM
  • Joined: 06 Oct 2011

Ok, thanks!

 

I had to add more sleep at the end, and I used SetTimer instead of just Sleep, but this works, thanks a lot!