Refresh Firefox with a Keystroke from Sublime Text

Browser Sync is nice but sometimes it is not available or it’s just plain overkill.

I wanted to always be able to refresh my web browser window with a keystroke while still keeping my code editor open and focused.

I use the 64-bit version of Firefox Developer Edition for Windows.

The simple AutoHotkey snippet below will refresh the current Firefox Developer Edition edition tab when the F5 key is pressed within Sublime Text, while still keeping the focus on Sublime Text.

SetTitleMatchMode, 2
#IfWinActive ahk_exe sublime_text.exe
  F5::
  {
    IfWinExist, Firefox Developer Edition
    {
       ControlSend, ahk_parent, {F5}, Firefox Developer Edition
    }
    Return
  }
#IfWinActive

Using a Different Editor instead of Sublime

You can substitute your editor of choice by using the “Window Spy” feature of AHK and clicking on the editor. For example, Atom is ahk_exe atom.exe

Using Chrome instead of Firefox Developer Edition

This one didn’t seem to work as easily, but I came up with this in a couple minutes, based on this StackOverflow answer.

SetTitleMatchMode, 2
#IfWinActive ahk_exe sublime_text.exe
  F5::
  {
    IfWinExist, Google Chrome
    {
       WinActivate, Google Chrome
       ControlSend, , {F5}, Google Chrome
       Click
       WinActivate, ahk_exe sublime_text.exe
    }
    Return
  }
#IfWinActive

That click in the middle of there was to get Chrome to stop flashing my taskbar. You may or may not need it.


Did this post save you time, frustration, or money?


Leave a Reply

Your email address will not be published. Required fields are marked *

Note: Comments are moderated. Please submit the form only once.