Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; This requires DesktopHut Video Backgrounds found at http://www.desktophut.com/Software/ ;
- ; This script stays in the background and changes the video screensaver every 10 minutes. ;
- ; It will change the video to a random file in a given directory chosen at startup ;
- ;_______________________________________________________________________________________________;
- ; In Win10 you may want to disable DesktopHut notifications, hit WINKEY+I & uncheck DesktopHut ;
- ; Exit Randomizer any time: CTRL+ALT+F1, it leaves DesktopHut running w/ current video desktop ;
- ; James M 7/3/2017 ;
- ;===============================================================================================;
- ; Script Environment and Settings
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- #SingleInstance Force
- #Persistent
- DetectHiddenWindows, On
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- Menu, Tray, Icon, %A_ScriptDir%\rlicon.ico
- SH := A_ScreenHeight*.97 ; This gets your screenheight while leaving toolbar showing
- SetTimer, Check, 600000 ; A timer is to check idle time, it pauses script after 1hr
- Inputbox, MySwapTime, How long before swap video backgrounds, Enter time in minutes that you want to swap backgrounds
- MySwapTime := MySwapTime*60000
- STimer = %MySwapTime% ; Timer to swap vidoes, in (ms) ie 60 Seconds is 60000, default is 10min (600000)
- ;Ask user what folder they want to randomly grab videos from
- AskForFolder:
- 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
- if(ErrorLevel)
- ExitApp
- if (RandFolder = ""){
- MsgBox, You didn't select a folder.
- Goto,AskForFolder
- }else
- Goto, TimedVidSwitch
- gosub,ReadFiles
- Return
- ;Now get a random file. This is called upon every X minutes
- GetFileForSS:
- if(!FileList.MaxIndex())
- gosub,ReadFiles
- Random,r,1,% FileList.MaxIndex()
- SSFile:=FileList[r]
- FileList.Delete(r)
- ReadFiles:
- FileList:=[]
- Loop,Files,%RandFolder%\*.mp4
- FileList.Push(A_LoopFileFullPath)
- if(!FileList.MaxIndex()){
- MsgBox,There are no mp4 files in this directory. Please choose another
- Goto,AskForFolder
- }
- return
- ;The video shows original desktop for half a second while swapping videos.
- ;So, you'll see 3 different desktops within a few seconds at each switch.
- ;This puts a black background to hide the switch without a jarring change.
- HideBackgroundGui:
- Gui, 1:Color, 000000
- Gui, 1:-Caption +ToolWindow
- Gui, 1:Show, x0 y0 w%A_ScreenWidth% h%SH% ; Cover entire monitor except taskbar in case of error
- Sleep 3000
- SysGet, MonitorCount, MonitorCount
- If(MonitorCount !=1){
- SysGet, Mon2, Monitor, 1 Gui, 2:Color, 000000
- Gui, 2:-Caption +ToolWindow
- Gui, 2:Show, x%Mon2Left% y%Mon2Top% w7000 h7000 ; Can't do ScreenWidth/Height so 7K resolution should cover all monitors
- }
- Return
- ; This is a subroutine that checks idle time, if > 1HR a msgbox will pause script
- Check:
- 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.
- Return
- ;This is the actual swapping of videos and reloading DesktopHut Viewer.
- TimedVidSwitch:
- GoSub, GetFileForSS
- ; Checks to see if desktop is active, if so, it hides switch with background
- #If WinActive("ahk_class Progman") || WinActive("ahk_class WorkerW")
- {
- GoSub HideBackgroundGui
- }
- ; If desktop is not active, OR if it is active but now currently Hidden
- ; We can now do the actual swapping of the files and reload the desktop
- ; Note, if you get 'orphan' tray icons, just mouse over and they disappear
- FileMove, %A_ScriptDir%\config.ini, %A_ScriptDir%\config-backup.ini, 1
- Process, Close, DesktopHut.exe
- ;WinKill, ahk_exe DesktopHut.exe
- FileAppend, %SSFile%, config.ini,
- Run, %A_ScriptDir%\DesktopHut.exe, ,Min
- SoundBeep
- Gui, 1:Destroy
- Gui, 2:Destroy
- Sleep %STimer%
- GoSub, Check
- Goto TimedVidSwitch
- Return
- ;Killswitch Hotbutton CTRL+ALT+F1 to Exit Script (but leave last video background running)
- ^!F1::
- ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement