Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
411 views
in Technique[技术] by (71.8m points)

AutoHotkey - capture a hotkey combination in one application only - do not prevent other apps from using same combination

I have created a hotkey that I want to use only in MS Teams (workaround for the lack of 'Reply to message' function).

I assigned it to Ctrl+R, however it seems that it prevents other applications that use the same combination from noticing the hotkey.

The code is below:

^r::
if WinActive("ahk_exe Teams.exe")
{
    SoundBeep 200,500
    Send, ^c
    Send, {Tab}
    Send, >
    Sleep, 500
    Send, ^v
    Send, {Enter}
    Send, {Enter}
}
return

Is there a way to tell AHK to let the key combination bubble up when the active app is NOT teams?
I tried adding an 'else' clause in which I would Send, ^r but that didn't work.

question from:https://stackoverflow.com/questions/65884247/autohotkey-capture-a-hotkey-combination-in-one-application-only-do-not-preve

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Actually, I got it. Posting the working solution.

It seems I needed to wrap the hotkey declaration within the #ifwinactive directive.

#IfWinActive("ahk_exe Teams.exe")
^r::
    SoundBeep 200,500
    Send, ^c
    Send, {Tab}
    Send, >
    Sleep, 500
    Send, ^v
    Send, {Enter}
    Send, {Enter}
return
#IfWinActive

An even better, comprehensive solution and more powerful approach by @ThierryDalon - https://github.com/tdalon/ahk/blob/master/Lib/Teams.ahk https://tdalon.blogspot.com/2020/11/teams-shortcuts-smart-reply.html


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...