Sori

This program is long and complex. <3

8 posts in this topic

Firstly... this program creates a slideshow on a secondary monitor, as well as a screensaver slideshow on the primary monitor.

It's a bit overwhelming if you just dive into it, but it's coded fairly easy and there are comments to explain what's going on.

I have 2 annoying errors.

Error 1: Lines 136 - 141

For some reason, it doesn't reset the txt file.

Minor annoyance, it just causes my logs to be very large at times so they open slow and are hard to scroll through.

Local $logFileSize = FileGetSize($logFile)
    If $logFileSize > 5242880 Then ;5 megabytes
        FileClose($logFile)
        FileDelete($logFile)
        $logFile = FileOpen(@WorkingDir & "\FSS Log.txt", 2) ;Erases log file due to extreme size
    EndIf

Error 2: Lines 1039 - 1067

I'll explain what's going on in this...

System Idle alone isn't enough to tell the screensaver not to run. It doesn't account for videos (youtube, Netflix, etc)

So, to combat this... Several screenshots are taken of the screen, then compared to the current screen. This will tell the program if the screen is changing.

My error is that sometimes it will properly take screenshots and all is well, and sometimes it won't. The workaround is to check if the screenshots have been taken, and then skip the comparison if they have not.

My workaround still has issues sometimes, which I'm working on -.-

Memo: I notice the errors with the compiled script. I'm not sure if the same thing happens when running straight from the au3

Func CaptureScreen()
    LogProgram("=CaptureScreen=")
    $currentShot = 1
    LogProgram("ssRows: " & $ssRows)
    LogProgram("ssColumns: " & $ssColumns)
    LogProgram("currentShot: " & $currentShot)
    ;Vertical
    For $currentYpos = 0 To $ssRows - 1 Step +1
        LogProgram("currentYpos: " & $currentYpos)
        ;Horizontal
        For $currentXpos = 0 To $ssColumns - 1 Step +1
            LogProgram("currentXpos: " & $currentXpos)
            _ScreenCapture_Capture(@WorkingDir & "\Screensaver\screensaver " & $currentShot & ".bmp", _
                    ($incrementX * $currentXpos), _
                    ($incrementY * $currentYpos), _
                    ($incrementX * ($currentXpos + 1)), _
                    $incrementY * ($currentYpos + 1), 0)
            If FileExists(@WorkingDir & "\Screensaver\screensaver " & $currentShot & ".bmp") = 1 Then
                LogProgram("screensaver " & $currentShot & ".bmp saved")
            Else
                LogProgram("screensaver " & $currentShot & ".bmp save error")
                $captureError = 1
            EndIf
            $currentShot += 1
            LogProgram("currentShot: " & $currentShot)
            Sleep(50)
        Next ;x
        Sleep(50)
    Next ;y

Whole Program:

#include <File.au3>
#include <GetFileProperty.au3>
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <Timers.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <Array.au3>
#include <ImageSearch.au3>
#include <ScreenCapture.au3>
#include <GDIPlus.au3>
#include <Date.au3>

;Find Log File information
Local $logCheck = FileOpen(@WorkingDir & "\FSS.txt", 0)
Local $line = FileReadLine($logCheck, 1)
If StringSplit($line, " = ", 1)[2] = "On" Then
    Global $keepLog = 1
Else
    Global $keepLog = 0
EndIf
FileClose($logCheck)

Global $logFile = FileOpen(@WorkingDir & "\FSS Log.txt", 2) ;Overwrites previous contents of file
FileWrite($logFile, "Program Start" & @CRLF)
FileWrite($logFile, "Time: " & _NowTime() & ", " & _NowDate() & @CRLF & @CRLF)
_GDIPlus_Startup()

;Only allow one instance of the program to run.
If _Singleton("Fullscreen Slideshow", 1) = 0 Then
    Exit
EndIf

Global $pictureFolder ;Fixes declared warning
;Settings
;====================================
;Can be edited via external text file (FSS.txt)
GetSettings()
;====================================

Global $desktop
Global $ssTimerSet = 0
Global $countedImages = 0
Global $imageWasShown = 1
Global $hidden = 0
Global $VNChidden = 0
Global $LoopCount = 1
Global $taskbarActivationHide = 0
Global $imageList = _FileListToArray($pictureFolder)
Global $imageCount = $imageList[0]
Global $imageShown[$imageCount + 1]
Global $resetCount = 0
Global $reset = 0
Global $changeImage = 0
Global Const $STM_SETIMAGE = 0x0172
Global $currActiveWindow = WinGetHandle("")
Global $smImageChangeBlack = 0
Global $smImageWidth, $smImageHeight, $smpHeight, $smpWidth, $smCenterX, $smCenterY, _
        $smPicName, $activeWindowPosition, $smRefreshImage, $smImageChangeTimer, $smSSMTimer, _
        $startWithWindows, $closeWithScreensaver, $smPic, $smGdiPic, $position
Global $pmImageWidth, $pmImageHeight, $pmpHeight, $pmpWidth, $pmCenterX, $pmCenterY, _
        $pmPicName, $pmSSTimer, $pmPic, $pmGdiPic, $pmSSChangeTimer, $blinkTaskbar, $forceFSSOn
Global $pmGUIhandle, $smGUIhandle, $captureError
Global $changeQuadrant = ($ssChangePercent * 0.01) * ($ssRows * $ssColumns)
Global $screenShotCount = $ssRows * $ssColumns
Global $currentShot = 1
Global $incrementX = @DesktopWidth / $ssColumns
Global $incrementY = @DesktopHeight / $ssRows
Global $currentXpos, $currentYpos, $result
Global $pmChangeImage = 1
Global $screenSaverIsOn = 0
Global $winSize[2]

;Prevents CloseProgram() function on startup
RegWrite("HKEY_CURRENT_USER\Software\Fullscreen Slideshow", "Close Program", "REG_SZ", 0)

;Preliminary setup - Creates GUI, displays 1 image
;====================================
GetImageForDisplaySM()
GetImageForDisplayPM()
CreateGUI()
MoveGUIWindow()
$smImageChangeTimer = TimerInit() ;Reset Image Change Timer
$pmSSTimer = TimerInit() ;Reset Primary Screensaver Timer
$pmSSChangeTimer = TimerInit() ;Reset Primary Screensaver Image Change Timer
ShowImageSM()
ShowImagePM()
;Main Program
;====================================
While 1
    ;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)
    ;======
;~  Local $temp = _Timer_GetIdleTime()
;~  ToolTip("SS: " & $screenSaverIsOn & @CRLF & "Idle: " & $temp, 100, 5)

    ;==========================

    ;These functions are set in settings (FSS.txt)
    ShowTrayIcon() ;Should Tray Icon be shown?
    StartWithWindows() ;Start program with Windows? (doesn't function)
    ;================
    AlwaysOnTop() ;Force slideshow to be on top of other windows
    LoseFocus() ;Lose focus in case slideshow becomes the active window

    ;Should Fullscreen Slideshow be on or off
    If CheckIfFSSshouldDisplay() = "Show" Then
        ShowFSS()
    Else
        HideFSS()
    EndIf
    ScreensaverOperations()
    ChangeImageSM()
    DisplayTaskbar()
    CloseProgram()

    ;Only every 5 times
    LogProgram("Loop Count: " & $LoopCount)
    FileWrite($logFile, "Loop Count: " & $LoopCount & @CRLF)
    If $LoopCount > 5 Then
        $LoopCount = 1
        ;Pre-cautionary in case of changes in Monitor dimensions (if secondary monitor is unplugged)
        MoveGUIWindow()
        ;Check settings for changes
        GetSettings()
    Else
        $LoopCount += 1
    EndIf

    LogProgram(@CRLF & "=======================================================================")
    Local $logFileSize = FileGetSize($logFile)
    If $logFileSize > 5242880 Then ;5 megabytes
        FileClose($logFile)
        FileDelete($logFile)
        $logFile = FileOpen(@WorkingDir & "\FSS Log.txt", 2) ;Erases log file due to extreme size
    EndIf
    ;Allow CPU to rest
    Sleep(10)
    LogProgram("Time: " & _NowTime() & ", " & _NowDate())
WEnd

;Beginning of Functions
;====================================

Func GetSettings()
    LogProgram("=Get Settings=")
    Global $settingsFile = FileOpen(@WorkingDir & "\FSS.txt", 0)
    Local $lineNumber = 1
    LogProgram("lineNumber: " & $lineNumber)
    Local $line = FileReadLine($settingsFile, $lineNumber)
    Local $lineSplit, $description, $value

    ;Move to the Fullscreen Slideshow Section
    While $line <> "Fullscreen Slideshow"
        $line = FileReadLine($settingsFile, $lineNumber)
        LogProgram("lineNumber: " & $lineNumber)
        LogProgram("line: " & $line)
        $lineNumber += 1
        Sleep(10)
    WEnd

    ;Read until the next section
    While $line <> "Fullscreen Screensaver"
        $line = FileReadLine($settingsFile, $lineNumber)
        If $line = "Fullscreen Screensaver" Then
            ExitLoop
        ElseIf $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
            LogProgram("Picture Folder: " & $value)
            $pictureFolder = $value
        ElseIf $description = "Show Tray Icon" Then
            LogProgram("Show Tray Icon: " & $value)
            Global $showIcon = $value
        ElseIf $description = "Secondary Monitor Width" Then
            LogProgram("SM Width: " & $value)
            Global $smWidth = $value
        ElseIf $description = "Secondary Monitor Height" Then
            LogProgram("SM Height: " & $value)
            Global $smHeight = $value
        ElseIf $description = "Monitor Position (Left, Right)" Then
            LogProgram("SM Position: " & $value)
            Global $smPosition = $value
        ElseIf $description = "Activation Mode (Inactive, Timer)" Then
            LogProgram("SM Activation Mode: " & $value)
            Global $smActivationMode = $value
        ElseIf $description = "Screensaver Mode Timer Seconds" Then
            LogProgram("SMSSM Seconds: " & $value)
            Global $smSSMsec = $value
            $smSSMsec = $smSSMsec * 1000 ;Convert to milliseconds
        ElseIf $description = "Change Method (Timer, Refresh)" Then
            LogProgram("SM Change Method: " & $value)
            Global $smChangeMethod = $value
        ElseIf $description = "Image Change Time (In Seconds)" Then
            LogProgram("SM Image Change Seconds: " & $value)
            Global $smImageChangeSec = $value
            $smImageChangeSec = $smImageChangeSec * 1000 ;Convert to milliseconds
        ElseIf $description = "Image Order (Ordered, Random, Random No Repeat)" Then
            LogProgram("SM Image Order: " & $value)
            Global $smImageOrder = $value
        ElseIf $description = "Taskbar Size (Default: 40)" Then
            LogProgram("Taskbar Size: " & $value)
            Global $taskbarSize = $value
        ElseIf $description = "Start with Windows (Yes, No)" Then
            LogProgram("Start with Windows: " & $value)
            Global $startWithWindows = $value
        EndIf
        $lineNumber += 1
    WEnd

    $lineNumber += 2 ;Move past 'Fullscreen Screensaver' line

    ;Read until the next section
    While $line <> ";===================================="
        $line = FileReadLine($settingsFile, $lineNumber)
        LogProgram("lineNumber: " & $lineNumber)
        LogProgram("line: " & $line)
        If $line = ";====================================" Then
            ExitLoop
        EndIf
        ;Split line by Description and value
        $lineSplit = StringSplit($line, " = ", 1)
        $description = $lineSplit[1]
        $value = $lineSplit[2]
        If $description = "Turn Screensaver On (Yes, No)" Then
            LogProgram("Screensaver Turned On?: " & $value)
            Global $screensaverActivated = $value
        ElseIf $description = "Activation Time (In Seconds)" Then
            LogProgram("Screensaver Activation Seconds: " & $value)
            Global $pmSSActivationSec = $value
            $pmSSActivationSec = $pmSSActivationSec * 1000 ;Convert to milliseconds
        ElseIf $description = "Image Change Time (In Seconds)" Then
            LogProgram("Screensaver Image Change Seconds: " & $value)
            Global $pmSSChangeImageSec = $value
            $pmSSChangeImageSec = $pmSSChangeImageSec * 1000 ;Convert to milliseconds
        ElseIf $description = "Taskbar Blink Time (In Seconds)" Then
            Global $taskbarBlinkSec = $value
            $taskbarBlinkSec = $taskbarBlinkSec * 1000 ;Convert to milliseconds
        ElseIf $description = "Rows (Horizontal Cuts)" Then
            LogProgram("Rows: " & $value)
            Global $ssRows = $value
        ElseIf $description = "Columns (Vertical Cuts)" Then
            LogProgram("Columns: " & $value)
            Global $ssColumns = $value
        ElseIf $description = "Percent" Then
            LogProgram("Change %: " & $value)
            Global $ssChangePercent = $value
        ElseIf $description = "Check Count" Then
            LogProgram("Check Count: " & $value)
            Global $ssCheckCount = $value
        EndIf
        $lineNumber += 1
        Sleep(50)
    WEnd

    FileClose($settingsFile)
    LogProgram("=End Get Settings=" & @CRLF)
EndFunc   ;==>GetSettings

Func GetImageForDisplaySM()
    LogProgram("=GetImageForDisplaySM=")
    Local $newPic = 0
    Local $smhHBmp ;for GDI (secondary)

    ;Check image folder for count change
    LogProgram("=GetImageForDisplaySM calling=")
    CheckForImageChanges()

    ;Throw away value to prevent error with GetDimensions
    $pmPicName = Random(1, $imageCount, 1)

    ;Secondary Monitor
    ;Images should go in order by file
    LogProgram("Image Order:" & $smImageOrder)
    If $smImageOrder = "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
        $smPicName = $countedImages
        ;Select a random image from the list
    ElseIf $smImageOrder = "Random" Then
        ;Select a random image from the list
        $smPicName = Random(1, $imageCount, 1)
        ;Select a random image, but do not show the same image twice
    Else ;$smImageOrder = "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
            $smPicName = Random(1, $imageCount, 1) ;Pick a random image
            ;Check if image has been shown
            For $y = 1 To $imageCount Step +1
                If $smPicName = $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] = $smPicName ;Save image to shown image list
                ExitLoop ;End loop early
            EndIf
        Next
    EndIf
    LogProgram("(SM) Selected Image SM: " & $imageList[$smPicName])
    LogProgram("(SM - Throw Away)Selected Image PM: " & $imageList[$pmPicName])

    ;Get Dimensions of image
    LogProgram("=GetImageForDisplaySM calling=")
    GetDimensions($imageList[$smPicName], $imageList[$pmPicName])
    $smImageHeight = $smpHeight
    $smImageWidth = $smpWidth

    ;Turn them all into integers. (Fixes glitch that caused some images to skip resizing)
    $smImageHeight = Int($smImageHeight)
    $smImageWidth = Int($smImageWidth)
    $smHeight = Int($smHeight)
    $smWidth = Int($smWidth)

    LogProgram("Pre-Adjust")
    LogProgram("smImageHeight: " & $smImageHeight)
    LogProgram("smImageWidth: " & $smImageWidth)
    LogProgram("smHeight: " & $smHeight)
    LogProgram("smWidth: " & $smWidth)

    ;Adjust the image size
    ;-----------------------------------------------
    ;If the image is bigger than the screen, adjust it
    If $smImageWidth > $smWidth = 1 Or $smImageHeight > $smHeight = 1 Then
        ;Get aspect ratio
        $aspectRatioX = $smWidth / $smImageWidth ;Aspect ratio = monitor horizontal / image X
        $aspectRatioY = $smHeight / $smImageHeight ;Aspect ratio = monitor vertical / image Y
        LogProgram("aspectRatioX: " & $aspectRatioX)
        LogProgram("aspectRatioY: " & $aspectRatioY)
        If $aspectRatioX < $aspectRatioY Then
            LogProgram("Image is Wide")
            ;New Height
            $smImageHeight = $smWidth * ($smImageHeight / $smImageWidth)
            $smImageWidth = $smWidth
            LogProgram("New smImageHeight: " & $smImageHeight)
            LogProgram("New smImageWidth: " & $smImageWidth)
        Else
            LogProgram("Image is Tall")
            ;New Width
            $smImageWidth = $smHeight * ($smImageWidth / $smImageHeight)
            $smImageHeight = $smHeight
            LogProgram("New smImageHeight: " & $smImageHeight)
            LogProgram("New smImageWidth: " & $smImageWidth)
        EndIf
    Else
        LogProgram("Image is smaller/same size as monitor")
    EndIf

    ;Calculate Center of monitor
    ;(Monitor size - image size) / 2
    $smCenterX = ($smWidth - $smImageWidth) / 2
    $smCenterY = ($smHeight - $smImageHeight) / 2
    LogProgram("smCenterX: " & $smCenterX)
    LogProgram("smCenterY: " & $smCenterY)

    ;Resize the image
    LogProgram("Resize Image SM")
    $smhHBmp = $pictureFolder & "\" & $imageList[$smPicName]
    $smGdiPic = _GDIPlus_BitmapCreateFromFile($smhHBmp) ;convert GDI bitmap to GDI+ bitmap
    _WinAPI_DeleteObject($smhHBmp) ;release GDI bitmap resource because not needed anymore
    $smPic = _GDIPlus_ImageResize($smGdiPic, $smImageWidth, $smImageHeight) ;resize image
    LogProgram("=End GetImageForDisplaySM=" & @CRLF)
EndFunc   ;==>GetImageForDisplaySM

Func GetImageForDisplayPM()
    LogProgram("=GetImageForDisplayPM=")
    Local $newPic = 0
    Local $pmhHBmp ;for GDI (primary)

    ;Check image folder for count change
    LogProgram("=GetImageForDisplayPM calling=")
    CheckForImageChanges()

    If $pmChangeImage = 1 Then
        $pmChangeImage = 0
        $pmPicName = Random(1, $imageCount, 1) ;Select a random image from the list for primary
    EndIf

    LogProgram("(PM - Throw Away) Selected Image SM: " & $imageList[$smPicName])
    LogProgram("(PM)Selected Image PM: " & $imageList[$pmPicName])

    ;Get Dimensions of image
    LogProgram("=GetImageForDisplayPM calling=")
    GetDimensions($imageList[$smPicName], $imageList[$pmPicName])
    $pmImageHeight = $pmpHeight
    $pmImageWidth = $pmpWidth

    ;Turn them all into integers. (Fixes glitch that caused some images to skip resizing)
    $pmImageHeight = Int($pmImageHeight)
    $pmImageWidth = Int($pmImageWidth)

    LogProgram("Pre-Adjust")
    LogProgram("pmImageHeight: " & $pmImageHeight)
    LogProgram("pmImageWidth: " & $pmImageWidth)
    LogProgram("pmHeight: " & @DesktopHeight)
    LogProgram("pmWidth: " & @DesktopWidth)

    ;Adjust the image size
    ;-----------------------------------------------
    ;If the image is bigger than the screen, adjust it
    If $pmImageWidth > @DesktopWidth Or $pmImageHeight > @DesktopHeight Then
        ;Get aspect ratio
        $aspectRatioX = @DesktopWidth / $pmImageWidth ;Aspect ratio = monitor horizontal / image X
        $aspectRatioY = @DesktopHeight / $pmImageHeight ;Aspect ratio = monitor vertical / image Y
        LogProgram("aspectRatioX: " & $aspectRatioX)
        LogProgram("aspectRatioY: " & $aspectRatioY)
        If $aspectRatioX < $aspectRatioY Then
            LogProgram("Image is Wide")
            ;New Height
            $pmImageHeight = @DesktopWidth * ($pmImageHeight / $pmImageWidth)
            $pmImageWidth = @DesktopWidth
            LogProgram("New pmImageHeight: " & $pmImageHeight)
            LogProgram("New pmImageWidth: " & $pmImageWidth)
        Else
            LogProgram("Image is Tall")
            ;New Width
            $pmImageWidth = @DesktopHeight * ($pmImageWidth / $pmImageHeight)
            $pmImageHeight = @DesktopHeight
            LogProgram("New pmImageHeight: " & $pmImageHeight)
            LogProgram("New pmImageWidth: " & $pmImageWidth)
        EndIf
    Else
        LogProgram("Image is smaller/same size as monitor")
    EndIf

    ;Calculate Center of monitor
    ;(Monitor size - image size) / 2
    $pmCenterX = (@DesktopWidth - $pmImageWidth) / 2
    $pmCenterY = (@DesktopHeight - $pmImageHeight) / 2
    LogProgram("pmCenterX: " & $pmCenterX)
    LogProgram("pmCenterY: " & $pmCenterY)

    ;Resize the image
    LogProgram("Resize Image PM")
    $pmhHBmp = $pictureFolder & "\" & $imageList[$pmPicName]
    $pmGdiPic = _GDIPlus_BitmapCreateFromFile($pmhHBmp) ;convert GDI bitmap to GDI+ bitmap
    _WinAPI_DeleteObject($pmhHBmp) ;release GDI bitmap resource because not needed anymore
    $pmPic = _GDIPlus_ImageResize($pmGdiPic, $pmImageWidth, $pmImageHeight) ;resize image
    LogProgram("=End GetImageForDisplayPM=" & @CRLF)
EndFunc   ;==>GetImageForDisplayPM

Func GetDimensions($smPicName, $pmPicName)
    LogProgram("=GetDimensions=")
    Local $prop, $dArray, $fileSize, $imageDimensionsGDI

    ;Secondary Monitor
    LogProgram("-Secondary Monitor-")
    $path = $pictureFolder & "\" & $smPicName
    LogProgram("Path: " & $path)
    $fileSize = FileGetSize($path)
    LogProgram("File Size: " & $fileSize)
    LogProgram("Registry Size: " & RegRead("HKEY_CURRENT_USER\Software\Fullscreen Slideshow\Pictures", $smPicName & " Size"))
    ;Save information to registry for faster access. Compare size of picture to verify changes to picture
    If $fileSize <> RegRead("HKEY_CURRENT_USER\Software\Fullscreen Slideshow\Pictures", $smPicName & " Size") Then
        LogProgram("File Sizes Do Not Match")
        RegWrite("HKEY_CURRENT_USER\Software\Fullscreen Slideshow\Pictures", $smPicName & " Size", "REG_SZ", $fileSize)
        $imageDimensionsGDI = _GDIPlus_ImageLoadFromFile($path)
        $smpWidth = _GDIPlus_ImageGetWidth($imageDimensionsGDI)
        $smpHeight = _GDIPlus_ImageGetHeight($imageDimensionsGDI)
        _GDIPlus_ImageDispose($imageDimensionsGDI)
;~      $prop = _GetFileProperty($path, "Dimensions")
;~      $dArray = StringSplit($prop, " x ")
;~      $smpWidth = Number(StringMid($dArray[1], 2))
;~      $smpHeight = Number($dArray[4])
        RegWrite("HKEY_CURRENT_USER\Software\Fullscreen Slideshow\Pictures", $smPicName & " Width", "REG_SZ", $smpWidth)
        RegWrite("HKEY_CURRENT_USER\Software\Fullscreen Slideshow\Pictures", $smPicName & " Height", "REG_SZ", $smpHeight)
    Else
        LogProgram("File Sizes Match")
        $smpWidth = RegRead("HKEY_CURRENT_USER\Software\Fullscreen Slideshow\Pictures", $smPicName & " Width")
        $smpHeight = RegRead("HKEY_CURRENT_USER\Software\Fullscreen Slideshow\Pictures", $smPicName & " Height")
    EndIf
    LogProgram("smpWidth: " & $smpWidth)
    LogProgram("smpHeight: " & $smpHeight)

    ;Primary Monitor
    LogProgram("-Primary Monitor-")
    $path = $pictureFolder & "\" & $pmPicName
    LogProgram("Path: " & $path)
    $fileSize = FileGetSize($path)
    LogProgram("File Size: " & $fileSize)
    LogProgram("Registry Size: " & RegRead("HKEY_CURRENT_USER\Software\Fullscreen Slideshow\Pictures", $pmPicName & " Size"))
    ;Save information to registry for faster access. Compare size of picture to verify changes to picture
    If $fileSize <> RegRead("HKEY_CURRENT_USER\Software\Fullscreen Slideshow\Pictures", $pmPicName & " Size") Then
        LogProgram("File Sizes Do Not Match")
        RegWrite("HKEY_CURRENT_USER\Software\Fullscreen Slideshow\Pictures", $pmPicName & " Size", "REG_SZ", $fileSize)
        $imageDimensionsGDI = _GDIPlus_ImageLoadFromFile($path)
        $pmpWidth = _GDIPlus_ImageGetWidth($imageDimensionsGDI)
        $pmpHeight = _GDIPlus_ImageGetHeight($imageDimensionsGDI)
        _GDIPlus_ImageDispose($imageDimensionsGDI)
;~      $prop = _GetFileProperty($path, "Dimensions")
;~      $dArray = StringSplit($prop, " x ")
;~      $pmpWidth = Number(StringMid($dArray[1], 2))
;~      $pmpHeight = Number($dArray[4])
        RegWrite("HKEY_CURRENT_USER\Software\Fullscreen Slideshow\Pictures", $pmPicName & " Width", "REG_SZ", $pmpWidth)
        RegWrite("HKEY_CURRENT_USER\Software\Fullscreen Slideshow\Pictures", $pmPicName & " Height", "REG_SZ", $pmpHeight)
    Else
        LogProgram("File Sizes Match")
        $pmpWidth = RegRead("HKEY_CURRENT_USER\Software\Fullscreen Slideshow\Pictures", $pmPicName & " Width")
        $pmpHeight = RegRead("HKEY_CURRENT_USER\Software\Fullscreen Slideshow\Pictures", $pmPicName & " Height")
    EndIf
    LogProgram("pmpWidth: " & $pmpWidth)
    LogProgram("pmpHeight: " & $pmpHeight)
    LogProgram("=End GetDimensions=" & @CRLF)
EndFunc   ;==>GetDimensions

Func CheckForImageChanges()
    LogProgram("=CheckForImageChanges=")
    Local $newCount = _FileListToArray($pictureFolder)
    LogProgram("Old Count: " & $imageCount)
    LogProgram("New Count: " & $newCount[0])
    If $newCount[0] <> $imageCount Then
        LogProgram("New Images Found")
        $imageList = _FileListToArray($pictureFolder)
        $imageCount = $imageList[0]
        ReDim $imageShown[$imageCount + 1]
    Else
        LogProgram("No New Images")
    EndIf
    LogProgram("=End CheckForImageChanges=" & @CRLF)
EndFunc   ;==>CheckForImageChanges

Func CreateGUI()
    LogProgram("=CreateGUI=")
    ;Hidden GUI for fixing if FSS becomes the active window
    GUICreate("FSS", 0, 0, 0, 0)
    LogProgram("FSS created")
    ;Parent, for window border hide effect
    $GUIHide = GUICreate("hide", 0, 0, 0, 0)
    LogProgram("hide created")
    ;Actual GUI to be used
    ;Slideshow GUI
    Global $smGUI = GUICreate("Fullscreen Slideshow", $smWidth, $smHeight, 0, 0, BitOR($WS_POPUP, $WS_EX_TOPMOST), -1, $GUIHide) ;GUI is the size of the secondary screen
    LogProgram("Fullscreen Slideshow created")
    $smGUIhandle = WinGetHandle("Fullscreen Slideshow", "")
    GUICtrlSetPos($smPic, $smCenterX, $smCenterY)
    GUISetBkColor(0, $smGUIhandle)
    LogProgram("smGUIhandle: " & $smGUIhandle)
    LogProgram("Show smGUI")
    GUISetState(@SW_SHOW, $smGUIhandle) ;Show SM GUI
    ;Screensaver GUI
    Global $pmGUI = GUICreate("Fullscreen Screensaver", @DesktopWidth, @DesktopHeight, 0, 0, BitOR($WS_POPUP, $WS_EX_TOPMOST), -1, $GUIHide) ;GUI is the size of the primary screen
    LogProgram("Fullscreen Screensaver created")
    $pmGUIhandle = WinGetHandle("Fullscreen Screensaver", "")
    LogProgram("pmGUIhandle: " & $pmGUIhandle)
    GUICtrlSetPos($pmPic, $pmCenterX, $pmCenterY)
    GUISetBkColor(0, $pmGUIhandle)
    LogProgram("Hide pmGUI")
    GUISetState(@SW_HIDE, $pmGUIhandle) ;Hide PM GUI
    LogProgram("=End CreateGUI=" & @CRLF)
EndFunc   ;==>CreateGUI

Func MoveGUIWindow()
    LogProgram("=MoveGUIWindow=")
    LogProgram("SM Position: " & $smPosition)
    ;Move GUI according to location of secondary monitor
    ;$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 ;Monitor on Right
        ;If $position[0] <> @DesktopWidth Or $position[1] <> $smHeight Then
        WinMove("Fullscreen Slideshow", "", @DesktopWidth, 0, $smWidth, $smHeight)
        ;EndIf
    EndIf
    WinMove("Fullscreen Screensaver", "", 0, 0, @DesktopWidth, @DesktopHeight)
    LogProgram("=End MoveGUIWindow=" & @CRLF)
EndFunc   ;==>MoveGUIWindow

Func ShowImageSM()
    LogProgram("=ShowImageSM=")
    LogProgram("smImageChangeBlack: " & $smImageChangeBlack)
    If $smImageChangeBlack = 0 Then
        Local $smhGraphics = _GDIPlus_GraphicsCreateFromHWND($smGUI) ;create a graphics object from a window handle
        _GDIPlus_GraphicsDrawImage($smhGraphics, $smPic, $smCenterX, $smCenterY) ;display scaled image
        LogProgram("smhGraphics: " & $smhGraphics)
        LogProgram("smPic: " & $smPic)
        LogProgram("smCenterX: " & $smCenterX)
        LogProgram("smCenterY: " & $smCenterY)
    EndIf
    LogProgram("=End ShowImageSM=" & @CRLF)
EndFunc   ;==>ShowImageSM

Func ShowImagePM()
    LogProgram("=ShowImagePM=")
    Local $pmhGraphics = _GDIPlus_GraphicsCreateFromHWND($pmGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsDrawImage($pmhGraphics, $pmPic, $pmCenterX, $pmCenterY) ;display scaled image
    LogProgram("pmhGraphics: " & $pmhGraphics)
    LogProgram("pmPic: " & $pmPic)
    LogProgram("pmCenterX: " & $pmCenterX)
    LogProgram("pmCenterY: " & $pmCenterY)
    LogProgram("=End ShowImagePM=" & @CRLF)
EndFunc   ;==>ShowImagePM

Func ShowTrayIcon()
    LogProgram("=ShowTrayIcon=")
    If $showIcon = "No" Then
        LogProgram("No")
        AutoItSetOption("TrayIconHide", 1)
    Else
        LogProgram("Yes")
        AutoItSetOption("TrayIconHide", 0)
    EndIf
    LogProgram("=End ShowTrayIcon=" & @CRLF)
EndFunc   ;==>ShowTrayIcon

Func StartWithWindows()
    LogProgram("=StartWithWindows=")
    If $startWithWindows = "Yes" Then
        LogProgram("Yes")
        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
        LogProgram("No")
        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
    LogProgram("=End StartWithWindows=" & @CRLF)
EndFunc   ;==>StartWithWindows

Func AlwaysOnTop()
    LogProgram("=AlwaysOnTop=")
    ;Always keep FSS on top of other windows
    WinSetOnTop("Fullscreen Slideshow", "", 0)
    WinSetOnTop("Fullscreen Slideshow", "", 1)
    WinSetOnTop("Fullscreen Screensaver", "", 0)
    WinSetOnTop("Fullscreen Screensaver", "", 1)
    LogProgram("=End AlwaysOnTop=" & @CRLF)
EndFunc   ;==>AlwaysOnTop

Func LoseFocus()
    LogProgram("=LoseFocus=")
    ;If Fullscreen Slideshow becomes the active window, change to FSS
    If WinActive("Fullscreen Slideshow", "") <> 0 Then
        WinActivate("FSS", "")
    EndIf
    LogProgram("=End LoseFocus=" & @CRLF)
EndFunc   ;==>LoseFocus

Func CheckIfFSSshouldDisplay()
    LogProgram("=CheckIfFSSshouldDisplay=")
    Local $decided = 0
    Local $returnValue

    ;Is selected window the Desktop?
    $winSize = WinGetClientSize("")
    LogProgram("Window Size: " & $winSize)
    If $winSize = "" Then ;Prevents non-accessible glitch
        $desktop = 0
    Else
        If $winSize[0] = @DesktopWidth + $smWidth Then ;Desktop
            $desktop = 1
        Else
            $desktop = 0
        EndIf
    EndIf
    LogProgram("Desktop Selected?: " & $desktop)

    ;Where is the active window
    $activeWindowPosition = WinGetPos("[ACTIVE]")
    LogProgram("Active Window Position: " & $activeWindowPosition[0])
    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"
                LogProgram("Active Window: On Left")
                LogProgram("Return: " & $returnValue)
            Else
                $returnValue = "Show"
                LogProgram("Active Window: On Right")
                LogProgram("Return: " & $returnValue)
            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"
                LogProgram("Active Window: On Right")
                LogProgram("Return: " & $returnValue)
            Else
                $returnValue = "Show"
                LogProgram("Active Window: On Left")
                LogProgram("Return: " & $returnValue)
            EndIf
        EndIf
    EndIf

    ;Only check if undecided
    If $decided = 0 Then
        ;Where is the mouse located
        LogProgram("Mouse Position: " & MouseGetPos(0) & ", " & MouseGetPos(1))
        If $smPosition = "Left" Then
            If MouseGetPos(0) < 0 Then ;If mouse is in monitor on left
                $decided = 1
                $returnValue = "Hide"
                LogProgram("Mouse Position: On Left")
                LogProgram("Return: " & $returnValue)
            EndIf
        Else ;$smPosition = "Right"
            If MouseGetPos(0) > @DesktopWidth Then ;If mouse is in monitor on right
                ;Bottom right corner of SM is activation spot
                If MouseGetPos(0) > (@DesktopWidth + $smWidth) - 3 Then
                    If MouseGetPos(1) > $smHeight - 3 Then
                        LogProgram("Mouse Activation Position")
                        LogProgram("Return: " & $returnValue)
                        $decided = 1
                        $returnValue = "Show"
                    Else
                        $decided = 1
                        $returnValue = "Hide"
                        LogProgram("Mouse Position: On Right")
                        LogProgram("Return: " & $returnValue)
                    EndIf
                Else
                    $decided = 1
                    $returnValue = "Hide"
                    LogProgram("Mouse Position: On Right")
                    LogProgram("Return: " & $returnValue)
                EndIf
            EndIf
        EndIf
        If $decided = 0 Then
            ;Is there a special Window that is active?
            $mPos = _WinAPI_GetMousePos()
            $hwnd = _WinAPI_WindowFromPoint($mPos)
            ;Is VNC active?
            If WinGetTitle($hwnd) = "Cursor Hider" Then
                LogProgram("Cursor Hider Active")
                $decided = 1

                ;Temporary while VNC is in main window
                ;$returnValue = "Hide"
                $returnValue = "Show"
                LogProgram("Return: " & $returnValue)
            EndIf
        EndIf
    EndIf

    ;Is the Toggle set to hide?
    ;Is Screensaver Off?
    LogProgram("forceFSSOn: " & $forceFSSOn)
    If $forceFSSOn = 0 Then
        If RegRead("HKEY_CURRENT_USER\Software\Fullscreen Slideshow", "Mode") = "Hide" Then
            ;Get new image ready while hidden
            CleanupPrevImageSM()
            GetImageForDisplaySM()
            ShowImageSM()
            ;Hide GUI
            $decided = 1
            $returnValue = "Hide"
            LogProgram("Return: " & $returnValue)
        EndIf
    Else
        $returnValue = "Show" ;Screensaver is active
    EndIf

    ;If no issues, then show
    If $decided = 0 Then
        $returnValue = "Show"
        LogProgram("Return: " & $returnValue)
    EndIf
    Return $returnValue
    LogProgram("=End CheckIfFSSshouldDisplay=" & @CRLF)
EndFunc   ;==>CheckIfFSSshouldDisplay

Func ShowFSS()
    LogProgram("=ShowFSS=")
    If $smActivationMode = "Inactive" Then ;Monitor not in use
        WinSetState("Fullscreen Slideshow", "", @SW_SHOW)
    Else ;$smActivationMode = "Timer" (Screensaver mode)
        If TimerDiff($smSSMTimer) > ($smSSMsec) Then
            WinSetState("Fullscreen Slideshow", "", @SW_SHOW)
        EndIf
    EndIf
    ;Redraw GDI
    LogProgram("=ShowFSS calling=")
    ShowImageSM()
    ShowImagePM()
    LogProgram("=End ShowFSS=" & @CRLF)
EndFunc   ;==>ShowFSS

Func HideFSS()
    LogProgram("=HideFSS=")
    WinSetState("Fullscreen Slideshow", "", @SW_HIDE)
    $smRefreshImage = 1
    $smSSMTimer = TimerInit() ;Reset Screensaver Timer
    LogProgram("=End HideFSS=" & @CRLF)
EndFunc   ;==>HideFSS

Func ChangeImageSM()
    LogProgram("=ChangeImageSM=")
    If RegRead("HKEY_CURRENT_USER\Software\Fullscreen Slideshow", "Mode") <> "Monitor Off" Then
        $smImageChangeBlack = 0
        If $smChangeMethod = "Refresh" Then
            If $smRefreshImage = 1 Then
                $smRefreshImage = 0
                GetImageForDisplaySM()
                CleanupPrevImageSM()
                ShowImageSM()
                GUISetState(@SW_SHOW, $smGUIhandle)
            EndIf
        Else ;$smChangeMethod = "Timer"
            If TimerDiff($smImageChangeTimer) > $smImageChangeSec Then
                $smImageChangeTimer = TimerInit() ;Reset Image Change Timer
                GetImageForDisplaySM()
                CleanupPrevImageSM()
                ShowImageSM()
                GUISetState(@SW_SHOW, $smGUIhandle)
            EndIf
        EndIf
    Else ;Use Black Image
        If $smImageChangeBlack = 0 Then
            $smImageChangeBlack = 1
            CleanupPrevImageSM()
            GUISetState(@SW_SHOW, $smGUIhandle)
        EndIf
    EndIf
    LogProgram("=End ChangeImageSM=" & @CRLF)
EndFunc   ;==>ChangeImageSM

Func CleanupPrevImageSM()
    LogProgram("=CleanupPrevImageSM=")
    ;_GDIPlus_GraphicsDispose($smGdiPic)
    ;_GDIPlus_BitmapDispose($smPic)
    GUISetBkColor(0, $smGUIhandle) ;Draw black over previous image
    LogProgram("=End CleanupPrevImageSM=" & @CRLF)
EndFunc   ;==>CleanupPrevImageSM

Func CleanupPrevImagePM()
    LogProgram("=CleanupPrevImagePM=")
    ;_GDIPlus_GraphicsDispose($pmGdiPic)
    ;_GDIPlus_BitmapDispose($pmPic)
    GUISetBkColor(0, $pmGUIhandle) ;Draw black over previous image
    LogProgram("=End CleanupPrevImagePM=" & @CRLF)
EndFunc   ;==>CleanupPrevImagePM


Func DisplayTaskbar()
    LogProgram("=DisplayTaskbar=")
    ;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
            LogProgram("DisplayTaskbar calling")
            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
    LogProgram("=End DisplayTaskbar=" & @CRLF)
EndFunc   ;==>DisplayTaskbar

Func HideTaskBar()
    LogProgram("=HideTaskBar=")
    ControlHide('', '', WinGetHandle("[CLASS:Shell_TrayWnd]"))
    ControlHide('', '', WinGetHandle("[CLASS:Button]"))
    LogProgram("=End HideTaskBar=" & @CRLF)
EndFunc   ;==>HideTaskBar

Func ShowTaskBar()
    LogProgram("=ShowTaskbar=")
    ControlShow('', '', WinGetHandle("[CLASS:Shell_TrayWnd]"))
    ControlShow('', '', WinGetHandle("[CLASS:Button]"))
    LogProgram("=End ShowTaskbar=" & @CRLF)
EndFunc   ;==>ShowTaskBar

Func CloseProgram()
    LogProgram("=CloseProgram=")
    If RegRead("HKEY_CURRENT_USER\Software\Fullscreen Slideshow", "Close Program") = 1 Then
        RegWrite("HKEY_CURRENT_USER\Software\Fullscreen Slideshow", "Close Program", "REG_SZ", 0)
        LogProgram("CloseProgram calling")
        CleanupPrevImageSM()
        LogProgram("CloseProgram calling")
        CleanupPrevImagePM()
        LogProgram("GDI Dispose")
        _GDIPlus_GraphicsDispose($smGdiPic)
        _GDIPlus_BitmapDispose($smPic)
        _GDIPlus_GraphicsDispose($pmGdiPic)
        _GDIPlus_BitmapDispose($pmPic)
        LogProgram("GDI Shutdown")
        _GDIPlus_Shutdown()
        LogProgram("GUI Delete")
        GUIDelete($smGUI)
        GUIDelete($pmGUI)
        LogProgram("Program Closed" & @CRLF)
        FileClose($logFile)
        Exit
    EndIf
    LogProgram("Program Not Closed" & @CRLF)
    LogProgram("=End CloseProgram=")
EndFunc   ;==>CloseProgram

Func ScreensaverOperations()
    LogProgram("=ScreensaverOperations=")
    Local $checkCount, $stop
    LogProgram("Screensaver Activated? " & $screensaverActivated)
    LogProgram("Is Screensaver On? " & $screenSaverIsOn)
    If $screensaverActivated = "Yes" Then
        ;Should Screensaver be activated?
        Local $idleTime = _Timer_GetIdleTime()
        LogProgram("Idle Time Seconds: " & ($idleTime / 1000))
        LogProgram("Activation Seconds: " & $pmSSActivationSec)
        If $idleTime > $pmSSActivationSec Then
            If $screenSaverIsOn = 0 Then
                LogProgram("=ScreensaverOperations calling=")
                CaptureScreen() ;Take a screenshot of entire screen (divided into sections)
                Sleep(1000) ;Give time for screenshots to load into hard drive
                $checkCount = 1
                $stop = 0
                While $stop = 0
                    LogProgram("stop: " & $stop)
                    LogProgram("=ScreensaverOperations calling=")
                    $result = CompareScreen() ;Compare screenshots with current desktop
                    LogProgram("result: " & $result)
                    If $result = "Not Changed" Then
                        $checkCount += 1
                        If $checkCount > $ssCheckCount Then ;Check x times before giving up
                            $stop = 1
                        Else
                            Sleep(2000) ;Wait 2 seconds before checking again
                        EndIf
                    Else
                        $stop = 1
                    EndIf
                    Sleep(50)
                WEnd

                ;Activate screensaver
                If $result = "Not Changed" Then
                    LogProgram("=ScreensaverOperations calling=")
                    ShowScreensaver()
                Else ;If the screen has changed
                    LogProgram("=ScreensaverOperations calling=")
                    If CheckForDesktop() = 1 Then ;If Desktop is taking over screen, turn on screensaver anyway
                        ShowScreensaver()
                    Else ;The screen is changing, but the desktop is not active
                        ;Reset Timer (to prevent constant checking)
                        $screensaverActivated = 0
                        _WinAPI_ShowCursor("False")
                        MouseMove(MouseGetPos(0), MouseGetPos(1) - 1, 0) ;Move mouse up 1 pixel
                        MouseMove(MouseGetPos(0), MouseGetPos(1) + 1, 0) ;Move mouse down 1 pixel
                        _WinAPI_ShowCursor("True")
                    EndIf
                EndIf
                ;Erase screenshots
                LogProgram("=ScreensaverOperations calling=")
                ScreensaverCleanUp()
            EndIf ;If $screenSaverIsOn = 0
        Else ;If $idleTime < $pmSSActivationSec
            LogProgram("=ScreensaverOperations calling=")
            HideScreensaver()
        EndIf
        ;===================
        ;Change Image?
        If $screenSaverIsOn = 1 Then
            If TimerDiff($pmSSChangeTimer) > $pmSSChangeImageSec Then
                $pmChangeImage = 1
                LogProgram("=ScreensaverOperations calling=")
                GetImageForDisplayPM()
                CleanupPrevImagePM()
                ShowImagePM()
                GUISetState(@SW_SHOW, $pmGUIhandle)
                $pmSSChangeTimer = TimerInit() ;Reset Image Change Timer
            EndIf
        EndIf
        ;===================
        ;If $screensaverActivated = "No" do nothing
    EndIf
    LogProgram("=End ScreensaverOperations=" & @CRLF)
EndFunc   ;==>ScreensaverOperations

Func ShowScreensaver()
    LogProgram("=ShowScreensaver=")
    WinSetState("Fullscreen Screensaver", "", @SW_SHOW)
    _WinAPI_ShowCursor("False")
    $screenSaverIsOn = 1
    $forceFSSOn = 1
    $blinkTaskbar = 1
    LogProgram("=End ShowScreensaver=" & @CRLF)
EndFunc   ;==>ShowScreensaver

Func HideScreensaver()
    LogProgram("=HideScreensaver=")
    WinSetState("Fullscreen Screensaver", "", @SW_HIDE)
    _WinAPI_ShowCursor("True")
    $screenSaverIsOn = 0
    $forceFSSOn = 0
    If $blinkTaskbar = 1 Then
        $blinkTaskbar = 0
        ControlShow('', '', WinGetHandle("[CLASS:Shell_TrayWnd]"))
        ControlShow('', '', WinGetHandle("[CLASS:Button]"))
        Sleep($taskbarBlinkSec)
        ControlHide('', '', WinGetHandle("[CLASS:Shell_TrayWnd]"))
        ControlHide('', '', WinGetHandle("[CLASS:Button]"))
    EndIf
    LogProgram("=End HideScreensaver=" & @CRLF)
EndFunc   ;==>HideScreensaver

Func CaptureScreen()
    LogProgram("=CaptureScreen=")
    $currentShot = 1
    LogProgram("ssRows: " & $ssRows)
    LogProgram("ssColumns: " & $ssColumns)
    LogProgram("currentShot: " & $currentShot)
    ;Vertical
    For $currentYpos = 0 To $ssRows - 1 Step +1
        LogProgram("currentYpos: " & $currentYpos)
        ;Horizontal
        For $currentXpos = 0 To $ssColumns - 1 Step +1
            LogProgram("currentXpos: " & $currentXpos)
            _ScreenCapture_Capture(@WorkingDir & "\Screensaver\screensaver " & $currentShot & ".bmp", _
                    ($incrementX * $currentXpos), _
                    ($incrementY * $currentYpos), _
                    ($incrementX * ($currentXpos + 1)), _
                    $incrementY * ($currentYpos + 1), 0)
            If FileExists(@WorkingDir & "\Screensaver\screensaver " & $currentShot & ".bmp") = 1 Then
                LogProgram("screensaver " & $currentShot & ".bmp saved")
            Else
                LogProgram("screensaver " & $currentShot & ".bmp save error")
                $captureError = 1
            EndIf
            $currentShot += 1
            LogProgram("currentShot: " & $currentShot)
            Sleep(50)
        Next ;x
        Sleep(50)
    Next ;y

    ;If there is a capture error, retry once
    If $captureError = 1 Then
        LogProgram("Attempt 2")
        $captureError = 0
        $currentShot = 1
        LogProgram("ssRows: " & $ssRows)
        LogProgram("ssColumns: " & $ssColumns)
        LogProgram("currentShot: " & $currentShot)
        ;Vertical
        For $currentYpos = 0 To $ssRows - 1 Step +1
            LogProgram("currentYpos: " & $currentYpos)
            ;Horizontal
            For $currentXpos = 0 To $ssColumns - 1 Step +1
                LogProgram("currentXpos: " & $currentXpos)
                _ScreenCapture_Capture(@WorkingDir & "\Screensaver\screensaver " & $currentShot & ".bmp", _
                        ($incrementX * $currentXpos), _
                        ($incrementY * $currentYpos), _
                        ($incrementX * ($currentXpos + 1)), _
                        $incrementY * ($currentYpos + 1), 0)
                If FileExists(@WorkingDir & "\Screensaver\screensaver " & $currentShot & ".bmp") = 1 Then
                    LogProgram("screensaver " & $currentShot & ".bmp saved")
                Else
                    LogProgram("screensaver " & $currentShot & ".bmp save error")
                    $captureError = 1
                EndIf
                $currentShot += 1
                LogProgram("currentShot: " & $currentShot)
                Sleep(50)
            Next ;x
            Sleep(50)
        Next ;y
    EndIf
    LogProgram("=End CaptureScreen=" & @CRLF)
EndFunc   ;==>CaptureScreen

Func CompareScreen()
    LogProgram("=CompareScreen=")
    Local $x, $y
    Local $resistance = $changeQuadrant
    If $captureError = 0 Then
        LogProgram("changeQuadrant: " & $resistance)
        $currentShot = 1
        LogProgram("currentShot: " & $currentShot)
        For $currentYpos = 0 To $ssRows - 1 Step +1
            LogProgram("currentYpos: " & $currentYpos)
            For $currentXpos = 0 To $ssColumns - 1 Step +1
                LogProgram("currentXpos: " & $currentXpos)
                If _ImageSearchArea(@WorkingDir & "\Screensaver\screensaver " & $currentShot & ".bmp", 1, ($incrementX * $currentXpos), ($incrementY * $currentYpos), ($incrementX * ($currentXpos + 1)), ($incrementY * ($currentYpos + 1)), $x, $y, 0) = 1 Then
                    LogProgram("Image Did Not Change")
                Else
                    LogProgram("Image Changed")
                    $resistance -= 1
                EndIf
                $currentShot += 1
                LogProgram("currentShot: " & $currentShot)
                Sleep(50)
            Next
            Sleep(50)
        Next
        LogProgram("resistance: " & $resistance)
        If $resistance = 0 Then
            LogProgram("Return: Changed")
            Return "Changed"
        ElseIf $resistance < 0 Then
            LogProgram("Return: Changed")
            Return "Changed"
        Else
            LogProgram("Return: Not Changed")
            Return "Not Changed"
        EndIf
    Else
        $captureError = 0
        LogProgram("Return: Skip")
        Return "Skip"
    EndIf
    LogProgram("=End CompareScreen=" & @CRLF)
EndFunc   ;==>CompareScreen

Func CheckForDesktop()
    LogProgram("=CheckForDesktop=")
    Local $x, $y, $desktopFound
    $desktopFound = _ImageSearchArea("*Trans0xFF00FF" & @WorkingDir & "\Screensaver\Desktop.bmp", 1, 0, 0, @DesktopWidth, @DesktopHeight, $x, $y, 0)
    LogProgram("desktopFound: " & $desktopFound)
    Return $desktopFound
    LogProgram("=End CheckForDesktop=" & @CRLF)
EndFunc   ;==>CheckForDesktop

Func ScreensaverCleanUp()
    LogProgram("=ScreensaverCleanup=")
    Local $file
    Local $picCount = $ssRows * $ssColumns
    For $file = 1 To $picCount Step +1
        FileDelete(@WorkingDir & "\Screensaver\screensaver " & $file & ".bmp")
        If FileExists(@WorkingDir & "\Screensaver\screensaver " & $file & ".bmp") = 1 Then
            LogProgram("screensaver " & $file & ".bmp delete error")
        Else
            LogProgram("screensaver " & $file & ".bmp deleted")
        EndIf
    Next
    LogProgram("=End ScreensaverCleanup=" & @CRLF)
EndFunc   ;==>ScreensaverCleanUp

Func LogProgram($sentence)
    If $keepLog = 1 Then
        ConsoleWrite($sentence & @CRLF)
        FileWrite($logFile, $sentence & @CRLF)
    EndIf
EndFunc   ;==>LogProgram

FSS.txt


If you need help with your stuff, feel free to get me on my Skype.

I often get bored and enjoy helping with projects.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi,

Please see the comments :

; assuming $logFile already contains a file handle
FileClose($logFile) ; closes the handle
FileDelete($logFile) ; that's where the problem is: first of all you are using a closed handle, and secondly the FileDelete function only takes a file path

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

BTW:

Could you please give meaningful titles to your threads?

Everyone first needs to open the thread before he nows what you are talking about and if he can provide any assistance.

Meaningful titles would save us a lot of time :)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Hi,

Please see the comments :

; assuming $logFile already contains a file handle
FileClose($logFile) ; closes the handle
FileDelete($logFile) ; that's where the problem is: first of all you are using a closed handle, and secondly the FileDelete function only takes a file path

Br, FireFox.

 

I had it previously just close then reopen with the overwrite command. I added the delete command trying to see if I could get it to just start a new text file.

I'll try removing the delete again, and see if it fixes itself.


If you need help with your stuff, feel free to get me on my Skype.

I often get bored and enjoy helping with projects.

Share this post


Link to post
Share on other sites

BTW:

Could you please give meaningful titles to your threads?

Everyone first needs to open the thread before he nows what you are talking about and if he can provide any assistance.

Meaningful titles would save us a lot of time :)

 

Duly noted.

Any way to change the topic name after the fact?


If you need help with your stuff, feel free to get me on my Skype.

I often get bored and enjoy helping with projects.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Edit your post with the full editor, when you go to edit it should be the button next to the post button.

Once in the full editor you should have a title box that allows you to change the title.

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

It's not letting me click full editor for my first post (works fine with subsequent posts, but those don't offer title)

Gonna kill this thread though, the glitches are minor... I'll try to target more specific issues if I run into things in the future.


If you need help with your stuff, feel free to get me on my Skype.

I often get bored and enjoy helping with projects.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now