Loading "cached" web pages in Chrome Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
User avatar
RobbieWilkes
Posts: 12
Joined: 27 Feb 2018, 21:52
Facebook: https://www.facebook.com/robbiewilkes

Loading "cached" web pages in Chrome

02 Mar 2018, 13:31

Hello folks, got one that I haven't been able to Google my way out of, so thought I'd come here, hat in hand, and seek the wisdom of the masters. As I've investigated further, I discovered that, although I had presented this question before, I did not really give a clear / adequate explanation of what was needed.

Not sure if I'm wording this correctly, or even understanding exactly what is going on, so please bear with me, but is there any way to load a currently "cached" web page while in Chrome?

As further explanation, here's why...

I am launching YouTube TV in Chrome kiosk mode, via AHK, and then capturing input from my MCE remote controls, for a nicer 10 foot interface. Thus far I've been able to accomplish almost everything I want, and have GREATLY improved the experience.

Currently YouTube TV has 3 different sections - Home, Library and Live, each with their own URL:

https://tv.youtube.com ; the default (home) screen
https://tv.youtube.com/library ; the recorded / on-demand shows
https://tv.youtube.com/live ; the live tv channels

I want to be able to switch between those links using the remote control (right now the numpad1 2 & 3 buttons), and have already tried simply launching the links via the Run command, but doing so takes a LOT longer than just clicking on the links.. which is almost instantaneous. Since I'm no web developer, I'm not sure what's going on behind the scenes, but one would assume that the pages are somehow being "cached", so that they just quickly appear, whereas the Run command causes a full reload.

I'm currently handling it via mouseclicks, which works well, but requires the specific coordinates of the link, and really inhibits scalability on different resolutions, etc.

Maybe I'm missing something simple... such as just simulating a mouseclick on the links, without having to know their location, but, thus far I haven't spotted the command to allow me to do that.

Any thoughts or illumination on how this is being handle by the site would be greatly appreciated.

Here's the current code for my YouTube TV launcher, and I would also love any input / suggestions on how I could improve it or do things more effectively & efficiently.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Last edited by RobbieWilkes on 02 Mar 2018, 18:38, edited 1 time in total.
MaxAstro
Posts: 550
Joined: 05 Oct 2016, 13:00

Re: Loading "cached" web pages in Chrome

02 Mar 2018, 14:56

Do the URLs change? I believe Ctrl + L in Chrome selects the address bar, so you could simply have a hoykey that presses Ctrl + L and then types in the correct address.
User avatar
RobbieWilkes
Posts: 12
Joined: 27 Feb 2018, 21:52
Facebook: https://www.facebook.com/robbiewilkes

Re: Loading "cached" web pages in Chrome

02 Mar 2018, 18:23

MaxAstro wrote:Do the URLs change? I believe Ctrl + L in Chrome selects the address bar, so you could simply have a hoykey that presses Ctrl + L and then types in the correct address.


Thanks for respondig MaxAstro.

Yes, the URLs do change (I'm actually monitoring and using that to determine how buttons function), but, as I'm running it in kiosk mode, the address bar is unavailable.

In any event, I have tested, while not in KIOSK, and, if the URL is changed via the address bar, a similar load-time occurs as is experienced with the Run statement. The load, when clicking the links, is nearly instantaneous, which is what led me to use the "caching" terminology... though I have no idea if that is what is actually occurring.
MaxAstro
Posts: 550
Joined: 05 Oct 2016, 13:00

Re: Loading "cached" web pages in Chrome

05 Mar 2018, 10:43

Unfortunately I don't think there is a way to locate and click a link directly... If the relative position of the link doesn't change you might be able to tab to it? Otherwise you probably need to write a whole thing to determine the monitor resolution and then click the link based on where it appears with that resolution.
User avatar
RobbieWilkes
Posts: 12
Joined: 27 Feb 2018, 21:52
Facebook: https://www.facebook.com/robbiewilkes

Re: Loading "cached" web pages in Chrome

06 Mar 2018, 15:41

MaxAstro wrote:Unfortunately I don't think there is a way to locate and click a link directly... If the relative position of the link doesn't change you might be able to tab to it? Otherwise you probably need to write a whole thing to determine the monitor resolution and then click the link based on where it appears with that resolution.


Thanks for responding MaxAstro. I was kinda guessing that might be the case, but hoped I'd find a direct solution in AHK. I'm guessing that, to accomplish what I'm trying to do, it would have to be in calling to something like a VB or javascript, since they can interface directly with Chrome, rather than just interact with it topically. Looks like I've got a lot of learning to do. :D

Much appreciated!
MaxAstro
Posts: 550
Joined: 05 Oct 2016, 13:00

Re: Loading "cached" web pages in Chrome  Topic is solved

08 Mar 2018, 11:04

Honestly if you can predict where the links will be in the tab order, tabbing to them might be a workable solution. If there is an area of the screen you can click to make sure there's no cursor focus (somewhere in the upper left that will be empty space at most resolutions), then you can establish a baseline for tabbing to the link.
User avatar
RobbieWilkes
Posts: 12
Joined: 27 Feb 2018, 21:52
Facebook: https://www.facebook.com/robbiewilkes

Re: Loading "cached" web pages in Chrome

08 Mar 2018, 12:25

MaxAstro wrote:Honestly if you can predict where the links will be in the tab order, tabbing to them might be a workable solution. If there is an area of the screen you can click to make sure there's no cursor focus (somewhere in the upper left that will be empty space at most resolutions), then you can establish a baseline for tabbing to the link.


Geez! Maybe if you hit me in the head with a hammer it would have CLICKED the first time you said it, but I was so focused on clicking, I didn't even test the TAB suggestion. DUH!

You're the man MaxAstro!!

Yes, I can tab between the options!! I just need to determine the best starting location on which to start tabbing, as the positions do change, once the video playback has been activated. It's not a severe change, but one that might cause clicking on the screen to activate something unintended.

There is a logo that sits on the same line as the options, and I'm currently playing with ImageSearch to try and use the found coordinates to act as a "hinge" from which to begin tabbing (or do nothing if not found aka on the video screen). Of course, I'm not having much luck with it right now, as the logo is a transparent .png and it's not finding it. :lol:

Code: [Select all] [Expand] [Download] (Untitled.ahk)GeSHi © Codebox Plus



I've even gone so far as to snip the logo from the screen itself, and saved as a jpg, thinking that would make it easier to find, but no luck.

Still, I am having fun learning more about AHK and trying out new functions that I have never played with before.

Thanks again for putting me on the right track!
MaxAstro
Posts: 550
Joined: 05 Oct 2016, 13:00

Re: Loading "cached" web pages in Chrome

08 Mar 2018, 12:50

Instead of using AHK's built in ImageSearch, I would suggest using the GDIP image search library. The code is complex, but well documented, and you basically just need to #include the files and then call the appropriate functions. The GDIP search is much faster and a LOT more flexible.

I've attached the two ahk files you'll need to include. You can Google something like "AHK GDIP" for examples.
Attachments
Gdip_ImageSearch.ahk
(32.59 KiB) Downloaded 3 times
Gdip_All.ahk
(95.45 KiB) Downloaded 3 times
MaxAstro
Posts: 550
Joined: 05 Oct 2016, 13:00

Re: Loading "cached" web pages in Chrome

08 Mar 2018, 12:51

Also. This might be silly, but considering the GDIP search is powerful: If the background of the site doesn't change, have you considered clipping out a picture of the link itself and image searching that?

And to save you some time searching, here's a quick example of what doing an image match with GDIP looks like:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Last edited by MaxAstro on 08 Mar 2018, 12:57, edited 1 time in total.
User avatar
gregster
Posts: 1190
Joined: 30 Sep 2013, 06:48

Re: Loading "cached" web pages in Chrome

08 Mar 2018, 12:55

Better use a lossless picture format like bmp or png than lossy jgp.
User avatar
RobbieWilkes
Posts: 12
Joined: 27 Feb 2018, 21:52
Facebook: https://www.facebook.com/robbiewilkes

Re: Loading "cached" web pages in Chrome

10 Mar 2018, 15:26

Well, I actually managed to find the image by taking both of your advice and saving a better quality snip.

Finds it perfectly, and I'm able to click on it, and use the coordinates as a reference point for other actions. :bravo:

But (isn't there ALWAYS a but) when the screen shifts down, following the start of the a video, it can't find it anymore... which makes absolutely zero sense to me. I mean, the only thing that has changed, as far as I can tell, are the Y coordinates. The associated link still works just fine, but ImageSearch just can't find it. :crazy:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus




I've pulled over the GDip libraries and have looked at your code MaxAstro, but I'm gonna need more coffee and reference code to understand how to implement. Thanks for the new avenues to try. I'm having fun... which is hard for my wife to understand when it's riddled with bursts of frustration. :lol:

Return to “Ask For Help”

Who is online

Users browsing this forum: No registered users and 11 guests