Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Simply install Autohotkey (https://autohotkey.com/download/), save this file as whatever.ahk, and double click.
- ; A macro for when there are no download links available; takes care of opening images in new tabs and downloading them.
- ; README
- ; A hacky AutoHotKey macro by meterion for idle downloading
- ; To use: Navigate to page 1 of desired gallery. Press Ctrl+q.
- ; Follow the prompt, leave computer alone as it does its thing (currently cannot function in background).
- ; Speed: ~1.5 minutes per 20 pages
- ; Press Ctrl+i for extra beeps lol (don't do this while it's running tho)
- ; NOTE: Makes an .ini file in the same directory it's used called "autosaversettings.ini"
- pageDelay := 3000 ; Conservative ms delay to load pages
- saveDelay := 1000 ; Faster ms delay when entering/exiting dialogue window
- numPages = 0 ; Number of pages set to download: 0 by default
- 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]
- ; ^Chromatic tones for when it finishes
- CoordMode, Mouse, Relative
- SetMouseDelay, 5
- setFormat, IntegerFast, d
- ^q::
- Gui, Name: New, , Online Reader Autodownloader by meterion
- GUI, Add, Button, x10 w380 h20 gstartButton, Select a folder in which to download images
- IniRead, folderStart, autosaversettings.ini, User Settings, iniStart, %A_Space% ; Reads ini file for previously set download location
- if(folderStart)
- {
- GUI, Add, Text, x10 r2 w400 vupdateStart, Images will be downloaded to: `n%folderStart%
- }
- else
- {
- GUI, Add, Text, x10 r2 w400 vupdateStart, There is no download folder selected
- }
- Gui, Add, Checkbox, vrenamePages, Check to numerically rename files starting at 001
- Gui, Add, Edit, x10 w50 vnumPages Number ; Set number of pages to download here
- Gui, Add, UpDown, gPagebutton, %numPages%
- Gui, Add, Button, x+m yp w320 h20 gpageButton, Enter number of pages to download
- Gui, Add, Text, x10 w300 vpageText, %numPages% pages to download
- GUI, Add, Button, x10 w380 h40 gdownloadButton, Begin Downloading
- GUI, Add, Button, x10 y+20 w380 h20 gfavoriteButton, Select a default folder from which to browse download folder
- IniRead, folderFavorite, autosaversettings.ini, User Settings, iniFavorite, %A_Space%
- if(folderFavorite) ; Same as above for a set default location
- {
- GUI, Add, Text, x10 r2 w400 vupdateFavorite, Current default folder is: `n%folderFavorite%
- }
- else
- {
- GUI, Add, Text, x10 r2 w400 vupdateFavorite, There is no current default folder selected
- }
- Gui, Show, W400 H250 Center, Online Reader Autodownloader by meterion
- return
- startButton: ; Brings up folder select, saves download folder path to ini file, updates GUI
- IniRead, folderFavorite, autosaversettings.ini, User Settings, iniFavorite, %A_Space%
- FileSelectFolder, toIniStart, *%folderFavorite%, 3, Choose where to save images
- IniWrite, %toIniStart%, autosaversettings.ini, User Settings, iniStart
- folderStart := toIniStart
- GuiControl, , updateStart, Images will be downloaded to: `n%folderStart%
- return
- pageButton: ; Need to submit value from GUI because the variable isn't being created here
- Gui, Submit, noHide
- GuiControl, , pageText, %numPages% pages to download
- return
- favoriteButton: ; As above for the default folder path
- FileSelectFolder, toIniFavorite, *%folderFavorite%, 3, Choose a Preferred Default Folder
- IniWrite, %toIniFavorite%, autosaversettings.ini, User Settings, iniFavorite
- folderFavorite := toIniFavorite
- Guicontrol, , updateFavorite, Current default folder is: `n%folderFavorite%
- return
- downloadButton: ; Where the magic happens
- Gui, Submit
- Gui, Destroy ; Ensures proper window is active
- WinGetActiveStats, Title, Width, Height, X, Y
- winXClick := Width/2 ; X/Y coords for where image probably is (top 1/3 of screen in the middle). If you have a lot of toolbars this probably has to be adjusted.
- winYClick := Height/3
- winXSClick := winXClick + 50 ; X/Y coords for where relative "Save Image As..." right-click dialogue is on Chrome. Probably has to be adjusted for other browsers/extensions installed.
- winYSClick := winYClick + 175
- loopNumber := numPages - 1 ; Since first page is downloaded out of loop, loopNumber is 1 less than page number
- numRename :=0 ; If rename option is selected, this will be used later. If it was used before, it will be reset to 0 now.
- Sleep, saveDelay ; allow for user to lift hand from keyboard/mouse
- Click, %winXClick%, %winYClick%, right ; Opening first page
- Click, %winXSClick%, %winYSClick% ; Save Image As
- Sleep, saveDelay
- if renamePages = 1 ; This code renames the image and is reused below, which is why it begins by iterating numRename to 1. It changes to numSend to properly return "009" instead of "9", etc.
- {
- numRename := ++numRename
- numSend := SubStr("00" . numRename, -2)
- Send, %numSend%
- Sleep, 100
- }
- Send, {F4} ; This brings you to the filepath edit box in chrome. Might need to be adjusted for other browsers.
- Send, ^a
- SendRaw, %folderStart% ; Enters directory from initial GUI
- loop, 4
- {
- Send, {Enter} ; It takes many enters to go from filepath edit to confirming image save. Might need to be adjusted for other browsers. Can cause issues without the delay.
- sleep, 100
- }
- Sleep, saveDelay
- Loop, %loopNumber% ; Now loops the rest of the pages
- {
- Click, %winXClick%, %winYClick% ; Advance page
- Sleep, pageDelay ; Page Loading Time
- Click, %winXClick%, %winYClick%, right ; Right Click
- Click, %winXSClick%, %winYSClick% ; Save Image As
- Sleep, saveDelay ; Save dialogue loading time
- if renamePages = 1 ; See above note for info
- {
- numRename := ++numRename
- numSend := SubStr("00" . numRename, -2)
- Send, %numSend%
- Sleep, 100
- }
- Send, {Enter} ; Save Image
- Sleep, saveDelay ; Needs some buffer time for the dialogue to exit before starting loop
- }
- Random, toneStart, 1, 40 ; This part just plays a short chord and loads a dialogue box to show completion
- Random, jumpOne, 3, 4
- Random, jumpTwo, 3, 4
- SoundBeep, tones[ToneStart], 150
- SoundBeep, tones[ToneStart + jumpOne], 150
- SoundBeep, tones[ToneStart + jumpOne + jumpTwo], 150
- MsgBox, 0, Autosave Completed, %numPages% pages downloaded.
- return
- ^i:: ; If you just want to play tones (could probably be compressed in a function but whatever it's only used twice)
- Random, toneStart, 1, 40
- Random, jumpOne, 3, 4
- Random, jumpTwo, 3, 4
- SoundBeep, tones[ToneStart], 150
- SoundBeep, tones[ToneStart + jumpOne], 150
- SoundBeep, tones[ToneStart + jumpOne + jumpTwo], 150
- return
Add Comment
Please, Sign In to add comment