How to reload/refresh a web page without leaving m

2020-02-16 06:59发布

Building Websites

When I build websites I use 2 monitors. I have my development IDE on the main monitor and the web page open on the secondary screen.

I get annoyed that everytime I need to refresh the web page I have to go to my mouse, move over to the other screen and click refresh.

I would like to have a shortcut key mapped to reloading the web page whenever I need. In a similar way to how Winamp maps keys to common functions like play/pause etc.

My current research:

Firefox via Command Line

I have discovered that an existing FireFox process can be controled from the command line, however the best it can do is create a new window with a specific URL.

firefox -remote "openURL(www.mozilla.org, new-tab)"

The documentation is here: https://developer.mozilla.org/en/Command_Line_Options

Reload Every

There is also a firefox extension that will refresh the web page periodically. However this results in a constant flickering of the page and will also be wasteful with resources.

https://addons.mozilla.org/en-US/firefox/addon/115/

However, what I really need is either....

  • A customisable global hotkey for Firefox/Chrome to reload current selected tab
  • A browser extension that could be fired from a Global Hotkey
  • A command to reload the current selected tab from the Command Line that I could then map to a hotkey (is it possible to add extra remote command with an extentsion?)

Does anyone know how I could do this? Thanks!

13条回答
smile是对你的礼貌
2楼-- · 2020-02-16 08:04

The VBScript solution does not work with Google Chrome browser in Windows 7. Below is a solution that works amazingly well with any browser (just adjust the ititle string) and the Eclipse IDE by using a small utility from NirSoft (http://www.nirsoft.net/).

  • Download NirCmd and extract 'nircmd.exe' somewhere into your project (its KISS this way).
  • Create the following 'nircmd-chrome-focus+f5.bat' batch file somewhere in your project:

    ECHO Off
    REM This little batch files calls the awesome nircmd utility to focus Chrome window send an F5 and swtich
    REM back to Eclipse. This is no longer possible with VBScript in WIN7 as Chrome can only be focused but won't 
    REM accept key sends unless a click is made. Seriously donate to the NirSoft for making this tool. 
    
    %~dp0nircmd.exe win activate ititle "- Google Chrome"
    %~dp0nircmd.exe win max ititle "- Google Chrome"
    %~dp0nircmd.exe sendkey f5 press
    %~dp0nircmd.exe win activate ititle "- Eclipse"
    %~dp0nircmd.exe win max ititle "- Eclipse" 
    
    
  • Add the batch file as a project builder 'Project > Properties > Builder > New' and ensure 'Project > Build Automatically' and 'Build Options' > 'During auto builds' is selected. See below screenshot for an idea.

查看更多
登录 后发表回答