How to map a global key to refresh?

时间秒杀一切 提交于 2019-12-04 19:29:52
demoncodemonkey

Autohotkey

Let me add my result for the awesome.ahc file:

^s::
SetTitleMatchMode, 2
IfWinExist, Mozilla Firefox
{
   WinActivate, Mozilla Firefox
   ControlSend, ahk_parent, {F5}, Mozilla Firefox
}
Return

This will switch to firefox and refresh the currently active tab.

As demoncodemonkey greatly suggested you can use Autohotkey. This is my script sample.

^x::                  ; listen for a CTRL+x
   Send ^s               ; sends a CTRL+s save command to Eclipse
   Sleep 500             ; sleeps a bit to allow SSH to transfer file
   Send !{tab}^r         ; alt-tab followed by a browser refresh
   Sleep 100             ; firefox, needs just a bit to allow ALT-TAB
   Send !{tab}           ; tabs back to eclipse

This is even better than I had in mind as I can do it all with only a single command. Very impressive. Thanks again demoncodemonkey.

Using Frankie's answer, I developed something a bit more advanced. My editor is Aptana, but you can easily change it into anything else:

$^s::                                       ; only capture actual keystrokes
SetTitleMatchMode, 2                        ; match anywhere in the title
IfWinActive, Aptana Studio 3                ; find aptana
{
    Send ^s                                 ; send save command
    IfWinExist, Mozilla Firefox             ; find firefox
    {
        WinActivate                         ; use the window found above
        Sleep 500                           ; sleeps to allow SSH to transfer file
        Send ^r                             ; send browser refresh
        WinActivate, Aptana Studio 3        ; get back to Aptana
    }
}
else
{
    Send ^s                                 ; send save command
}
return
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!