Advertisement
Najeebsk

VLC-PLAYER2.ahk

Mar 22nd, 2023 (edited)
1,687
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*   INFO
  2.    VLC VIDEOS PLAYER
  3.    Written by: Najeeb Shah Khan (najeebshahkhan@gmail.com)
  4.    Last Modified: 3-20-2023
  5.    ESC to STOP/PLAY  > minimize / maximize
  6. */
  7. ;#warn
  8. #NoEnv
  9. #SingleInstance, Force
  10. Process, Priority, , A
  11. SendMode, Input
  12. SetTitleMatchMode,2
  13. SetBatchLines, -1
  14. ;#NoTrayIcon
  15. SetWorkingDir %A_ScriptDir%  
  16. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  17. FileCreateDir, %A_ScriptDir%\DATA
  18. FileSetAttrib +HS, %A_ScriptDir%\DATA, 2
  19. FileInstall , VLC-PLAYER2.ahk, %A_ScriptDir%\DATA\VLC-PLAYER2.ahk, 1
  20. FileSetAttrib +HS, %A_ScriptDir%\DATA\VLC-PLAYER2.ahk, 2
  21. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  22. wa:=A_screenwidth,ha:=A_screenHeight,xx:=100
  23. fontsize1=12
  24. Gui,2:default
  25. Gui,2: +HwndAId  +0x2000000  ; +WS_CLIPCHILDREN Fixes drawing problems with child.
  26. Gui,2: -DPIScale hwndUID
  27. SS_REALSIZECONTROL := 0x40
  28. Gui,2:Color,Black,Black
  29. ;Gui,2:Font,s%fontsize1% cGray,Lucida Console
  30. Gui,2: Font, s9, Lucida Console
  31. stringmid,datex,a_now,1,10
  32. global C2,T2
  33. ;-
  34. Name1=NAJEEB PLAY_VLC_ACTIVE-X_MP3_MP4_PICTURE
  35. ;-
  36. ;======================================================
  37. hotkey, IfWinActive,%name1% ahk_class AutoHotkeyGUI
  38. Hotkey,SPACE,pause1,ON
  39.  
  40. hotkey, IfWinExist,%name1% ahk_class AutoHotkeyGUI
  41. hotkey,ESC,aabb        
  42.  
  43. ;======================================================  
  44.  
  45. ;-------------------------------------------
  46. editorx1=C:\Program Files\Notepad++\notepad++.exe
  47. ifnotexist,%editorx1%
  48.   editorx1:=""
  49. vlc1  =%A_programfiles%\VideoLAN\VLC\vlc.exe    ;- VLC should be installed for ActiveX
  50. dlm:=";"
  51. ;-
  52. FDMusic    :="D:\VIDEOS\MP3"   ;- Folder Music
  53. FDVideo    :="D:\VIDEOS\SONGS"     ;- Folder Video
  54. FDPictures :="D:\TOOLS\WALLP"          ;- Folder Pictures for random pictures used for audio-file which not contains thumbnail-picture
  55. ;-
  56. videoextensions   :="flv,vob,mp4,mpg,wmv,avi,webm,m4a,mp3,wma,ogg,m3u,m3u8"
  57. musicextensions   :="mp3,wav,aac,flac,aif,ogg"
  58. picturesextensions:="jpg,bmp,png"
  59. ;-
  60. ;---------------------
  61. RSSINI=%A_scriptdir%\%name1%_RSSINI.txt
  62. ifnotexist,%rssini%
  63.     {
  64.     xxca:="https://mediandr-a.akamaihd.net/download/podcasts/extradrei196/TV-20210108-1424-4800.hi.mp4"
  65.     IniWrite,%xxca%  , %rssini%  ,A1   , KEY1
  66.     Iniwrite,00:00:10, %rssini%  ,A2   , KEY1
  67.     }
  68. LastPlayedTEXT:=a_scriptdir . "\" . name1 . "_LastPlayed.txt"  
  69. ;--------------------------------------------------
  70.  
  71. ;------- PICTURES for RANDOM-read ---------------------------
  72. countP:=0
  73. Loop, %FDPictures%\*.*,,1
  74. {
  75. if A_LoopFileExt in %picturesextensions%
  76.   {
  77.   countP++
  78.   list_%countp% = %A_LoopFileShortPath%
  79.   name_%countp% = %A_LoopFileName%
  80.   }
  81. }
  82. gosub,randomtest1
  83. ;------------------------------------------------
  84. whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
  85. ComObjError(false)
  86. whr.Silent := True    ;- script failure = off
  87. whr.SetTimeouts(500,500,500,500)
  88. ;-------------------------------------------------
  89.  
  90. x:=(wa*.1)/xx,y:=(ha*3.1)/xx,w:=(wa*15.7)/xx,h:=(ha*74)/xx
  91. Gui,2:Add, ListView,backgroundTeal cWhite  x%x% y%y% h%h% w%w% +hscroll +altsubmit gLW1 vLV1 , NAME|PATH|TIME
  92. T1:=(wa*14.7)/xx,T2:=(wa*0)/xx,T3:=(wa*0)/xx
  93. LV_ModifyCol(1,T1),LV_ModifyCol(2,T2),LV_ModifyCol(3,T3)
  94. ;-
  95. x:=(wa*16)/xx ,y:=(ha*1)/xx,w:=(wa*82)/xx,h:=(ha*76)/xx
  96. Gui,2:Add,ActiveX, x%x% y%y% w%w% h%h% vVlcx, VideoLAN.VLCPlugin.2
  97. ;------------------------------------------------------------
  98. ;--- lines down ---
  99. x:=(wa*8)/xx ,y:=(ha*80)/xx,w:=(wa*80)/xx,h:=(ha*2)/xx
  100. Gui,2:Add, Progress,  x%x%  y%y% w%w% h%h% vPRBAR backgroundGray range0-100 Disabled
  101. Gui,2:Add, Text, x%x% y%y% w%w% h%h% gPrBar1 ,
  102. x:=(wa*.2)/xx ,y:=(ha*80)/xx,w:=(wa*2)/xx,
  103. Gui,2:Add,Text,       x%x%    y%y% w%w%    vT1 cYellow   ;- procent
  104. x:=(wa*3)/xx ,y:=(ha*80)/xx,w:=(wa*4.2)/xx,
  105. Gui,2:Add,Edit,       x%x%   y%y% w%w%     vT2 cYellow   ;- played time actual
  106. x:=(wa*88.5)/xx ,y:=(ha*80)/xx,w:=(wa*4.2)/xx,
  107. Gui,2:Add,Edit,       x%x% y%y% w%w%       vT3 cYellow   ;- total lenght from video
  108. x:=(wa*93)/xx ,y:=(ha*80)/xx,w:=(wa*6)/xx,
  109. Gui,2:Add,Text,       x%x% y%y% w%w%       vT5 cYellow   ;- vlc state playing paused
  110. ;------------
  111. ;--- buttons left top ----
  112. ;--------------------------
  113.  
  114. x:=(wa*.1)/xx ,y:=(ha*.5)/xx,w:=(wa*5)/xx,h:=(ha*2.3)/xx
  115. Gui,2:add, Button  , x%x%   y%y%  w%w% h%h%   gMUSIC,MUSIC
  116.  
  117. x:=(wa*5.2)/xx ,y:=(ha*.5)/xx,w:=(wa*5)/xx,h:=(ha*2.3)/xx
  118. Gui,2:add, Button  , x%x%   y%y%  w%w% h%h%   gVIDEO,VIDEO
  119.  
  120. x:=(wa*10.4)/xx ,y:=(ha*.5)/xx,w:=(wa*5)/xx,h:=(ha*2.3)/xx
  121. Gui,2:add, Button  , x%x%   y%y%  w%w% h%h%   gExtra_3,Extra3
  122.  
  123. ;-------- 2nd lines down ------------
  124. x:=(wa*.1)/xx ,y:=(ha*83.2)/xx,w:=(wa*7)/xx,h:=(ha*2.3)/xx
  125. Gui,2:add, Button  , x%x%   y%y%  w%w% h%h%   gSnapshot vSnapshot1, SNAPSHOT
  126. ;------------------------------------
  127. x:=(wa*13)/xx,y:=(ha*83.2)/xx,w:=(wa*7.5)/xx,h:=(ha*2.3)/xx
  128. Gui,2:add,Button   , x%x%   y%y%  w%w% h%h%  vLastPLAY gLastini,PLAY_NEW
  129. ;----------------------------
  130. x:=(wa*21)/xx,y:=(ha*83.2)/xx,w:=(wa*3.5)/xx,h:=(ha*2.3)/xx
  131. Gui,2:add,Button   , x%x%   y%y%  w%w% h%h%  vSTOP11 gSTOP,STOP
  132. ;----------------------------
  133. a5xx=00:00:10   ;- Jump Back
  134. a6xx=00:00:20   ;- Jump Forward
  135. a7xx=00:02:25   ;- GoTo Seek
  136. ;----------------------------
  137. Gui,2: Font, s9, Lucida Console
  138. x:=(wa*40)/xx,y:=(ha*83.2)/xx,w:=(wa*5)/xx,h:=(ha*2.3)/xx
  139. Gui,2:Add,Edit,cYellow right  x%x%  y%y%    w%w%   h%h%   vJumpB,%a5xx%        ;-- Jump backward
  140. ;----------------------------
  141. x:=(wa*40)/xx,y:=(ha*87)/xx,w:=(wa*5)/xx,h:=(ha*2.3)/xx
  142. Gui,2:Add,Button,           x%x%  y%y%    w%w%   h%h%   gGoto1B   vGoto1B2   ,<SKIP
  143. ;----------------------------
  144. x:=(wa*46)/xx,y:=(ha*83.2)/xx,w:=(wa*5)/xx,h:=(ha*2.3)/xx
  145. Gui,2:Add,Edit,cYellow right  x%x%  y%y%    w%w%   h%h%   vJumpF,%a6xx%        ;-- Jump forward
  146. ;----------------------------
  147. x:=(wa*46)/xx,y:=(ha*87)/xx,w:=(wa*5)/xx,h:=(ha*2.3)/xx
  148. Gui,2:Add,Button,           x%x%  y%y%    w%w%   h%h%   gGoto1F   vGoto1F2   ,SKIP>
  149. ;----------------------------
  150. x:=(wa*52)/xx,y:=(ha*83.2)/xx,w:=(wa*5)/xx,h:=(ha*2.3)/xx
  151. Gui,2:Add,Edit,cYellow right  x%x%  y%y%    w%w%   h%h%   vGotox,%a7xx%        ;-- GotoX
  152. ;----------------------------
  153. x:=(wa*52)/xx,y:=(ha*87)/xx,w:=(wa*5)/xx,h:=(ha*2.3)/xx
  154. Gui,2:Add,Button,           x%x%  y%y%    w%w%   h%h%   gGoto1X   vGoto1X2   ,GotoX
  155. ;----------------------------
  156. Gui,2: Font, s9, Lucida Console
  157. x:=(wa*.1)/xx,y:=(ha*87)/xx,w:=(wa*39)/xx
  158. Gui,2:add, Edit    , x%x%    y%y% w%w% cYellow readonly vTxt1                  ;- show URL
  159. ;----------------------------
  160. Gui,2:Add,Text,x0 y0 w0 h0 vEmptyText,
  161. ;----------------------------------------
  162. w:=(wa*99.9)/xx,h:=(ha*90)/xx
  163. Gui,2: Show,x0 y0 w%w% h%h%,%name1%   OS=%a_osversion% | AHK=%a_ahkversion% | %a_ostype% | 64bit=%a_is64bitos% | %wa%*%ha% | %a_username%=%a_isadmin% | %a_computername%
  164. ;------------------------------------
  165. settimer,aas1,500
  166. settimer,aas1,off
  167. GuiControl,2:Disable,Snapshot1
  168. GuiControl,2: Focus,EmptyText
  169. sleep,500
  170. return
  171. ;-----------------------------------------------------------------------------------------------------
  172. 2Guiclose:
  173. Gui,2:submit,nohide
  174. sleep,200
  175. IniWrite,%T2%, %rssini% , A2 , Key1
  176. ;IniRead, C2a, %rssini% , A1 , Key1
  177. ;Fileappend,%c2a%`;%t2%`r`n,%LastPlayedTEXT%,utf-8
  178. sleep,200  
  179. exitapp
  180. ;----------------------------------------
  181.  
  182. ;-- used ESCAPE -------------------------
  183. aabb:
  184. Gui,2:submit,nohide
  185. ay:=vlcx.input.state
  186. WinGet, IsMin, MinMax, % "ahk_id " uid
  187. if (IsMin = -1)
  188.  {
  189.  WinRestore, % "ahk_id " uid
  190.  if winexist(name1)
  191.    Hotkey,SPACE,pause1,ON
  192.  Guicontrolget,T5
  193.  if (ay=4)
  194.    gosub,pause1  
  195.  }
  196. else
  197.  {
  198.  Winminimize
  199.  if winexist(name1)
  200.    Hotkey,SPACE,pause1,OFF
  201.   if (ay=3)
  202.    gosub,pause1  
  203.  }
  204. return
  205. ;-----------------------------------------
  206. LASTINI:
  207. Gui,2:submit,nohide
  208. if winactive(name1)
  209.   Hotkey,SPACE,pause1,ON
  210. IniRead, C2, %rssini% , A1 , Key1
  211. if C2<>
  212.   {
  213.   Guicontrol,2:,txt1,%C2%
  214.   gosub,VideoAudioPLAY
  215.   }
  216. else
  217.   msgbox, 262208, ,Error C2=%c2%
  218. return
  219.  
  220. ;======================================
  221. VideoAudioPLAY:
  222. Gui,2:submit,nohide
  223. gosub,checkc2
  224.  
  225. if (checkvar="OK")
  226. {
  227.    vlcx.playlist.stop()
  228.    vlcx.playlist.items.clear()
  229.    vlcx.playlist.add(C2,"","""""")
  230.    vlcx.playlist.next()
  231.    settimer,aas1,on
  232. }
  233. else
  234. msgbox, 262144, ,Not exist =`n%c2%  
  235. return
  236. ;======================================
  237.  
  238. ;-----------------------------------------
  239.  
  240. Playfile:
  241. Gui,4:destroy
  242. Gui,2:submit,nohide
  243. gosub,checkc2
  244.  
  245. if (checkvar="OK")
  246. {
  247. vlcx.playlist.stop()
  248. vlcx.playlist.items.clear()
  249. vlcx.playlist.add(C2,"","""""")
  250. vlcx.playlist.next()
  251. settimer,aas1,on
  252. gosub,clearall
  253. if ext in %musicextensions%
  254.   gosub,ChildPicture
  255. }
  256. else
  257.   msgbox, 262144,NOT FOUND ,Not exist=`n%c2%  
  258. return
  259. ;----------------------------------------
  260.  
  261. ;============= CHECK C2 =============================
  262. CheckC2:
  263. if C2 contains file:///
  264. {
  265. stringreplace,c2a,c2,file:///,,all
  266. Guicontrol,2:,txt1,%C2%
  267. ifexist,%c2a%
  268.  checkvar=OK
  269. else
  270.  checkvar=NOK
  271. }
  272.  
  273. if C2 contains http
  274.  {
  275.  checkvar=OK
  276.  Guicontrol,2:,txt1,%C2%
  277.  }
  278. return
  279. ;----------------------------------------------------
  280.  
  281.  
  282. ;------------------- CHILDNEW for picture -----------
  283. ChildPicture:
  284. Gui,4:destroy
  285. Gui,2:submit,nohide
  286. Gui,4:Default
  287. Gui,4: -DPIScale
  288. Gui,4: Color,Black,black
  289. Gui,4: +Parent2 -Sysmenu -caption
  290. imgw:=0,imgh:=0
  291. if hBitmap := GetThumbnailOrIcon(C2,0,0)
  292.    {
  293.    aa:="HBITMAP:" . GetThumbnailOrIcon(C2,300,300)
  294.    }
  295. else
  296.    {
  297.    gosub,randomtest2
  298.    imgSize(ShowPic,imgw,imgh)
  299.    aa:=ShowPic
  300.    sleep,100
  301.    }
  302. ;----------------------------
  303. px:=(wa*4)/xx,x:=(wa*0)/xx,y:=(ha*0)/xx,w:=(wa*60)/xx,h:=(ha*80)/xx
  304. if (imgw>imgh)
  305.   Gui,4: Add, Pic,x%x% y%y% w%w%  h-1, %aa%
  306. else if (imgh>imgw)
  307.   Gui,4: Add, Pic,x%px% y%y% h%h% w-1, %aa%
  308. else
  309.   Gui,4: Add, Pic,x%x% y%y% w%w%  h-1, %aa%  
  310. x:=(wa*17)/xx,y:=(ha*1)/xx,w:=(wa*80)/xx,h:=(ha*80)/xx
  311. Gui,4: Show,x%x% y%y% w%w% h%h% , Child_2
  312. return
  313. ;---------------------------------------
  314.  
  315. ;--------------- LISTVIEW -------------
  316. LW1:
  317. Gui,2:Submit,nohide
  318. Gui,2:ListView, LV1
  319. LV_GetText(C1,A_EventInfo,1)
  320. LV_GetText(C2,A_EventInfo,2)
  321. LV_GetText(C3,A_EventInfo,3)
  322.   RN:=LV_GetNext("C")
  323.   RF:=LV_GetNext("F")
  324.   GC:=LV_GetCount()
  325. if (A_GuiEvent = "Normal")
  326.  {
  327.  if (rn=0)
  328.     return
  329.  ;msgbox, 262208,,C1=%c1%`nC2=%c2%
  330.  Guicontrol,2:,txt1,%C2%
  331.  SplitPath,C2, name, dir, ext, name_no_ext, drive
  332.  C2=file:///%c2%
  333.  IniWrite,%C2%, %rssini% ,A1   , KEY1
  334.  gosub,playfile
  335.  return
  336.  }  
  337. ;-------------------------------------------------------------------
  338. if A_GuiEvent = Rightclick
  339.  {
  340.  ;msgbox, 262208,,C1=%c1%`nC2=%c2%
  341.  gosub,stop
  342.  try
  343.    run,%c2%
  344.  }
  345. Return
  346. ;================== END  LISTVIEW ===============================================
  347. MUSIC:
  348. Gui,2:submit,nohide
  349. elf:="",lastfiles:=0
  350. LV_Delete()
  351. ;---
  352. I:=0
  353.   Loop, Files,%FDMusic%\*.*,FDR
  354.     {
  355.     SplitPath,a_loopfilefullpath, name, dir, ext, name_no_ext, drive
  356.     if ext in %musicextensions%
  357.       elf .= name . "              " . dlm . a_loopfilefullpath . "`r`n"
  358.     }
  359. for each, Line in StrSplit(elf, "`n", "`r")
  360. {
  361. if line=
  362.   continue
  363. Columns := StrSplit(Line,dlm)
  364. LV_Add("",Columns*)
  365. }
  366. if elf=
  367.   msgbox, 262144, ,PATH NOT FOUND =`n %fdmusic%
  368. elf:="",I:=0
  369. return
  370. ;----------------------------------------------
  371. ;---------- VIDEO -----------------------------
  372. VIDEO:
  373. Gui,2:submit,nohide
  374. elf:="",lastfiles:=0
  375. LV_Delete()
  376. ;---
  377. I:=0
  378.   Loop, Files,%FDVideo%\*.*,FDR
  379.     {
  380.     SplitPath,a_loopfilefullpath, name, dir, ext, name_no_ext, drive
  381.     if ext in %videoextensions%
  382.       elf .= name . "         " . dlm . a_loopfilefullpath . "`r`n"
  383.     }
  384. for each, Line in StrSplit(elf, "`n", "`r")
  385. {
  386. if line=
  387.   continue
  388. Columns := StrSplit(Line,dlm)
  389. LV_Add("",Columns*)
  390. }
  391. if elf=
  392.   msgbox, 262144, ,PATH NOT FOUND =`n %FDVideo%
  393. elf:="",I:=0
  394. return
  395. ;----------------------------------------------
  396. ;=============================================================================  
  397.  
  398. ;-----------  STOP ----------------------
  399. STOP:
  400. Gui,2:submit,nohide
  401. if winexist(name1)
  402.   Hotkey,SPACE,pause1,OFF
  403. Guicontrolget,T2
  404. settimer,aas1,off
  405. GuiControl,2:Disable,Snapshot1
  406. vlcx.playlist.stop()
  407. vlcx.playlist.items.clear()
  408. GuiControl,2:Text,T5,Stopped
  409. IniWrite,%T2%, %rssini% , A2 , Key1
  410. gosub,clearall
  411. return
  412. ;------------------------------------------------------
  413. ;========== CLEAR ===================
  414. clearall:
  415.  GuiControl,2:Text,T1,
  416.   GuiControl,2:Text,T2,
  417.   GuiControl,2:Text,T3,
  418.   Guicontrol,2:text,T5
  419.   Guicontrol,2:text,prbar
  420.   GuiControl,2:,PRBAR,0
  421.   GuiControl,2:Text,Procentx   ,0`%
  422. return
  423. ;-------------------------------------
  424. ;-------------------------------------
  425. Prbar1:
  426. gui,2:submit,nohide
  427. vlcx.playlist.items.clear()
  428. gosub,checkx
  429. if (acc=0 or bcx=0)
  430.    return
  431. MouseGetPos,xpos
  432. x100:=(wa*80)/xx
  433. afc:=(wa*.2734375)/xx
  434. procent  :=round((100*xpos)/x100)-afc
  435. calctime :=((bc*procent)/100)
  436. ;msgbox,CALC=%calctime%`nLenght=%bcx%`nNow=%acc%
  437. vlcx.input.time :=(calctime)
  438. return
  439. ;---------------------------------
  440. ;------------------
  441. #IfWinActive ahk_class AutoHotkeyGUI ahk_exe AutoHotkey.exe
  442. ~left::
  443. Goto1B:
  444. vlcx.playlist.items.clear()   ;--(?)
  445. acx:=vlcx.input.time
  446. guicontrolget,jumpb
  447. varxx=%jumpb%
  448. gosub,gosubtimecalc
  449. vlcx.input.time :=(-total+acx)
  450. return
  451. ;------------------
  452. ~right::
  453. Goto1F:
  454. vlcx.playlist.items.clear()   ;--(?)
  455. acx:=vlcx.input.time
  456. guicontrolget,jumpf
  457. varxx=%jumpf%
  458. gosub,gosubtimecalc
  459. endtotal:=(total+acx)
  460. if (endtotal>=bc)
  461.    endtotal:=(bc-10000)        ;- goto endtotal minus 10 sec
  462. vlcx.input.time :=(endtotal)
  463. return
  464. #IfWinActive
  465. ;------------------
  466. Goto1X:
  467. gui,2:submit,nohide
  468. vlcx.playlist.items.clear()   ;--(?)
  469. gosub,checkx
  470. if (acc=0 or bcx=0)
  471.    return
  472. guicontrolget,gotoX
  473. varxx=%gotox%
  474. total:=0
  475. gosub,gosubtimecalc
  476. endtotal:=(total)
  477. if (endtotal>bc)
  478.    endtotal:=(bc-10000)       ;- goto endtotal minus 10 sec
  479. vlcx.input.time :=(endtotal)
  480. return
  481. ;========== VLC functions ============================
  482. ;-------- pause / PLAY --------------
  483. pause1:
  484. gui,2:submit,nohide
  485. vlcx.playlist.items.clear()   ;--(?)
  486. vlcx.playlist.togglePause()
  487. return
  488. ;------- check ----------
  489. checkx:
  490. bc:=vlcx.input.length
  491. ac:=vlcx.input.time
  492. acc:=(ac//1000)
  493. bcx:=(bc//1000)
  494. return
  495. ;------------------
  496. SNAPSHOT:
  497. ;- rename saved picture bmp to png ( is in a_scriptdir )
  498. ifexist,%vlc1%
  499.   vlcx.video.takeSnapshot()
  500. return
  501. ;---------------------------------------------
  502. ;=============================================
  503. ;------------------------------- EXTRA-3 german satire ----------------------------------------
  504. Extra_3:
  505. Gui,2:submit,nohide
  506. gosub,clearall
  507. GuiControl,2:Disable,download1
  508. GuiControl,2:Disable,Snapshot1
  509. C2:=""
  510. url:="https://www.ndr.de/fernsehen/sendungen/extra_3/video-podcast/index.xml"
  511. whr.Open("GET",URL, true)
  512. whr.Send()    ; Using 'true' above and the call below allows the script to remain responsive.
  513. whr.WaitForResponse()
  514. H := whr.ResponseText  ; haystack
  515. ;------------------------
  516. B=<enclosure url="
  517. E="
  518. C2:=xStr(H,,B,E)
  519. Guicontrol,2:,txt1,%C2%
  520. Gui,4:destroy
  521. if C2<>
  522.   {
  523.   Guicontrol,2:,txt1,%C2%
  524.   IniWrite,%C2%, %rssini% ,A1   , KEY1
  525.   gosub,VideoAudioPLAY
  526.   }
  527. else
  528.   msgbox, 262208, ,Error read URL
  529. return
  530. ;=========== settimer progressbar ==================
  531. aas1:
  532. gui,2:submit,nohide
  533. ay:=vlcx.input.state
  534. if (ay=6)
  535.    {
  536.    GuiControl,2:,PRBAR,100
  537.    GuiControl,2:Text,Procentx   ,100`%
  538.    GuiControl,2:Text,T5,ENDed
  539.    settimer,aas1,off
  540.    if winexist(name1)
  541.      Hotkey,SPACE,pause1,OFF
  542.    return
  543.    }
  544. if (ay=0)
  545.    cy=Idle
  546. if (ay=1)
  547.    cy=Opening
  548. if (ay=2)
  549.    cy=Buffering
  550. if (ay=3)
  551.    cy=Playing
  552. if (ay=4)
  553.    cy=Paused
  554. if (ay=5)
  555.    cy=Stopped
  556. if (ay=7)
  557.    cy=Error
  558.  
  559. if winactive(name1)
  560.   Hotkey,SPACE,pause1,ON
  561. bc:=vlcx.input.length
  562. ac:=vlcx.input.time
  563. acc:=(ac//1000)
  564. bcx:=(bc//1000)
  565. if (acc=0 or bcx=0)
  566.    return
  567. ;msgbox, 262208, ,acc=%acc%`nbcx=%bcx% , 1
  568. SetFormat, float, 02
  569. hours1   := (acc//3600)
  570. minutes1 := (acc - hours1 * 3600)// 60
  571. seconds1 := (acc - hours1 * 3600 - minutes1 * 60)
  572. hours1  +=0.00
  573. minutes1+=0.00
  574. seconds1+=0.00
  575. acc=%hours1%:%minutes1%:%seconds1%
  576. ;------- played-time ---------------
  577. hours   := (bcx//3600)
  578. minutes := (bcx - hours * 3600)// 60
  579. seconds := (bcx - hours * 3600 - minutes * 60)
  580. hours  +=0.00
  581. minutes+=0.00
  582. seconds+=0.00
  583. bcx=%hours%:%minutes%:%seconds%
  584. ;----- total-time ----------------
  585. GuiControl,2:Text,T5,%cy%
  586.     RES1:=Round((100*AC)/BC)
  587.     GuiControl,2:,PRBAR ,%res1%
  588. GuiControl,2:Text,T1    ,%res1%`%   ;- procent
  589. GuiControl,2:Text,T2    ,%acc%      ;- PlayedTime
  590. GuiControl,2:Text,T3    ,%bcx%      ;- Lenght
  591. if (CY="Paused") or (CY="Playing")
  592.   GuiControl,2:Enable,Snapshot1
  593. return
  594. ;===============  timecalc ===========
  595. gosubtimecalc:
  596. total:=0
  597. y1=
  598. y2=
  599. y3=
  600.   stringsplit,Y,varxx,`:
  601.   if y3<>
  602.   {
  603.   hours:=(y1*60*60)*1000
  604.   minutes:=(y2*60)*1000
  605.   seconds:=(y3*1000)
  606.   total:=(hours+minutes+seconds)
  607.   }
  608.   if (y3="" and y2<>"")
  609.   {
  610.   minutes:=(y1*60)*1000
  611.   seconds:=(y2*1000)
  612.   total:=(minutes+seconds)
  613.   }
  614.   if (y3="" and y2="")
  615.      total:=(varxx*1000)
  616. return
  617. ;======================================
  618. ;----------- for picture -------------------------------------
  619. Randomtest1:         ;- run once a list from random numbers
  620. ;- Lotto / from user Laszlo
  621. MIN:= 1
  622. MAX:= countp     ;- Total pictures
  623. N  := countp
  624. i:=0, ex11:=""
  625. Loop %N%
  626. {
  627.   i := A_Index
  628.   loop
  629.   {
  630.     Random R, %MIN%, %MAX%     ; R = random number
  631.     j := Index_%R%             ; get value from Indexes
  632.     If j is number
  633.       If j between 1 and % i - 1
  634.         If (R_%j% = R)
  635.           continue             ; repetition found, try again
  636.     Index_%R% := i             ; store index
  637.     R_%i% := R                 ; store in R_1, R_2...
  638.     ff:=R_%i%
  639.     ex11 .= ff . ","
  640.     break                      ; different number
  641.   }
  642. }
  643. return
  644. ;----------------------------------------------------------------
  645. Randomtest2:
  646. ck += 1
  647. loop,parse,ex11,`,
  648.  {
  649.  x:=a_loopfield
  650.  if (ck=a_index)
  651.    {
  652.    ShowPic := list_%x%
  653.    NamePic := name_%x%
  654.    break
  655.    }
  656.  }
  657. ;msgbox,Total-Pictures=%countp%`nLoop=%ck%`nRandom-Number=%x%
  658. if (ck=countp)
  659.  ck:=0
  660. return
  661. ;----------------------------------------------------------------
  662. ;----------------------------------------------------------------
  663. imgSize(img, ByRef width , ByRef height) { ; Get image's dimensions
  664.  If FileExist(img) {
  665.   GUI,3: Add, Picture, hwndpic, %img%
  666.   ControlGetPos,,, width, height,, ahk_id %pic%
  667.   Gui,3: Destroy
  668.  } Else height := width := 0
  669. }
  670.  
  671. ;------------------------------------------------------------------
  672.  
  673. ;=============== get MP3 Picture thumbnail/ICO ============================================
  674. ;-------------
  675. GetThumbnailOrIcon(filePath, width, height := 0, iconOnly := false) {
  676.    static IID_IShellItemImageFactory := "{BCC18B79-BA16-442F-80C4-8A59C30C463B}"
  677.         , SIIGBF_BIGGERSIZEOK := 0x00000001
  678.         , SIIGBF_ICONONLY     := 0x00000004
  679.    
  680.    VarSetCapacity(GUID, 16, 0)
  681.    DllCall("Ole32\IIDFromString", "WStr", IID_IShellItemImageFactory, "Ptr", &GUID)
  682.    hr := DllCall("Shell32\SHCreateItemFromParsingName", "WStr", filePath, "Ptr", 0, "Ptr", &GUID, "PtrP", IShellItemImageFactory)
  683.    if (hr != 0)
  684.       Return 0
  685.    flag := SIIGBF_BIGGERSIZEOK, (iconOnly && flag |= SIIGBF_ICONONLY)
  686.    ; IShellItemImageFactory::GetImage
  687.    DllCall(NumGet(NumGet(IShellItemImageFactory+0) + A_PtrSize*3), "Ptr", IShellItemImageFactory, "Int64", height << 32 | width
  688.                                                                                                 , "Int", flag, "PtrP", hBitmap, "Int")
  689.    ObjRelease(IShellItemImageFactory)
  690.    Return hBitmap
  691. }
  692. ;==========================================================================================
  693.  
  694. ;-------- saved at Dienstag, 7. April 2020 16:34:11 SKAN --------------
  695. ;- xStr  for general text extraction and parsing XML  HTML
  696. ;- https://www.autohotkey.com/boards/viewtopic.php?f=6&t=74050
  697. xStr(ByRef H, C:=0, B:="", E:="",ByRef BO:=1, EO:="", BI:=1, EI:=1, BT:="", ET:="") {                          
  698. Local L, LB, LE, P1, P2, Q, N:="", F:=0                 ; xStr v0.97 by SKAN on D1AL/D343 @ tiny.cc/xstr  
  699. Return SubStr(H,!(ErrorLevel:=!((P1:=(L:=StrLen(H))?(LB:=StrLen(B))?(F:=InStr(H,B,C&1,BO,BI))?F+(BT=N?LB
  700. :BT):0:(Q:=(BO=1&&BT>0?BT+1:BO>0?BO:L+BO))>1?Q:1:0)&&(P2:=P1?(LE:=StrLen(E))?(F:=InStr(H,E,C>>1,EO=N?(F
  701. ?F+LB:P1):EO,EI))?F+LE-(ET=N?LE:ET):0:EO=N?(ET>0?L-ET+1:L+1):P1+EO:0)>=P1))?P1:L+1,(BO:=Min(P2,L+1))-P1)  
  702. }
  703. ;------------------------------------------------------------------
  704. ;======== END SCRIPT =======================================
  705.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement