Hot key to refresh a browser that is in the background

google-chromekeyboard

I want to have a key combo to refresh active window in Google Chrome, which normally would be Cmd + R. Keep in mind that (a) I am using two screens, (b) Google Chrome is not presently active window.

Is it even possible?


I am trying to bind this script https://gist.github.com/51b459e5e93210f37e24 with hot-key. What I did is: created a service using Automator (no input, any application). Using services hot key, I've set cmd+r. However, that doesn't do anything.

My expected result is: cmd+r does what it should already do in the present app + executes my apple-script.

Best Answer

You can put either of these in an Automator service using a applescript Action.

Then set a keyboard shortcut with the Services in keyboard system preferences's Keyboard Shortcuts.

Note the 'Service receives' settings in the screen shots. This will make sure the Menu appears in all app's services. (The other apps may need to quit and re open before they pick up the short cut)


Chrome.

tell application "Google Chrome"
    reload active tab of (get window 1)
end tell

enter image description here


Safari.

tell application "Safari"
    tell document 1 to do JavaScript "javascript:location.reload(true)"
end tell

enter image description here


Services.

enter image description here


Service Menu -In iTunes

enter image description here