Code: Select all
;- user mikeyww
;-------- saved at 星期六 十一月 2020-11-14 22:15 UTC --------------
;- How to auto decide close cmd window or not based on results after running?
;- https://www.autohotkey.com/boards/viewtopic.php?f=76&t=83172
;url=https://www.youtube.com/watch?v=G6_DldYj0u ;- URL wrong
url=https://www.youtube.com/watch?v=G6_DldYj0uQ ;- URL Li Xiang Lan
app = youtube-dl.exe ; Your own path here
Clipboard =
SplashTextOn, 700, 100, Downloading %url%, `nPlease wait....
RunWait, %ComSpec% /c %app% %url% 2>&1 |clip,,hide
SplashTextOff
ClipWait, 2
If ErrorLevel
MsgBox, 48, Error, An error occurred while waiting for the clipboard.
Else MsgBox, 64, Clipboard, %Clipboard%
;fileappend,%clipboard%,test21.txt
ExitApp
;------------------------
/*
ERROR: Incomplete YouTube ID G6_DldYj0u. URL https://www.youtube.com/watch?v=G6_DldYj0u looks truncated.
;- or if OK :
[youtube] G6_DldYj0uQ: Downloading webpage
[download] Destination: Ye Lai Xiang-G6_DldYj0uQ.mp4
[download] 0.0% of 5.74MiB at Unknown speed ETA Unknown ETA
[download] 0.1% of 5.74MiB at Unknown speed ETA Unknown ETA
[download] 0.1% of 5.74MiB at 448.03KiB/s ETA 00:13
[download] 0.3% of 5.74MiB at 960.06KiB/s ETA 00:06
[download] 0.5% of 5.74MiB at 1.94MiB/s ETA 00:02
[download] 1.1% of 5.74MiB at 3.94MiB/s ETA 00:01
[download] 2.2% of 5.74MiB at 3.96MiB/s ETA 00:01
[download] 4.3% of 5.74MiB at 7.95MiB/s ETA 00:00
[download] 8.7% of 5.74MiB at 2.28MiB/s ETA 00:02
[download] 17.4% of 5.74MiB at 2.37MiB/s ETA 00:02
[download] 34.8% of 5.74MiB at 2.72MiB/s ETA 00:01
[download] 69.7% of 5.74MiB at 2.61MiB/s ETA 00:00
[download] 100.0% of 5.74MiB at 2.59MiB/s ETA 00:00
[download] 100% of 5.74MiB in 00:02
*/
;=================================================================
meanwhile I tried a complicated script ...
Code: Select all
modified = 20201114
created = 20201114
;-- example youtube-dl.exe / copy to EDIT
;------------------------------------------------
#Warn
#Noenv
setworkingdir,%a_scriptdir%
settitlematchmode,2
Gui,2: +HwndGui
Gui,2:default
Gui,2: -DPIScale
Gui,2:color,black,black
Gui,2:Font,s12 cYellow,Lucida Console
DetectHiddenWindows On
wa:=A_screenwidth,ha:=A_screenHeight,xx:=100
;------------
filename1=YOUTUBE-DL.exe TEST
youtubedl:=a_scriptdir . "\youtube-dl.exe" ;<<< youtube-dl.exe in a_scriptdir
fdmp4:=a_desktop . "\M_VIDEO" ;<<< save videos here
ifnotexist,%fdmp4%
filecreatedir,%fdmp4%
ifexist,%youtubedl%
{
loop,%youtubedl%
SP1:=A_loopFileShortPath
;RunWait, %comspec% /k %sp1% -U ;- Update youtube-dl.exe
}
else
{
run,https://youtube-dl.org/latest/youtube-dl.exe
return
}
var=https://www.youtube.com/watch?v=G6_DldYj0uQ ;- URL Li Xiang Lan
x:=(wa*1)/xx,y:=(ha*1)/xx,h:=(ha*3)/xx,w:=(wa*70)/xx
Gui,2:Add, Edit , x%x% y%y% h%h% w%w% vVAR ,%VAR%
x:=(wa*72)/xx,y:=(ha*1)/xx,h:=(ha*2.5)/xx,w:=(wa*5)/xx
Gui,2:Add, Button, x%x% y%y% w%w% h%h% gSTART1,Start
x:=(wa*1)/xx,y:=(ha*10)/xx,h:=(ha*50)/xx,w:=(wa*70)/xx
Gui,2:Add,Edit, x%x% y%y% h%h% w%w% vED1 cYellow,
Gui,2:add,Text,x0 y0 w0 h0 vTT
x:=(wa*.1)/xx,y:=(ha*.1)/xx,h:=(ha*70)/xx,w:=(wa*80)/xx
Gui,2:Show, x%x% y%y% w%w% h%h% ,%filename1%
GuiControl,2:Focus,TT
return
;----------------------------------------------
2Guiescape:
2Guiclose:
xx=youtube-dl.exe
process,exist,%xx%
pps:=errorlevel
if pps<>0
Process, Close, %pid2%
exitapp
;----------------------------------------------
start1:
gui,2:submit,nohide
GuiControl,2:,ED1,
settimer,aa,900
;-------------
cmd=%sp1% %var% --verbose --youtube-skip-dash-manifest --write-auto-sub --sub-lang de -o "%fdmp4%\`%(title)s$`%(uploader)s$`%(id)s.`%(ext)s"
RunWait,%cmd%,,hide,pid2
;RunWait,%comspec% /k %cmd%,,,pid2 ;-- see original window
;-------------
sleep,2000
settimer,aa,off
try
run,%fdmp4%
return
;----------------------------------------------
aa:
gui,2:submit,nohide
WinActivate ahk_pid %PID2%
send,^a{Enter} ;- <<< copy hidden DOS Windows-10
ClipWait,1,1
GuiControl,2:,ED1,%Clipboard%
ControlSend, Edit2,^{end}, ahk_id %Gui%
return
;=========== END youtube-dl.exe ========================================