Yes, it's partially my fault, I mentioned that the Javascript from the WebView variant (i.e. the 2nd variant) was untested code - I wrote it from my phone and had a few typos (not that easy to type from a phone compared to a laptop). I edited the above post and corrected them, so technically, both variants should work.Kotofanchik wrote: ↑April 2nd, 2024, 3:21 pm Something isn't working. Rainmeter\Skins\test3\DownloadFile\Data.txt file is empty
It also started causing the entire Rainmeter to freeze. I didn’t do anything, I see it froze, now it constantly freezes with test3
!WriteKeyValue: File not found: C:\Users\RmicroN\Documents\Rainmeter\Skins\test3\ + f +
HOWEVER, in practice, many times the 2nd variant you tried to use will NOT work and Rainmeter will freeze / hang (even after unloading the variant with the WebView measure!). The code is correct and you can see that if you first try to load the skin with the RainmeterAPI.Bang(bang); part commented out to <!-- RainmeterAPI.Bang(bang); -->, then uncomment that part and refresh or reload the skin (which will provide the data and will not cause Rainmeter to freeze while the skin is loaded, although it will freeze once you unload it). Frankly, this doesn't really depend on me since I did my part, but it's clear something else than the code itself is not going smoothly here (doesn't seem to be about the length of the string or the funky characters in it, since the freeze happens even I set the "page" variable to "blah blah" in Javascript).
I already explained the role of api.allorigins.win in the other thread:Kotofanchik wrote: ↑April 2nd, 2024, 8:29 pm I think about everything. why is api.allorigins.win here? I don’t understand the capabilities of Webwiev, but isn’t it easier to save a file using its ability to save to a file?
Maybe it’s simpler as I originally suggested:
Webwiev opens the specified site and receives a command to save its contents or overwrite it and that's it. and do it at intervals. Or is this impossible?
Well, and by the way, once again why webparser is not suitable. He cannot get to the desired site, but webwiev can.
Perhaps the option with api.allorigins.win will also work. But it hasn't been possible to check yet. Now the site works without human verification and I don’t know how the different ways will work.
This is again because of the security required here. You can't access an only address from a local page, because of CORS (google it). You can't save automatically the contents of a webpage (which is why I used Rainmeter bangs to do it from Javascript), only manually by interacting with the browser. Microsoft's WebView's only capability is to facilitate displaying webpages in a desktop program, and the only capability of khanhas's WebView plugin for Rainmeter is to facilitate Microsoft's WebView interaction with Rainmeter, that's all there is to it. The code is still subject to the same limitations a "normal" webpage code has (in the case of the page used by the WebView measure), or a "normal" skin code has (in the case of Rainmeter code).Getting the response makes use of this nice and free API to bypass CORS and get the response even if ran from the above local webpage.
So, there isn't any command to save a webpage contents to a local file, overwrite that file, or EVEN freely chosing that file's path (!) - yeah, I know, kind of stupid, but it's what it is. The most I could do is to come up with a minor alternative like:
- the path where the file is saved is restricted to the one in the WebView environment (for me, it is C:\Users\[User]\Downloads, as seen in [Data])
- a download popup always shows after downloading / saving the resource, see here for details (me, I'm not going to explore that further)
- the previous saved file needs to be deleted after it's no longer needed, otherwise the subsequent saves will be appended with (1), (2) and so on
- although initially I thought this alternative was safe, it will still freeze / hang Rainmeter, so clearly something is wrong with the plugin or such
Anyways, I'll stop here with this. You already have plenty of routes to follow, albeit not many convenient ones. Maybe others have better ideas, I don't know...