Page 2 of 2
Re: [solved] How to send Chrome a refresh periodically
Posted: Mon Dec 11, 2023 2:28 am
by netmaestro
I've been trying the iFrame approach by Kiffi but without success. I slightly modified the code to make sure it's using html5 and edited the address to reflect my page but with both Chrome and Edge this is my result:

And here is the code I used:
Re: [solved] How to send Chrome a refresh periodically
Posted: Mon Dec 11, 2023 6:11 am
by firace
netmaestro wrote: Sun Dec 10, 2023 11:07 pm
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?
In the compiled version did you remove the Debug statement?
should be
Re: [solved] How to send Chrome a refresh periodically
Posted: Mon Dec 11, 2023 6:27 am
by netmaestro
Thanks 6theo4 and firace, that was it. I took the Debug statement out quite a while back and I thought I'd recompiled after that but I hadn't. Working perfectly now. Kiffi's code should work too imho but the server refuses to connect in both Chrome and Edge.
Re: [solved] How to send Chrome a refresh periodically
Posted: Mon Dec 11, 2023 1:44 pm
by 6theo4
you should add an entry with the chrome title when your connection is interrupted so you can also get a refresh after a disconnection....

Re: [solved] How to send Chrome a refresh periodically
Posted: Mon Dec 11, 2023 10:07 pm
by BarryG
netmaestro wrote: Sat Dec 09, 2023 6:20 pmWhen sales are recorded on site the info isn't pushed, I have to refresh the page if I want to see the latest sales.
You should be able to use ReceiveHTTPMemory() to get the page's raw HTML periodically, and then parse that. I do it all the time to get info from my website. No need to muck around with a Chrome window and F5.
Re: [solved] How to send Chrome a refresh periodically
Posted: Mon Dec 11, 2023 10:18 pm
by netmaestro
@BarryG, that's a great idea and I'll see if the site will talk to my computer. But it's a banking site so its security may not be something I can get through to. With the webpage I log in with my credentials and it sometimes gives me captchas and text messages containing 6 digit codes. I don't think my chances are going to be that good.
Re: [solved] How to send Chrome a refresh periodically
Posted: Mon Dec 11, 2023 10:21 pm
by skywalk
Kiffi wrote: Mon Dec 11, 2023 1:22 am
skywalk wrote: Mon Dec 11, 2023 12:30 amYeah, the iFrame html approach did not work for me.
Which browser?
Chrome and Edge are based on chromium code. Both bowsers fail to connect certain websites. Dell.com connects but I did not inspect why the others fail.
Code: Select all
<html>
<body>
<!--
<iframe id="myFrame" src="https://www.dell.com"></iframe>
-->
<iframe id="myFrame" src="https://www.ibm.com/us-en"></iframe>
<script>
window.setInterval("reloadIFrame();", 30000);
function reloadIFrame() {
<!--
document.getElementById("myFrame").src="https://www.dell.com";
-->
document.getElementById("myFrame").src="https://www.ibm.com/us-en";
}
</script>
</body>
</html>
Re: [solved] How to send Chrome a refresh periodically
Posted: Mon Dec 11, 2023 10:26 pm
by BarryG
That certainly changes things, NetMaestro, when a login and captchas are involved.
Re: [solved] How to send Chrome a refresh periodically
Posted: Tue Dec 12, 2023 7:59 am
by infratec
Without keyboard hacking involved:
Code: Select all
If OpenWindow(0, 0, 0, 600, 300, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
WebGadget(0, 10, 10, 580, 280, "https://www.purebasic.com")
AddWindowTimer(0, 123, 3000)
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Timer
If EventTimer() = 123
SetGadgetItemText(0, #PB_Web_HtmlCode, "<script>document.location.replace(location.href);</script>")
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
Re: [solved] How to send Chrome a refresh periodically
Posted: Tue Dec 12, 2023 9:12 am
by Kiffi
Some website operators prevent their site from running in an IFrame. For this reason, my solution does not work.
+1 for infratec's solution.
Re: [solved] How to send Chrome a refresh periodically
Posted: Tue Dec 12, 2023 9:18 am
by infratec
There are different methods available to do it with javascript.
You can read about the cons and pros here:
https://www.freecodecamp.org/news/javas ... age-in-js/
Re: [solved] How to send Chrome a refresh periodically
Posted: Tue Dec 12, 2023 7:14 pm
by netmaestro
Thanks infratec but the site won't work in the native webgadget. But the WebGadgetEx by RSBasic works flawlessly. So I have a couple of solutions that are working now until Fred releases b1 of PB 6.10. Then the native webgadget should do the trick and your code will be the best and simplest solution overall. You're just a couple weeks early is all. I found your implementation of js very instructive as I'm pretty much of a noob when it comes to javascript.
Re: [solved] How to send Chrome a refresh periodically
Posted: Tue Dec 12, 2023 7:58 pm
by infratec
There is also an other possibility: use the WebView2 runtime from Windows Edge
https://www.purebasic.fr/english/viewto ... 39#p609539
This implements a full working WebView2Gadget().