I am a real beginner with AHK , with no programming skill at all.
using AHK script ...
Code: Select all
#NoEnv
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#Persistent
#SingleInstance
If !FileExist("ahk-aria2.ini")
{
MsgBox, 64, ahk-aria2, Settings file ahk-aria2.ini not found , creating a new one.`nThen do not forget to enter Options in the tray menu to set them properly.
IniWrite, 0, ahk-aria2.ini, Paths, aria2
IniWrite, 0, ahk-aria2.ini, Paths, webui
}
IniRead, Aria2Path, ahk-aria2.ini, Paths, aria2
IniRead, WebUIPath, ahk-aria2.ini, Paths, webui
IfNotExist, %Aria2Path%
{
MsgBox, 65, ahk-aria2, aria2c.exe not found , download available there : http://sourceforge.net/projects/aria2/files/stable/aria2-1.18.7/`n`nDo you want to get the latest stable build right now ?
IfMsgBox OK
MsgBox, 36, ahk-aria2, Get the x64 build ? ( answer No will let you get the x32 build )`nZip file containing the executable will be available in ahk-aria2 directory.
IfMsgBox Yes
UrlDownloadToFile, http://sourceforge.net/projects/aria2/files/stable/aria2-1.18.7/aria2-1.18.7-win-64bit-build1.zip/download, aria2c_win64.zip
IfMsgBox No
UrlDownloadToFile, http://sourceforge.net/projects/aria2/files/stable/aria2-1.18.7/aria2-1.18.7-win-32bit-build1.zip/download, aria2c_win32.zip
}
IfNotExist, %WebUIPath%
{
MsgBox, 36, ahk-aria2, ziahamza/webui-aria2 not found , download available there : https://github.com/ziahamza/webui-aria2`n`nDo you want to get the latest stable release right now ?`nZip file containing the webUI will be available in ahk-aria2 directory.
IfMsgBox Yes
UrlDownloadToFile, https://github.com/ziahamza/webui-aria2/archive/master.zip, webui.zip
}
Destination = %A_MyDocuments%
Threads = 2
Menu, Tray, NoStandard
Menu, Tray, add, Add URL, ShowMainGui
Menu, Tray, add
Menu, Tray, add, Settings, ShowSettingsGui
Menu, Tray, add, Launch Aria2, LaunchAria2
Menu, Tray, add, Close Aria2, CloseAria2
Menu, Tray, add, Launch Web-UI, LaunchWebUI
Menu, Tray, add
Menu, Tray, add, Exit, AhkAria2Close
UpdateTray_Aria2_ON()
{
Menu, Tray, disable, Launch Aria2
Menu, Tray, enable, Close Aria2
Menu, Tray, enable, Launch Web-UI
}
UpdateTray_Aria2_OFF()
{
Menu, Tray, enable, Launch Aria2
Menu, Tray, disable, Close Aria2
Menu, Tray, disable, Launch Web-UI
}
Process, Exist, aria2c.exe
Aria2PID = %ErrorLevel%
If (%Aria2PID% = 0)
{
UpdateTray_Aria2_OFF()
}
else
{
UpdateTray_Aria2_ON()
}
return
ShowMainGui:
{
Gui, New
Gui, Add, Edit, x16 y34 w410 h20 vDownloadLink gDownloadLink, Paste URL here !
Gui, Add, DropDownList, x176 y74 w40 h10 R5 vThreads gThreads, 1|2||3|4|5|6|7|8|9|10|11|12
Gui, Add, Radio, x26 y114 w120 h30 Group Checked gDefaultDestination, My Documents
Gui, Add, Radio, x26 y154 w120 h30 gDestination, Open folder
Gui, Add, DropDownList, x176 y114 w150 h10 R5 vCategory gCategory, Archives|Video|Audio|Programs|Misc
Gui, Add, Button, x310 y150 w100 h30 gDownload, DOWNLOAD
Gui, Add, ListBox, x6 y184 w430 h90 ReadOnly +HScroll vListBox
Gui -Resize -MaximizeBox +MinimizeBox
; Generated using SmartGUI Creator for SciTE
Gui, Show, w445 h280 , ahk-aria2
return
}
ShowSettingsGui:
{
Gui, New
Gui, Add, Button, x16 y14 w400 h30 gAria2PathConfig, Aria2c
Gui, Add, Button, x16 y94 w400 h30 gWebUIPathConfig, WebUI
Gui, Add, Edit, x16 y54 w400 h20 ReadOnly vAria2Path
Gui, Add, Edit, x16 y134 w400 h20 ReadOnly vWebUIPath
; Generated using SmartGUI Creator for SciTE
Gui, Show, w434 h186, ahk-aria2 Settings
IniRead, Aria2Path, ahk-aria2.ini, Paths, aria2
IniRead, WebUIPath, ahk-aria2.ini, Paths, webui
GuiControl,, Aria2Path, %Aria2Path%
GuiControl,, WebUIPath, %WebUIPath%
return
}
Aria2PathConfig:
{
FileSelectFile, Aria2Path, 1, aria2c.exe, Select aria2c executable, (*.exe)
GuiControl,, Aria2Path, %Aria2Path%
IniWrite, %Aria2Path%, ahk-aria2.ini, Paths, aria2
return
}
WebUIPathConfig:
{
FileSelectFile, WebUIPath, 1, index.html, Select webUI startpage file, (*.html)
GuiControl,, WebUIPath, %WebUIPath%
IniWrite, %WebUIPath%, ahk-aria2.ini, Paths, webui
return
}
LaunchAria2:
{
IniRead, Aria2Path, ahk-aria2.ini, Paths, aria2
IfNotExist, %Aria2Path%
{
MsgBox, 16, ahk-aria2, Please specify aria2 directory path `in the settings.`n
}
IfExist, %Aria2Path%
{
Run, %Aria2Path% --enable-rpc --rpc-listen-all,, Min, Aria2PID
UpdateTray_Aria2_ON()
}
return
}
CloseAria2:
{
Process, Close, %Aria2PID%
UpdateTray_Aria2_OFF()
return
}
LaunchWebUI:
{
IniRead, WebUIPath, ahk-aria2.ini, Paths, webui
IfNotExist, %WebUIPath%
{
MsgBox, 16, ahk-aria2, Please specify webUI directory path `in the settings.`n
}
IfExist, %WebUIPath%
{
Run, %WebUIPath%,, Max
}
return
}
DownloadLink:
{
Gui, Submit, NoHide
FormatTime, Time,, HH:mm:ss
GuiControl,, ListBox, %Time% - Download link set to %DownloadLink%||
return
}
Threads:
{
Gui, Submit, NoHide
FormatTime, Time,, HH:mm:ss
GuiControl,, ListBox, %Time% - Number of threads set to %Threads%||
return
}
Destination:
{
Gui, Submit, NoHide
FileSelectFolder, Destination,, 3
GuiControl,, ListBox, %Time% - Destination folder set to %Destination%||
return
}
DefaultDestination:
{
Gui, Submit, NoHide
Destination = %A_MyDocuments%
GuiControl,, ListBox, %Time% - Destination folder set to %Destination%||
return
}
Category:
{
Gui, Submit, NoHide
FormatTime, Time,, HH:mm:ss
GuiControl,, ListBox, %Time% - Download category changed : %Category%||
return
}
Download:
{
IniRead, Aria2Path, ahk-aria2.ini, Paths, aria2
If !Destination
{
MsgBox, ERROR
}
; MsgBox, %Aria2Path% -x %Threads% -d %Destination% --file-allocation=none %DownloadLink%
Run, %Aria2Path% -x %Threads% -d %Destination% --file-allocation=none %DownloadLink%
return
}
AhkAria2Close:
ExitApp
As you can see it is ugly. And probably there are some bugs and bad use of a lot of things.
- Check for INI and settings , proposing the download of aria and webui if not found.
But of course with my knowledge , no JSON or other libs. And there was absolutely no "output" from
inside the script as your code provide ( love the progress bar and all the timers info !! )
Thanks again for sharing ! I will try to understand ( and eventually learn ) the most i can.
Will add minor features from mine to your nice piece of art.