URL Download to File not working

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
clarkj0388
Posts: 13
Joined: 11 Aug 2022, 18:50

URL Download to File not working

Post by clarkj0388 » 11 Feb 2023, 23:04

Hi all,

Can someone come up with another solution to download the PNG generated by this URL?

https://www.google.com/maps/vt/data=9KZ ... =200&w=652

Seems it's dynamically generated, so URLDownloadtoFile doesn't seem to be working.

The only solution I came up with would be to pop open the browser, let it render then send CTRL S... but I'd love to do it in the background.

Any thoughts???

User avatar
flyingDman
Posts: 2848
Joined: 29 Sep 2013, 19:01

Re: URL Download to File not working

Post by flyingDman » 11 Feb 2023, 23:34

It works fine here:

Code: Select all

url := "https://www.google.com/maps/vt/data=9KZnDfCpPlvTU8liZSxRK68iPgkpi9GbpD2FYCu5E0ZDk38075U0gI7qkeyXnksU1tgsFuLu3sa0b2uT_d87J6zH8Jque0tCB2Zz3m2g5ECC1R6oXlB65pD6zoerLOEc_wa_V-gCPfFgLBsF54iPUz0S6hDMh8FhON_qdm-l,9QY-qAGDoGYenT4VpxyK99_2EdBJhiV33wqM88e8G-rUb3PjERXM1G1kXsPSZajXT9rdIsiDrL2uCFU0gtEvyDmU7oBKMNYc26wVv4hrJiHC7AiLniIL0HW8Jnh7IuOGza0hrrefT6GLccqwz-XoIcOA6JAFn3FwYRo9AWFxDtOHliX1Zfb12utHjjhDcuRYTkd3DwvbVxZ0gCdDtjBHogrJ9QtpP-A9na3zlGEmQ75J7emq2G1x-qye7ejGizzQzu_xWWAPb9fwj7MYISmU4X7pJebod3gk1nZWrr4yC_pppb0tFsf36Qp-_-IaxgpoSnbbu1qgxSg?scale=1&h=200&w=652"

urldownloadtofile,%url%,map.png
run, map.png
14.3 & 1.3.7

clarkj0388
Posts: 13
Joined: 11 Aug 2022, 18:50

Re: URL Download to File not working

Post by clarkj0388 » 12 Feb 2023, 00:03

Yes it does. Thanks.

I wonder why passing it in as a var makes a difference over this:

Code: Select all

UrlDownloadToFile, "https://www.google.com/maps/vt/data=9KZnDfCpPlvTU8liZSxRK68iPgkpi9GbpD2FYCu5E0ZDk38075U0gI7qkeyXnksU1tgsFuLu3sa0b2uT_d87J6zH8Jque0tCB2Zz3m2g5ECC1R6oXlB65pD6zoerLOEc_wa_V-gCPfFgLBsF54iPUz0S6hDMh8FhON_qdm-l,9QY-qAGDoGYenT4VpxyK99_2EdBJhiV33wqM88e8G-rUb3PjERXM1G1kXsPSZajXT9rdIsiDrL2uCFU0gtEvyDmU7oBKMNYc26wVv4hrJiHC7AiLniIL0HW8Jnh7IuOGza0hrrefT6GLccqwz-XoIcOA6JAFn3FwYRo9AWFxDtOHliX1Zfb12utHjjhDcuRYTkd3DwvbVxZ0gCdDtjBHogrJ9QtpP-A9na3zlGEmQ75J7emq2G1x-qye7ejGizzQzu_xWWAPb9fwj7MYISmU4X7pJebod3gk1nZWrr4yC_pppb0tFsf36Qp-_-IaxgpoSnbbu1qgxSg?scale=1&h=200&w=652", LAX.png

clarkj0388
Posts: 13
Joined: 11 Aug 2022, 18:50

Re: URL Download to File not working

Post by clarkj0388 » 12 Feb 2023, 00:05

and yes... I've tried it without the quotes as well...

Code: Select all

UrlDownloadToFile, https://www.google.com/maps/vt/data=9KZnDfCpPlvTU8liZSxRK68iPgkpi9GbpD2FYCu5E0ZDk38075U0gI7qkeyXnksU1tgsFuLu3sa0b2uT_d87J6zH8Jque0tCB2Zz3m2g5ECC1R6oXlB65pD6zoerLOEc_wa_V-gCPfFgLBsF54iPUz0S6hDMh8FhON_qdm-l,9QY-qAGDoGYenT4VpxyK99_2EdBJhiV33wqM88e8G-rUb3PjERXM1G1kXsPSZajXT9rdIsiDrL2uCFU0gtEvyDmU7oBKMNYc26wVv4hrJiHC7AiLniIL0HW8Jnh7IuOGza0hrrefT6GLccqwz-XoIcOA6JAFn3FwYRo9AWFxDtOHliX1Zfb12utHjjhDcuRYTkd3DwvbVxZ0gCdDtjBHogrJ9QtpP-A9na3zlGEmQ75J7emq2G1x-qye7ejGizzQzu_xWWAPb9fwj7MYISmU4X7pJebod3gk1nZWrr4yC_pppb0tFsf36Qp-_-IaxgpoSnbbu1qgxSg?scale=1&h=200&w=652, LAX10.png
Stumped.

Thanks for helping me through it.

User avatar
boiler
Posts: 17404
Joined: 21 Dec 2014, 02:44

Re: URL Download to File not working

Post by boiler » 12 Feb 2023, 01:48

You have syntax issues in both cases. In the first case, you have a quoted string as if it were an expression, but that parameter doesn’t take expressions unless you force an expression:

Code: Select all

 UrlDownloadToFile, % "https://www.google.com/maps/vt/data=9KZnDfCpPlvTU8liZSxRK68iPgkpi9GbpD2FYCu5E0ZDk38075U0gI7qkeyXnksU1tgsFuLu3sa0b2uT_d87J6zH8Jque0tCB2Zz3m2g5ECC1R6oXlB65pD6zoerLOEc_wa_V-gCPfFgLBsF54iPUz0S6hDMh8FhON_qdm-l,9QY-qAGDoGYenT4VpxyK99_2EdBJhiV33wqM88e8G-rUb3PjERXM1G1kXsPSZajXT9rdIsiDrL2uCFU0gtEvyDmU7oBKMNYc26wVv4hrJiHC7AiLniIL0HW8Jnh7IuOGza0hrrefT6GLccqwz-XoIcOA6JAFn3FwYRo9AWFxDtOHliX1Zfb12utHjjhDcuRYTkd3DwvbVxZ0gCdDtjBHogrJ9QtpP-A9na3zlGEmQ75J7emq2G1x-qye7ejGizzQzu_xWWAPb9fwj7MYISmU4X7pJebod3gk1nZWrr4yC_pppb0tFsf36Qp-_-IaxgpoSnbbu1qgxSg?scale=1&h=200&w=652", LAX.png

In the second case where you don’t have quotes around it and would otherwise be correct legacy syntax, the string contains a comma, so it must be escaped or else it sees what follows it as belonging to the next parameter:

Code: Select all

UrlDownloadToFile, https://www.google.com/maps/vt/data=9KZnDfCpPlvTU8liZSxRK68iPgkpi9GbpD2FYCu5E0ZDk38075U0gI7qkeyXnksU1tgsFuLu3sa0b2uT_d87J6zH8Jque0tCB2Zz3m2g5ECC1R6oXlB65pD6zoerLOEc_wa_V-gCPfFgLBsF54iPUz0S6hDMh8FhON_qdm-l`,9QY-qAGDoGYenT4VpxyK99_2EdBJhiV33wqM88e8G-rUb3PjERXM1G1kXsPSZajXT9rdIsiDrL2uCFU0gtEvyDmU7oBKMNYc26wVv4hrJiHC7AiLniIL0HW8Jnh7IuOGza0hrrefT6GLccqwz-XoIcOA6JAFn3FwYRo9AWFxDtOHliX1Zfb12utHjjhDcuRYTkd3DwvbVxZ0gCdDtjBHogrJ9QtpP-A9na3zlGEmQ75J7emq2G1x-qye7ejGizzQzu_xWWAPb9fwj7MYISmU4X7pJebod3gk1nZWrr4yC_pppb0tFsf36Qp-_-IaxgpoSnbbu1qgxSg?scale=1&h=200&w=652, LAX.png

If you switch to AHK v2, you can avoid all the expression vs. legacy syntax confusion because expressions are used throughout.

Post Reply

Return to “Ask for Help (v1)”