#include #include #include #include #include #include #include #include #include ;Only allow one instance of the program to run. If _Singleton("Fullscreen Slideshow", 1) = 0 Then Exit EndIf ;Settings ;==================================== GetSettings() ;==================================== Global $desktop Global $ssTimerSet = 0 Global $countedImages = 0 Global $imageWasShown = 1 Global $hidden = 0 Global $VNChidden = 0 Global $checkCount = 1 Global $taskbarActivationHide = 0 ;Global $inputDirector = WinGetHandle("Cursor Hider") ;Uknown glitch fix ;$inputDirector = 0x00530C46 ;====== Global $imageList = _FileListToArray($pictureFolder) Global $imageCount = $imageList[0] Global $imageShown[$imageCount + 1] Global $resetCount = 0 Global $reset = 0 Global Const $STM_SETIMAGE = 0x0172 Global $currActiveWindow = WinGetHandle("") Global $imageChangedBlack = 0 Global $imageWidth, $imageHeight, $pHeight, $pWidth, $smCenterX, $smCenterY, _ $picName, $activeWindowPosition, $refreshImage, $imageTimer, $screenSaverTimer, _ $startWithWindows, $closeWithScreensaver Global $screenSaverOpened = 0 Global $winSize[2] Global $hHBmp _GDIPlus_Startup() ;GetMonitorInformation() GetImage() ;GUI ;Hidden GUI for fixing if FSS becomes the active window GUICreate("FSS", 0, 0, 0, 0) ;Parent, for taskbar hide effect $GUIHide = GUICreate("hide", 0, 0, 0, 0) ;Actual GUI to be used $GUI = GUICreate("Fullscreen Slideshow", @DesktopWidth, @DesktopHeight, 0, 0, BitOR($WS_POPUP, $WS_EX_TOPMOST), -1, $GUIHide) ;GUI is the size of the screen $hHBmp = $pictureFolder & "\" & $imageList[$picName] $gdiPic = _GDIPlus_BitmapCreateFromFile($hHBmp) ;convert GDI bitmap to GDI+ bitmap _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore $pic = _GDIPlus_ImageResize($gdiPic, $imageWidth, $imageHeight) ;resize image GUICtrlSetPos($pic, $smCenterX, $smCenterY) GUISetBkColor(0) GUISetState(@SW_SHOW) MoveWindow() Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($GUI) ;create a graphics object from a window handle _GDIPlus_GraphicsDrawImage($hGraphics, $pic, $smCenterX, $smCenterY) ;display scaled image $imageTimer = TimerInit() ;Reset Image Change Timer WinActivate(HWnd($currActiveWindow)) ;Activate window that was previously active ;Fix for sudden power failure (screensaver fix) RegWrite("HKEY_CURRENT_USER\Software\Fullscreen Slideshow", "ForceFSSOn", "REG_SZ", 0) ;Main Program While 1 ToolTip($timerSeconds * 1000, 100, 5, TimerDiff($imageTimer)) If TimerDiff($imageTimer) > ($timerSeconds * 1000) Then Exit EndIf ;Debug ;~ ToolTip(CheckIfFSSshouldDisplay() & @CRLF & _ ;~ "Active: " & $activeWindowPosition[0] & ", " & $activeWindowPosition[1] & @CRLF & _ ;~ "Mouse: " & MouseGetPos(0) & ", " & MouseGetPos(1) & @CRLF & _ ;~ "Desktop: " & $desktop & @CRLF & _ ;~ "Monitor: " & @DesktopWidth & "x" & @DesktopHeight _ ;~ , 100, 5) ;========================== ;ToolTip(TimerDiff($screenSaverTimer), 100, 5) ;Show Tray Icon? If $showIcon = "No" Then AutoItSetOption("TrayIconHide", 1) Else AutoItSetOption("TrayIconHide", 0) EndIf ;Start with Windows? If $startWithWindows = "Yes" Then If RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", "Fullscreen Slideshow") = "" Then RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", "Fullscreen Slideshow", "REG_SZ", '"' & @ScriptFullPath & '"') EndIf Else If RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", "Fullscreen Slideshow") <> "" Then RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", "Fullscreen Slideshow") EndIf EndIf ;Close program if Screensaver closes If $closeWithScreensaver = "Yes" Then If $screenSaverOpened = 1 Then If ProcessExists("Fullscreen Screensaver.exe") = 0 Then Exit EndIf EndIf EndIf ;Make sure Fullscreen Screensaver is running If $runScreensaver = "Yes" Then If ProcessExists("Fullscreen Screensaver.exe") = 0 Then Run("D:\Autoit Scripts\Fullscreen Screensaver.exe") $screenSaverOpened = 1 Else $screenSaverOpened = 1 EndIf EndIf ;Always keep FSS on top of other windows WinSetOnTop("Fullscreen Slideshow", "", 0) WinSetOnTop("Fullscreen Slideshow", "", 1) ;If Fullscreen Slideshow becomes the active window, change to FSS If WinActive("Fullscreen Slideshow", "") <> 0 Then WinActivate("FSS", "") EndIf ;Should Fullscreen Slideshow be on or off If CheckIfFSSshouldDisplay() = "Show" Then If $activationMode = "Inactive" Then ;Monitor not in use WinSetState("Fullscreen Slideshow", "", @SW_SHOW) Else ;$activationMode = "Timer" (Screensaver mode) If TimerDiff($screenSaverTimer) > ($ssTimerSeconds * 1000) Then WinSetState("Fullscreen Slideshow", "", @SW_SHOW) EndIf EndIf Else ;Skype Black Screen Glitch ;============ If WinExists("[CLASS:tchatcontentcontrol]") = 1 Then WinClose("[CLASS:tchatcontentcontrol]") EndIf ;============ WinSetState("Fullscreen Slideshow", "", @SW_HIDE) $refreshImage = 1 $screenSaverTimer = TimerInit() ;Reset Screensaver Timer EndIf ;Changing the Image If RegRead("HKEY_CURRENT_USER\Software\Fullscreen Slideshow", "Mode") <> "Monitor Off" Then $imageChangedBlack = 0 If $changeMode = "Refresh" Then If $refreshImage = 1 Then $refreshImage = 0 GetImage() _GDIPlus_ImageDispose($pic) $hHBmp = $pictureFolder & "\" & $imageList[$picName] $gdiPic = _GDIPlus_BitmapCreateFromFile($hHBmp) ;convert GDI bitmap to GDI+ bitmap _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore $pic = _GDIPlus_ImageResize($gdiPic, $imageWidth, $imageHeight) ;resize image $hGraphics = _GDIPlus_GraphicsCreateFromHWND($GUI) ;create a graphics object from a window handle _GDIPlus_GraphicsDrawImage($hGraphics, $pic, $smCenterX, $smCenterY) ;display scaled image EndIf Else ;$changeMode = "Timer" If TimerDiff($imageTimer) > ($timerSeconds * 1000) Then GetImage() ;How to dispose of image? $hHBmp = $pictureFolder & "\" & $imageList[$picName] $gdiPic = _GDIPlus_BitmapCreateFromFile($hHBmp) ;convert GDI bitmap to GDI+ bitmap _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore $pic = _GDIPlus_ImageResize($gdiPic, $imageWidth, $imageHeight) ;resize image $hGraphics = _GDIPlus_GraphicsCreateFromHWND($GUI) ;create a graphics object from a window handle _GDIPlus_GraphicsDrawImage($hGraphics, $pic, $smCenterX, $smCenterY) ;display scaled image $imageTimer = TimerInit() ;Reset Image Change Timer EndIf EndIf Else ;Use Black Image If $imageChangedBlack = 0 Then $imageChangedBlack = 1 GUICtrlDelete($pic) $pic = GUICtrlCreatePic("D:\All Black.jpg", 0, 0, $smWidth, $smHeight) EndIf EndIf ;Hide/Show Taskbar If MouseGetPos(0) > 0 And MouseGetPos(0) < @DesktopWidth Then ;If mouse is in main monitor If MouseGetPos(1) > (@DesktopHeight - 2) Then ;If mouse is at bottom of screen ShowTaskBar() ElseIf MouseGetPos(1) < (@DesktopHeight - $taskbarSize) Then ;If mouse leaves taskbar area If RegRead("HKEY_CURRENT_USER\Software\Fullscreen Slideshow", "Blink Taskbar") = 0 Then HideTaskBar() EndIf Else If RegRead("HKEY_CURRENT_USER\Software\Fullscreen Slideshow", "Blink Taskbar") = 0 Then HideTaskBar() EndIf ;Only every 5 times If $checkCount > 5 Then $checkCount = 1 ;Pre-cautionary in case of changes in Monitor dimensions (if secondary monitor is unplugged) MoveWindow() ;Check settings for changes GetSettings() Else $checkCount += 1 EndIf ;Allow CPU to rest Sleep(100) WEnd _GDIPlus_Shutdown() Func GetImage() Local $newPic = 0 ;Change count, if image folder changes CheckForImageChanges() If $randomImages = "Ordered" Then ;Counted Images default is 0 $countedImages += 1 ;If the the counted images surpasses the number of images that are there, then reset the count If $countedImages > $imageCount Then $countedImages = 1 EndIf $picName = $countedImages ElseIf $randomImages = "Random" Then ;Select a random image from the list $picName = Random(1, $imageCount, 1) Else ;$randomImages = "Random No Repeat" If $reset = 1 Then $reset = 0 $resetCount = 0 For $x = 1 To $imageCount Step +1 $imageShown[$x] = "" Next EndIf While $newPic <> 1 $picName = Random(1, $imageCount, 1) ;Pick a random image ;Check if image has been shown For $y = 1 To $imageCount Step +1 If $picName = $imageShown[$y] Then $imageWasShown = 1 EndIf Next ;y If $imageWasShown = 1 Then $imageWasShown = 0 $newPic = 0 Else $newPic = 1 $resetCount += 1 EndIf If $resetCount = $imageCount Then $reset = 1 EndIf WEnd ;Save image to shown image list ;Store name in next available empty slot For $x = 1 To $imageCount Step +1 If $imageShown[$x] = "" Then $imageShown[$x] = $picName ;Save image to shown image list ExitLoop ;End loop early EndIf Next EndIf ;Get Dimensions of image GetDimensions($imageList[$picName]) $imageHeight = $pHeight $imageWidth = $pWidth ;Adjust the image size ;----------------------------------------------- ;If the image is bigger than the screen, adjust it If $imageWidth > $smWidth Or $imageHeight > $smHeight Then ;Get aspect ratio $aspectRatioX = $smWidth / $imageWidth ;Aspect ratio = 1280 / image X $aspectRatioY = $smHeight / $imageHeight ;Aspect ratio = 800 / image Y If $aspectRatioX < $aspectRatioY Then ;Image is wide ;New Height $imageHeight = $smWidth * ($imageHeight / $imageWidth) $imageWidth = $smWidth Else ;Image is tall ;New Width $imageWidth = $smHeight * ($imageWidth / $imageHeight) $imageHeight = $smHeight EndIf $imageWidth = Int($imageWidth) ;Convert iW into integer $imageHeight = Int($imageHeight) ;Convert iH into integer EndIf ;Calculate Center ;(Monitor size - image size) / 2 $smCenterX = ($smWidth - $imageWidth) / 2 $smCenterY = ($smHeight - $imageHeight) / 2 EndFunc ;==>GetImage Func GetDimensions($picName) Local $prop, $dArray $path = $pictureFolder & "\" & $picName $prop = _GetFileProperty($path, "Dimensions") $dArray = StringSplit($prop, " x ") $pWidth = Number(StringMid($dArray[1], 2)) $pHeight = Number($dArray[4]) EndFunc ;==>GetDimensions Func MoveWindow() Local $position = WinGetPos("Fullscreen Slideshow") If $smPosition = "Left" Then If $position[0] <> (-1 * $smWidth) Or $position[1] <> $smHeight Then WinMove("Fullscreen Slideshow", "", (-1 * $smWidth), 0, $smWidth, $smHeight) EndIf Else If $position[0] <> @DesktopWidth Or $position[1] <> $smHeight Then WinMove("Fullscreen Slideshow", "", @DesktopWidth, 0, $smWidth, $smHeight) EndIf EndIf EndFunc ;==>MoveWindow Func HideTaskBar() ControlHide('', '', WinGetHandle("[CLASS:Shell_TrayWnd]")) ControlHide('', '', WinGetHandle("[CLASS:Button]")) EndFunc ;==>HideTaskBar Func ShowTaskBar() ControlShow('', '', WinGetHandle("[CLASS:Shell_TrayWnd]")) ControlShow('', '', WinGetHandle("[CLASS:Button]")) EndFunc ;==>ShowTaskBar Func CheckIfFSSshouldDisplay() Local $decided = 0 Local $returnValue ;Is selected window the Desktop? $winSize = WinGetClientSize("") If $winSize = "" Then ;Prevents non-accessible glitch $desktop = 0 Else If $winSize[0] = @DesktopWidth + $smWidth Then ;Desktop $desktop = 1 Else $desktop = 0 EndIf EndIf ;Where is the active window $activeWindowPosition = WinGetPos("[ACTIVE]") If $smPosition = "Left" Then If $activeWindowPosition[0] < 0 Then ;If Active Window is in monitor on left If $desktop = 0 Then $decided = 1 $returnValue = "Hide" Else $returnValue = "Show" EndIf EndIf Else ;$smPosition = "Right" If $activeWindowPosition[0] > (@DesktopWidth - 1) Or _ ;If Active Window is in monitor on right $activeWindowPosition[0] = (@DesktopWidth - 8) Then ;If Active Window is fullscreen If $desktop = 0 Then $decided = 1 $returnValue = "Hide" Else $returnValue = "Show" EndIf EndIf EndIf ;Only check if undecided If $decided = 0 Then ;Where is the mouse located If $smPosition = "Left" Then If MouseGetPos(0) < 0 Then ;If mouse is in monitor on left $decided = 1 $returnValue = "Hide" EndIf Else ;$smPosition = "Right" If MouseGetPos(0) > @DesktopWidth Then ;If mouse is in monitor on right $decided = 1 $returnValue = "Hide" EndIf EndIf If $decided = 0 Then ;Is there a special Window that is active? $mPos = _WinAPI_GetMousePos() $hwnd = _WinAPI_WindowFromPoint($mPos) ;If $hwnd = $inputDirector Then ;Is VNC active? If WinGetTitle($hwnd) = "Cursor Hider" Then $decided = 1 ;Temporary while VNC is in main window ;$returnValue = "Hide" $returnValue = "Show" EndIf EndIf EndIf ;Is the Toggle set to hide? ;Is Screensaver Off? If RegRead("HKEY_CURRENT_USER\Software\Fullscreen Slideshow", "ForceFSSOn") = 0 Then If RegRead("HKEY_CURRENT_USER\Software\Fullscreen Slideshow", "Mode") = "Hide" Then ;Replace Black with image, in anticipation of screen turning back on _GDIPlus_BitmapDispose($pic) $pic = GUICtrlCreatePic($pictureFolder & "\" & $imageList[$picName], 0, 0, $imageWidth, $imageHeight) ;Pic Control is the size of image GUICtrlSetPos($pic, $smCenterX, $smCenterY) GUISetBkColor(0) ;Hide GUI $decided = 1 $returnValue = "Hide" EndIf Else $returnValue = "Show" ;Screensaver is active EndIf ;If no issues, then show If $decided = 0 Then $returnValue = "Show" EndIf Return $returnValue EndFunc ;==>CheckIfFSSshouldDisplay Func CheckForImageChanges() Local $newCount = _FileListToArray($pictureFolder) If $newCount[0] <> $imageCount Then $imageList = _FileListToArray($pictureFolder) $imageCount = $imageList[0] ReDim $imageShown[$imageCount + 1] EndIf EndFunc ;==>CheckForImageChanges Func GetSettings() Global $settingsFile = FileOpen(@WorkingDir & "\FSS.txt", 0) Local $lineNumber = 1 Local $line = FileReadLine($settingsFile, $lineNumber) Local $lineSplit, $description, $value ;Move to the Fullscreen Slideshow Section While $line <> "Fullscreen Slideshow" $line = FileReadLine($settingsFile, $lineNumber) $lineNumber += 1 Sleep(10) WEnd $lineNumber += 2 ;Move past the divider line ;Read until the next section While $line <> ";====================================" $line = FileReadLine($settingsFile, $lineNumber) If $line = ";====================================" Then ExitLoop EndIf ;Split line by Description and value $lineSplit = StringSplit($line, " = ", 1) $description = $lineSplit[1] $value = $lineSplit[2] If $description = "Picture Folder" Then Global $pictureFolder = $value ElseIf $description = "Show Tray Icon" Then Global $showIcon = $value ElseIf $description = "Secondary Monitor Width" Then Global $smWidth = $value ElseIf $description = "Secondary Monitor Height" Then Global $smHeight = $value ElseIf $description = "Monitor Position (Left, Right)" Then Global $smPosition = $value ElseIf $description = "Activation Mode (Inactive, Timer)" Then Global $activationMode = $value ElseIf $description = "Timer Seconds" Then Global $ssTimerSeconds = $value ElseIf $description = "Change Method (Timer, Refresh)" Then Global $changeMode = $value ElseIf $description = "Image Change Time (In Seconds)" Then Global $timerSeconds = $value ElseIf $description = "Image Order (Ordered, Random, Random No Repeat)" Then Global $randomImages = $value ElseIf $description = "Taskbar Size (Default: 40)" Then Global $taskbarSize = $value ElseIf $description = "Run Screensaver (Yes, No)" Then Global $runScreensaver = $value ElseIf $description = "Close with Screensaver (Yes, No)" Then Global $closeWithScreensaver = $value ElseIf $description = "Start with Windows (Yes, No)" Then Global $startWithWindows = $value EndIf $lineNumber += 1 Sleep(10) WEnd FileClose($settingsFile) EndFunc ;==>GetSettings Func GetMonitorInformation() Local $mouseX, $mouseX2, $mouseY, $mouseY2, $monitorPosition, $smResolutionX, $smResolutionY BlockInput(1) MsgBox(0, "Calibrating", "Calibrating Monitors, please wait...", 3) MouseMove(0, 0, 0) Sleep(200) $mouseX = MouseGetPos(0) $mouseY = MouseGetPos(1) ;Get X Resolution MouseMove(MouseGetPos(0) - 1, 0, 5) ;Move mouse 1 pixel left $mouseX2 = MouseGetPos(0) ;Save new position to mx2 While $mouseX <> $mouseX2 ;If position is different $mouseX = MouseGetPos(0) ;save position to mx1 MouseMove(MouseGetPos(0) - 1, 0, 5) ;move mouse to left $mouseX2 = MouseGetPos(0) ;save position to mx2 Sleep(10) WEnd ;compare again If (MouseGetPos(0)) < 0 Then $monitorPosition = "Left" ;Get Y Resolution EndIf MsgBox(0, "Complete", "Monitors have been calibrated, thank you.", 3) BlockInput(0) EndFunc ;==>GetMonitorInformation