How to map a global key to refresh?

匆匆过客 提交于 2019-12-12 09:16:37

问题


Winamp has a neat feature. Global keys. That way I can change the playing song even if Winamp GUI doesn't have focus.

I am looking for a similar solution to Firefox or Chrome.

I use Eclipse to code PHP. It auto SSH's and saves to another machine (testing) I could use something like XRefresh with a mapped virtual drive but I cant install Samba on the testing machine.

Right now I have to:

CTRL+S (save and auto-update)
ALT+TAB (switch to Firefox GUI)
F5 (refresh current Firefox page)
ALT+TAB (back to Eclipse)

I am looking for something like:

CTRL+S (save and auto-update)
CTRL+X (refresh Firefox - while keeping focus on Eclipse)

I've looked over Firefox Plug-ins but found nothing to my needs. Chrome neither. XRefresh would be a perfect solution but, as said, cant SSH/Samba into the testing machine.


回答1:


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.




回答2:


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.




回答3:


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


来源:https://stackoverflow.com/questions/1476777/how-to-map-a-global-key-to-refresh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!