Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 09, 2016, 03:50:24 AM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: refresh all open browsers automatically?  (Read 4563 times)

nudone

  • Cody's Creator
  • Columnist
  • Joined in 2005
  • ***
  • Posts: 4,117
    • View Profile
    • Donate to Member
refresh all open browsers automatically?
« on: April 29, 2010, 08:45:56 AM »
anyone know of a little util that will automatically refresh ALL browsers that are open?

when i say "automatically" i mean, by pressing a single key or button and then IE, FireFox, Safari, Chome, Opera, etc. refresh the page they are on (or the main tab that's selected).

this has got to be an old idea so there ought to be something out there - not that i can find anything.

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 4,668
    • View Profile
    • Donate to Member
Re: refresh all open browsers automatically?
« Reply #1 on: April 29, 2010, 09:13:40 AM »
This wouldn't take much in AHK.  Give me a minute.

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 4,668
    • View Profile
    • Donate to Member
Re: refresh all open browsers automatically?
« Reply #2 on: April 29, 2010, 09:34:07 AM »
Tested on my computer running WinXP SP2 and with the following browsers:

Firefox
Internet Explorer
Maxthon
Opera
Safari
Chrome

Code: AutoIt [Select]
  1. WinGet, myList, List
  2. Loop, % myList
  3. {
  4.     myID := myList%A_Index%
  5.     WinGetTitle, myTitle, % "ahk_id " . myID
  6.     WinGetClass, myClass, % "ahk_id " . myID
  7.  
  8.     If myTitle contains Firefox,Chrome,Maxthon ; These accept remote keysends directly.
  9.     {
  10.         ControlSend, , {F5}, % "ahk_id " . myID
  11.     }
  12.     Else If myTitle contains Opera,Internet Explorer ; These have to be focused first.
  13.     {
  14.         WinActivate, % "ahk_id " . myID
  15.         ControlSend, , {Ctrl down}r{Ctrl up}, % "ahk_id " . myID
  16.     }
  17.     Else If myClass contains {1C03B488-D53B-4a81-97F8-754559640193} ; Safari.
  18.     {
  19.         WinActivate, % "ahk_id " . myID
  20.         ControlSend, , {F5}, % "ahk_id " . myID
  21.     }
  22. }

nudone

  • Cody's Creator
  • Columnist
  • Joined in 2005
  • ***
  • Posts: 4,117
    • View Profile
    • Donate to Member
Re: refresh all open browsers automatically?
« Reply #3 on: April 29, 2010, 10:17:18 AM »
thanks for giving it a shot, skwire but it doesn't seem to be refreshing more than a single browser at a time - i think it may have done two though.

i'm using vista so maybe that's the problem.

interestingly, Internet Explorer refreshes without being focussed - sometimes. the two that refreshed together were Chrome and IE.

Firefox doesn't appear to want to play and neither does Maxthon.

if this all sounds inexplicable then it might be best to leave it alone - if it's a vista thing then i'm sort of stuck.

oh, one other thing - does it matter if i have lots of non browser windows open at the same time? i should have mentioned that in the first place. sorry.

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 4,668
    • View Profile
    • Donate to Member
Re: refresh all open browsers automatically?
« Reply #4 on: April 29, 2010, 06:09:36 PM »
i'm using vista so maybe that's the problem.

Could be...but I don't see why that would make such a huge difference in this case.

oh, one other thing - does it matter if i have lots of non browser windows open at the same time? i should have mentioned that in the first place. sorry.

No, that shouldn't matter.  The code:

1) Scans through all open processes.
2) Gets their window title and class.
3) Matches against a few lists.
4) Sends an F5 (Ctrl-R in some cases) keystroke to the parent window.

nudone

  • Cody's Creator
  • Columnist
  • Joined in 2005
  • ***
  • Posts: 4,117
    • View Profile
    • Donate to Member
Re: refresh all open browsers automatically?
« Reply #5 on: April 30, 2010, 03:29:20 AM »
right. that's how i thought it was working - i'm trying to think of what could be stopping it.

i wondered if using multi-monitors would be a problem but it is refreshing IE on a 2nd screen and Chrome on the main screen - so no problem there.

would it make a difference if the process performed slower?

i've 3 other autohotkey scripts running at the same time - could these be challenging this browser refresh script in some way?

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 4,668
    • View Profile
    • Donate to Member
Re: refresh all open browsers automatically?
« Reply #6 on: April 30, 2010, 03:32:53 AM »
would it make a difference if the process performed slower?

No, it shouldn't.

i've 3 other autohotkey scripts running at the same time - could these be challenging this browser refresh script in some way?

Nope.  However, if you don't mind, I could re-write it so that each window is focused first and then dealt with.  Is this acceptable?

nudone

  • Cody's Creator
  • Columnist
  • Joined in 2005
  • ***
  • Posts: 4,117
    • View Profile
    • Donate to Member
Re: refresh all open browsers automatically?
« Reply #7 on: April 30, 2010, 04:02:13 AM »
Nope.  However, if you don't mind, I could re-write it so that each window is focused first and then dealt with.  Is this acceptable?

ooh, that's a good idea. please do.

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 4,668
    • View Profile
    • Donate to Member
Re: refresh all open browsers automatically?
« Reply #8 on: April 30, 2010, 04:22:05 AM »
Try this:

Code: AutoIt [Select]
  1. WinGet, myList, List
  2. Loop, % myList
  3. {
  4.     myID := myList%A_Index%
  5.     WinGetTitle, myTitle, % "ahk_id " . myID
  6.     WinGetClass, myClass, % "ahk_id " . myID
  7.  
  8.     If myTitle contains Firefox,Chrome,Maxthon,Opera,Internet Explorer
  9.     {
  10.         WinActivate, % "ahk_id " . myID
  11.         WinWaitActive, % "ahk_id " . myID
  12.         SendInput, {Ctrl down}r{Ctrl up}
  13.         Sleep, 250
  14.         ; ControlSend, , {Ctrl down}r{Ctrl up}, % "ahk_id " . myID
  15.         ; ControlSend, , {F5}, % "ahk_id " . myID
  16.         ; SendInput, {F5}
  17.     }
  18.     Else If myClass contains {1C03B488-D53B-4a81-97F8-754559640193} ; Safari.
  19.     {
  20.         WinActivate, % "ahk_id " . myID
  21.         WinWaitActive, % "ahk_id " . myID
  22.         SendInput, {Ctrl down}r{Ctrl up}
  23.         Sleep, 250
  24.         ; ControlSend, , {Ctrl down}r{Ctrl up}, % "ahk_id " . myID
  25.         ; ControlSend, , {F5}, % "ahk_id " . myID
  26.         ; SendInput, {F5}
  27.     }
  28. }

nudone

  • Cody's Creator
  • Columnist
  • Joined in 2005
  • ***
  • Posts: 4,117
    • View Profile
    • Donate to Member
Re: refresh all open browsers automatically?
« Reply #9 on: April 30, 2010, 05:29:30 AM »
excellent. it now appears to work (it got stuck a couple of times but i can't say why).

i've just changed the SendInput to F5 as Maxthon didn't want to respond (even after making sure that ctrl+R did work for it).

perhaps this should be included on Skwire Empire - i think it's a really helpful web development util. i still don't understand why there hasn't been something like this around for years.

i'll send some DC credits later - just waiting for them to go into my account first.

thanks very much for this, skwire.

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 4,668
    • View Profile
    • Donate to Member
Re: refresh all open browsers automatically?
« Reply #10 on: April 30, 2010, 06:28:41 AM »
excellent. it now appears to work (it got stuck a couple of times but i can't say why).
i've just changed the SendInput to F5 as Maxthon didn't want to respond (even after making sure that ctrl+R did work for it).

Who knows?   :D  That's how these scriptlets go sometimes.  You could play with the sleep value a bit to see if that helps.

perhaps this should be included on Skwire Empire - i think it's a really helpful web development util. i still don't understand why there hasn't been something like this around for years.

*shrug* Honestly, that above code  is very simple and could be set as a hotkey in your main AHK script (if you use one).  Bits like this really show off how flexible and powerful AHK is as a language.

i'll send some DC credits later - just waiting for them to go into my account first.
thanks very much for this, skwire.

You are most welcome.  Happy to help.   :)

nudone

  • Cody's Creator
  • Columnist
  • Joined in 2005
  • ***
  • Posts: 4,117
    • View Profile
    • Donate to Member
Re: refresh all open browsers automatically?
« Reply #11 on: April 30, 2010, 06:43:56 AM »
i've been wondering about combining all of the autohotkey scripts into one single script - something i'll have to investigate later.

if you don't mind, maybe i'll try and modify the browser refresh script into a little tray app - just with a menu for selecting browsers or something. it would give me something to play with and learn autohotkey.

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 4,668
    • View Profile
    • Donate to Member
Re: refresh all open browsers automatically?
« Reply #12 on: April 30, 2010, 06:52:13 AM »
if you don't mind, maybe i'll try and modify the browser refresh script into a little tray app - just with a menu for selecting browsers or something. it would give me something to play with and learn autohotkey.

By all means, please do.  I'm happy to help if you get stuck, too.