meterion

Autohotkey Online Reader Autodownload Macro

Apr 22nd, 2017
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.44 KB | None | 0 0
  1. ; Simply install Autohotkey (https://autohotkey.com/download/), save this file as whatever.ahk, and double click.
  2. ; A macro for when there are no download links available; takes care of opening images in new tabs and downloading them.
  3. ; visual instructions here: https://imgur.com/a/y85KT
  4.  
  5. ; README
  6. ; A very hacky AutoHotKey macro by meterion for idle downloading
  7. ; To use properly, save the page 1 image to the desired directory before starting the macro
  8. ; This is needed to set the save directory for the rest of the images
  9. ; Page 1 is then omitted from the macro so there is no need to delete it from the directory
  10. ; Press Ctrl+k from page 1 and follow the input prompts to begin
  11. ; Beeps and displays a dialogue box upon completion
  12. ; Note: Rename Files won't rename the file you manually downloaded
  13. ; Speed: ~1.5 minutes per 20 pages
  14. ; Press Ctrl+y for extra beeps lol (don't do it while it's running tho)
  15.  
  16. pageDelay := 3000 ; Conservative ms delay to load pages
  17. saveDelay := 1000 ; Faster ms delay when waiting for dialogue window
  18. winDelay := 100 ; Fastest ms delay within windows
  19. CoordMode, Mouse, Relative
  20. SetMouseDelay, 0
  21.  
  22. tones := [131, 139, 147, 156, 165, 175, 185, 196, 208, 220, 233, 247, 262, 277, 294, 311, 330, 349, 370, 392, 415, 440, 466, 494, 523, 554, 587, 622, 659, 698, 740, 784, 831, 880, 932, 988, 1047, 1109, 1175, 1245, 1319, 1397, 1480, 1568, 1661, 1760, 1865, 1976]
  23.  
  24. setFormat, IntegerFast, d
  25.  
  26. ^y::
  27. Random, toneStart, 1, 40
  28. Random, jumpOne, 3, 4
  29. Random, jumpTwo, 3, 4
  30.  
  31. SoundBeep, tones[ToneStart], 150
  32. SoundBeep, tones[ToneStart + jumpOne], 150
  33. SoundBeep, tones[ToneStart + jumpOne + jumpTwo], 150
  34. return
  35.  
  36. ^k:: ; You set the save directory, right?
  37. WinGetActiveStats, Title, Width, Height, X, Y
  38. winXClick := Width/2
  39. winYClick := Height/2
  40. winXSClick := winXClick + 50
  41. winYSClick := winYClick + 150
  42.  
  43. InputBox, pageNumber, Number of Pages to Download, Please enter the total page NUMBER
  44. if Errorlevel ; cancel out of download
  45. {
  46. MsgBox, , Autodownload Cancelled, Download successfully cancelled
  47. return
  48. }
  49. minNumber := pageNumber - 1 ; modified value for image loop
  50. Sleep, winDelay
  51.  
  52. MsgBox, 260, Rename Files, Press Yes to rename files starting at 002
  53. IfMsgBox, Yes ; Defaults to "No"
  54. {
  55. numRename := 1
  56. }
  57.  
  58. Sleep, saveDelay ; allow for user to lift hand from keys
  59.  
  60. Loop, %minNumber% ; First page is being done out of macro, so -1
  61. {
  62. Click, %winXClick%, %winYClick% ; Advance page
  63. Sleep, pageDelay
  64. Click, %winXClick%, %winYClick%, right ; Right Click
  65. Sleep, winDelay
  66. Click, %winXSClick%, %winYSClick% ; Open image in new tab
  67. Sleep, winDelay
  68. } ; Done opening images, now saving
  69.  
  70. Send, ^{Tab} ; move to image tabs
  71. Sleep, winDelay
  72. Loop, %minNumber% ; First page is being done out of macro, so -1
  73. {
  74. Send, ^s ; enter save dialogue
  75. Sleep, saveDelay
  76.  
  77. IfMsgBox, Yes
  78. {
  79. numRename := ++numRename
  80. numSend := SubStr("00" . numRename, -2)
  81. Send, %numSend%
  82. Sleep, winDelay
  83. }
  84.  
  85. Send, {Enter} ; save image
  86. Sleep, winDelay
  87. Send, ^w ; advance tab
  88. Sleep, winDelay
  89. }
  90. Random, toneStart, 1, 40
  91. Random, jumpOne, 3, 4
  92. Random, jumpTwo, 3, 4
  93.  
  94. SoundBeep, tones[ToneStart], 150
  95. SoundBeep, tones[ToneStart + jumpOne], 150
  96. SoundBeep, tones[ToneStart + jumpOne + jumpTwo], 150
  97. MsgBox, 0, Autosave Completed, %pageNumber% pages downloaded.
  98. return
Add Comment
Please, Sign In to add comment