jdm001

DesktopHut - Video Wallpaper Randomizer

Jul 2nd, 2017
90
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. STimer = 600000    ; Timer to swap vidoes, in (ms) ie 60 Seconds is 60000, default is 10min (600000)
  22.  
  23. ;Ask user what folder they want to randomly grab videos from
  24. AskForFolder:
  25. FileSelectFolder, RandFolder, , 0  
  26. if(ErrorLevel)
  27.     ExitApp
  28. if (RandFolder = ""){
  29.         MsgBox, You didn't select a folder.
  30.         Goto,AskForFolder
  31.     }else
  32.         Goto, TimedVidSwitch
  33.     gosub,ReadFiles
  34. Return
  35.  
  36. ;Now get a random file.  This is called upon every X minutes
  37. GetFileForSS:
  38.     if(!FileList.MaxIndex())
  39.         gosub,ReadFiles
  40.     Random,r,1,% FileList.MaxIndex()
  41.     SSFile:=FileList[r]
  42.     FileList.Delete(r)
  43. ReadFiles:
  44.     FileList:=[]
  45.     Loop,Files,%RandFolder%\*.mp4
  46.         FileList.Push(A_LoopFileFullPath)
  47.     if(!FileList.MaxIndex()){
  48.         MsgBox,There are no mp4 files in this directory.  Please choose another
  49.         Goto,AskForFolder
  50.     }
  51. return
  52.  
  53. ;The video shows original desktop for half a second while swapping videos.
  54. ;So, you'll see 3 different desktops within a few seconds at each switch.
  55. ;This puts a black background to hide the switch without a jarring change.
  56. HideBackgroundGui:
  57.     Gui, 1:Color, 000000
  58.     Gui, 1:-Caption +ToolWindow
  59.     Gui, 1:Show, x0 y0 w%A_ScreenWidth% h%SH% ; Cover entire monitor except taskbar in case of error
  60.     Sleep 3000
  61.     SysGet, MonitorCount, MonitorCount
  62.     If(MonitorCount !=1){
  63.         SysGet, Mon2, Monitor, 1 Gui, 2:Color, 000000
  64.         Gui, 2:-Caption +ToolWindow
  65.         Gui, 2:Show, x%Mon2Left% y%Mon2Top% w7000 h7000 ; Can't do ScreenWidth/Height so 7K resolution should cover all monitors
  66. }
  67. Return
  68.  
  69. ; This is a subroutine that checks idle time, if > 1HR a msgbox will pause script
  70. Check:
  71. 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.
  72. Return
  73.  
  74. ;This is the actual swapping of videos and reloading DesktopHut Viewer.
  75. TimedVidSwitch:
  76. GoSub, GetFileForSS
  77.     ; Checks to see if desktop is active, if so, it hides switch with background
  78. #If WinActive("ahk_class Progman") || WinActive("ahk_class WorkerW")
  79. {
  80.         GoSub HideBackgroundGui
  81. }
  82.     ; If desktop is not active, OR if it is active but now currently Hidden
  83.     ; We can now do the actual swapping of the files and reload the desktop
  84.     ; Note, if you get 'orphan' tray icons, just mouse over and they disappear
  85. FileMove, %A_ScriptDir%\config.ini, %A_ScriptDir%\config-backup.ini, 1
  86. Process, Close, DesktopHut.exe
  87. ;WinKill, ahk_exe DesktopHut.exe
  88. FileAppend, %SSFile%, config.ini,
  89. Run, %A_ScriptDir%\DesktopHut.exe, ,Min
  90. SoundBeep
  91. Gui, 1:Destroy
  92. Gui, 2:Destroy
  93. Sleep %STimer%
  94. GoSub, Check
  95. Goto TimedVidSwitch
  96. Return
  97.  
  98. ;Killswitch Hotbutton CTRL+ALT+F1 to Exit Script (but leave last video background running)
  99. ^!F1::
  100. ExitApp
Add Comment
Please, Sign In to add comment