Advertisement
jdm001

JimmerScripts - Video Background Randomizer

Jul 11th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; This requires DesktopHut Video Backgrounds found at http://www.desktophut.com/Software/       ;
  2. ; This script stays in the background and changes the video screensaver every 10 minutes.       ;
  3. ; It will change the video to a random file in a given directory chosen at startup              ;
  4. ;_______________________________________________________________________________________________;
  5. ; In Win10 you may want to disable DesktopHut notifications, hit WINKEY+I & uncheck DesktopHut  ;
  6. ; Exit Randomizer any time: CTRL+ALT+F1, it leaves DesktopHut running w/ current video desktop  ;
  7. ; James M 7/3/2017                                                                              ;
  8. ;===============================================================================================;
  9.  
  10. ; Script Environment and Settings
  11. #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
  12. #SingleInstance Force
  13. #Persistent
  14. DetectHiddenWindows, On
  15. SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
  16. SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
  17. Menu, Tray, Icon, %A_ScriptDir%\rlicon.ico
  18. SH := A_ScreenHeight*.97   ; This gets your screenheight while leaving toolbar showing
  19. SetTimer, Check, 600000    ; A timer is to check idle time, it pauses script after 1hr
  20.  
  21. Inputbox, MySwapTime, How long before swap video backgrounds, Enter time in minutes that you want to swap backgrounds
  22. MySwapTime := MySwapTime*60000
  23. STimer = %MySwapTime%    ; Timer to swap vidoes, in (ms) ie 60 Seconds is 60000, default is 10min (600000)
  24.  
  25. ;Ask user what folder they want to randomly grab videos from
  26. AskForFolder:
  27. FileSelectFolder, RandFolder, *D:\Arcade\Media\Main Menu\Video, 3, Select a folder`, default is all the system videos folder, or try D:\Arcade\Media\_Launchbox Media\Videos\Platforms
  28. if(ErrorLevel)
  29.     ExitApp
  30. if (RandFolder = ""){
  31.         MsgBox, You didn't select a folder.
  32.         Goto,AskForFolder
  33.     }else
  34.         Goto, TimedVidSwitch
  35.     gosub,ReadFiles
  36. Return
  37.  
  38. ;Now get a random file.  This is called upon every X minutes
  39. GetFileForSS:
  40.    if(!FileList.MaxIndex())
  41.         gosub,ReadFiles
  42.     Random,r,1,% FileList.MaxIndex()
  43.     SSFile:=FileList[r]
  44.     FileList.Delete(r)
  45. ReadFiles:
  46.    FileList:=[]
  47.     Loop,Files,%RandFolder%\*.mp4
  48.         FileList.Push(A_LoopFileFullPath)
  49.     if(!FileList.MaxIndex()){
  50.         MsgBox,There are no mp4 files in this directory.  Please choose another
  51.         Goto,AskForFolder
  52.     }
  53. return
  54.  
  55. ;The video shows original desktop for half a second while swapping videos.
  56. ;So, you'll see 3 different desktops within a few seconds at each switch.
  57. ;This puts a black background to hide the switch without a jarring change.
  58. HideBackgroundGui:
  59.    Gui, 1:Color, 000000
  60.     Gui, 1:-Caption +ToolWindow
  61.     Gui, 1:Show, x0 y0 w%A_ScreenWidth% h%SH% ; Cover entire monitor except taskbar in case of error
  62.     Sleep 3000
  63.     SysGet, MonitorCount, MonitorCount
  64.     If(MonitorCount !=1){
  65.         SysGet, Mon2, Monitor, 1 Gui, 2:Color, 000000
  66.         Gui, 2:-Caption +ToolWindow
  67.         Gui, 2:Show, x%Mon2Left% y%Mon2Top% w7000 h7000 ; Can't do ScreenWidth/Height so 7K resolution should cover all monitors
  68. }
  69. Return
  70.  
  71. ; This is a subroutine that checks idle time, if > 1HR a msgbox will pause script
  72. Check:
  73. IfGreater, A_TimeIdle, 3600000, MsgBox, You were idle for over an hour so Video Desktop Randomizer stopped swapping videos `n`nPress OK to continue randomizing videos for your desktop.
  74. Return
  75.  
  76. ;This is the actual swapping of videos and reloading DesktopHut Viewer.
  77. TimedVidSwitch:
  78. GoSub, GetFileForSS
  79.     ; Checks to see if desktop is active, if so, it hides switch with background
  80. #If WinActive("ahk_class Progman") || WinActive("ahk_class WorkerW")
  81. {
  82.         GoSub HideBackgroundGui
  83. }
  84.     ; If desktop is not active, OR if it is active but now currently Hidden
  85.     ; We can now do the actual swapping of the files and reload the desktop
  86.     ; Note, if you get 'orphan' tray icons, just mouse over and they disappear
  87. FileMove, %A_ScriptDir%\config.ini, %A_ScriptDir%\config-backup.ini, 1
  88. Process, Close, DesktopHut.exe
  89. ;WinKill, ahk_exe DesktopHut.exe
  90. FileAppend, %SSFile%, config.ini,
  91. Run, %A_ScriptDir%\DesktopHut.exe, ,Min
  92. SoundBeep
  93. Gui, 1:Destroy
  94. Gui, 2:Destroy
  95. Sleep %STimer%
  96. GoSub, Check
  97. Goto TimedVidSwitch
  98. Return
  99.  
  100. ;Killswitch Hotbutton CTRL+ALT+F1 to Exit Script (but leave last video background running)
  101. ^!F1::
  102. ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement