[solved] How to send Chrome a refresh periodically

Just starting out? Need help? Post your questions and find answers here.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

[solved] How to send Chrome a refresh periodically

Post by netmaestro »

I have a sales page which is always up during the day and it's displayed in Chrome. When sales are recorded on site the info isn't pushed, I have to refresh the page if I want to see the latest sales. I would like to write a small tool in PB that knows where the Chrome window is and refreshes it once per minute. My problem: no idea how to do that. Any suggestions would be much appreciated, thanks.

An alternative would be the webgadget I guess but the doc for it says it uses Internet Explorer 4. IE4 is 26 years old! Can this be right? If so, is it possible to hook it up to a more modern engine?
Last edited by netmaestro on Sun Dec 10, 2023 9:51 pm, edited 1 time in total.
BERESHEIT
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: How to send Chrome a refresh periodically

Post by Fred »

6.10 will ship with edge gadget, won't be long before be available for testing 8)
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: How to send Chrome a refresh periodically

Post by netmaestro »

Thanks Fred. IE4 is older than PureBasic! Don't tell anyone else, this'll be our secret, OK?
BERESHEIT
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: How to send Chrome a refresh periodically

Post by Kiffi »

You can place your page in an iFrame and then update it regularly:

Code: Select all

<html>

<body>

<iframe id="myFrame" src="https://yourSite"></iframe>

<script>
	window.setInterval("reloadIFrame();", 30000);
	function reloadIFrame() {
		document.getElementById("myFrame").src="https://yourSite";
	}
</script>

</body>

</html>
Hygge
plouf
Enthusiast
Enthusiast
Posts: 281
Joined: Fri Apr 25, 2003 6:35 pm
Location: Athens,Greece

Re: How to send Chrome a refresh periodically

Post by plouf »

Christos
BarryG
Addict
Addict
Posts: 4128
Joined: Thu Apr 18, 2019 8:17 am

Re: How to send Chrome a refresh periodically

Post by BarryG »

Fred wrote: Sat Dec 09, 2023 7:36 pm6.10 will ship with edge gadget, won't be long before be available for testing 8)
Wow! This is great news!
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: How to send Chrome a refresh periodically

Post by Fred »

netmaestro wrote: Sat Dec 09, 2023 7:41 pm Thanks Fred. IE4 is older than PureBasic! Don't tell anyone else, this'll be our secret, OK?
Actually it uses lastest IE installed (mostly IE6) :)
normeus
Enthusiast
Enthusiast
Posts: 470
Joined: Fri Apr 20, 2012 8:09 pm
Contact:

Re: How to send Chrome a refresh periodically

Post by normeus »

This code from Rashad might help:

https://www.purebasic.fr/english/viewto ... 61#p611861

I haven't tried it, but KCC was very happy it worked so I assume it works.

Norm
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
6theo4
New User
New User
Posts: 8
Joined: Sun Dec 08, 2013 8:44 pm

Re: How to send Chrome a refresh periodically

Post by 6theo4 »

this works for me

Code: Select all

Procedure SendF5(window$) ; use part of window name  
  r=GetWindow_(GetDesktopWindow_(),#GW_CHILD)
  Repeat
    t$=Space(999) : GetWindowText_(r,@t$,999) 
;        Debug t$  ;to get window titles
  If FindString(LCase(t$), LCase(window$),1)<>0 And IsWindowVisible_(r)=#True
    t$=Trim(t$)
;    If t$ = window$ And IsWindowVisible_(r)=#True   ; use this part for full window name 
    w=r
    Else
      r=GetWindow_(r,#GW_HWNDNEXT)
    EndIf
  Until r=0 Or w<>0  
 handle = w     
  If IsWindow_(handle)=0 ; Does the target window actually exist?
    ProcedureReturn 0 ; Nope, so report 0 for failure to type.
  Else
    ; This block gives the target window the focus before typing.
    thread1=GetWindowThreadProcessId_(GetForegroundWindow_(),0)
    thread2=GetWindowThreadProcessId_(handle,0)
    If thread1<>thread2 : AttachThreadInput_(thread1,thread2,#True) : EndIf
    SetForegroundWindow_(handle) ; Target window now has the focus for typing.
    Sleep_(125) ; 1/8 second pause before typing to prevent fast CPU problems.
    ; Now the actual typing starts.
    keybd_event_(#VK_F5,0,0,0)    
    If thread1<>thread2 : AttachThreadInput_(thread1,thread2,#False) : EndIf ; Finished typing to target window!
    ProcedureReturn 1 ; Report successful typing!  :)
  EndIf
EndProcedure

Debug SendF5("window title")
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: How to send Chrome a refresh periodically

Post by netmaestro »

Thanks, 6theo4, that works perfectly for me! Thanks as well to all who gave ideas, it's much appreciated :mrgreen:
BERESHEIT
BarryG
Addict
Addict
Posts: 4128
Joined: Thu Apr 18, 2019 8:17 am

Re: How to send Chrome a refresh periodically

Post by BarryG »

normeus wrote: Sun Dec 10, 2023 6:14 pmKCC was very happy it worked so I assume it works
You only need to see an animated GIF from KCC to know some code worked. :lol:
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: [solved] How to send Chrome a refresh periodically

Post by netmaestro »

Ok, so this is just weird now. The code from 6theo4 works perfectly, refreshing my window at the selected intervals. But only if run from the IDE. If I compile the code, add it to my taskbar and run it from there it does not work anymore. Anyone have an idea?
BERESHEIT
6theo4
New User
New User
Posts: 8
Joined: Sun Dec 08, 2013 8:44 pm

Re: [solved] How to send Chrome a refresh periodically

Post by 6theo4 »

maybe forgot to remove the "Debug" ?
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: [solved] How to send Chrome a refresh periodically

Post by skywalk »

Yeah, the iFrame html approach did not work for me.
And sendkeys will probably get blocked in the future.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: [solved] How to send Chrome a refresh periodically

Post by Kiffi »

skywalk wrote: Mon Dec 11, 2023 12:30 amYeah, the iFrame html approach did not work for me.
Which browser?
Hygge
Post Reply