0

I have a list of URLs for recipes that I want to save as PDFs before my subscription to the site runs out. A friend wrote an AutoHotKey script that will take the URLs and use the Print to PDF option in Chrome, but there are problems with this. Apart from making my computer unusable while it's running since the script needs to control the mouse, it often stops working correctly by somehow trying to save the same URL twice even though there are no duplicate links.

Below is the script which I tweaked to have an extra step and be a tad quicker

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

Loop, read, %A_ScriptDir%\CookSpread.txt

{
StringSplit, LineArray, A_LoopReadLine, %A_Tab%
  URL := LineArray1

Run, %URL%

Sleep 6000
Click 1500, 550
Sleep 500
Click 1480, 220
Sleep 3000
Send {Enter}
Sleep 1000
Send {Enter}
Sleep 1000
Send ^{F4}
Sleep 2000

}

Below is what my friend provided. I shortened some of the times, added an extra click at the start of the loop to click on the nutrition info inclusion option, and added the second Enter to hit save in the Save to PDF dialogue box that comes up in Chrome.

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.


Loop, read, %A_ScriptDir%\CookSpread.txt

{
StringSplit, LineArray, A_LoopReadLine, %A_Tab%
  URL := LineArray1


Run, %URL%

Sleep 7000

Click 3407, 241
Sleep 3000
Send {Enter}
Sleep 7000

Send ^{F4}
Sleep 4000

}

I am wondering if one of the problems I am running into is that the times that I adjusted are not long enough.

Any help would be appreciated, or any suggestions for a better way to do this so that the computer can still be used while this is going on would be fantastic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.