[solved] How to send Chrome a refresh periodically
- netmaestro
- 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
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?
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
Re: How to send Chrome a refresh periodically
6.10 will ship with edge gadget, won't be long before be available for testing 

- netmaestro
- 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
Thanks Fred. IE4 is older than PureBasic! Don't tell anyone else, this'll be our secret, OK?
BERESHEIT
Re: How to send Chrome a refresh periodically
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
Re: How to send Chrome a refresh periodically
there area already some Chromium WEbGadget by 3rd parties
https://www.purebasic.fr/english/viewtopic.php?t=75898
https://www.purebasic.fr/english/viewtopic.php?t=77089
https://www.purebasic.fr/english/viewtopic.php?t=72703
https://www.purebasic.fr/english/viewtopic.php?t=75898
https://www.purebasic.fr/english/viewtopic.php?t=77089
https://www.purebasic.fr/english/viewtopic.php?t=72703
Christos
Re: How to send Chrome a refresh periodically
Wow! This is great news!Fred wrote: Sat Dec 09, 2023 7:36 pm6.10 will ship with edge gadget, won't be long before be available for testing
Re: How to send Chrome a refresh periodically
Actually it uses lastest IE installed (mostly IE6)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?

Re: How to send Chrome a refresh periodically
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
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
Re: How to send Chrome a refresh periodically
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")
- netmaestro
- 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
Thanks, 6theo4, that works perfectly for me! Thanks as well to all who gave ideas, it's much appreciated 

BERESHEIT
Re: How to send Chrome a refresh periodically
You only need to see an animated GIF from KCC to know some code worked.

- netmaestro
- 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
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
Re: [solved] How to send Chrome a refresh periodically
maybe forgot to remove the "Debug" ?
Re: [solved] How to send Chrome a refresh periodically
Yeah, the iFrame html approach did not work for me.
And sendkeys will probably get blocked in the future.
And sendkeys will probably get blocked in the future.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum