Prehistory:
Some time ago Skype has assigned Ctrl+R hotkey to make a new call. This setting can't be disabled.
Sometimes I confuse browser window with Skype window and made a call to many people instead of refreshing browser window (I need to refresh browser window very often because of profession).
So I made a script to prevent sending Ctrl+R hotkey to Skype window, it works perfect, but sometimes I can't send Ctrl+R anywhere, not only Skype window.
Code:
;#NoTrayIcon
$^r::
WinGetClass, class, A
if (class != "TConversationForm")
Send ^r
return
Compiled binary: http://random.net.ua/SkypePreventHotkey.exe
Autohotkey version: 1.1.14.03
I have two improvements:
#If(...)
for context-sensitive hotkeys whenever possible. In my experience, #If
is more reliable due to various reasons. Also, you won't have to worry about non-affected windows (e.g. by deciding what to send); in fact, I believe that non-affected windows receive the original native keystrokes if the #If...
condition comes up false.ahk_exe
which lets you identify windows by their process name, rather than their class/title. It's possible that different windows of the same program have different class names, e.g. Windows Media Player in minimized/maximized mode. Possibly, Skype has that, too. That's why for more complex applications, it is often reasonable to identify by process name.Mixing these suggestions into a solution, we get this brief piece of code:
; I hope it's skype.exe ;)
#IfWinActive ahk_exe skype.exe
^r::return
Instead of programmatically saying "If the active window isn't Skype, we send CTRL + R", we're now saying "If the window is Skype, we do nothing".