#RequireAdmin #NoTrayIcon #include-once #include #include #include #include Local $key1 = "HKCU\Control Panel\Desktop", $key2 = "HKCU\Control Panel\Colors" Local $val1 = "Wallpaper", $val2 = "Background", $hDLL = "user32.dll" Local $wP = RegRead($key1,$val1), $bG = RegRead($key2,$val2) Local $tBar = "[CLASS:Shell_TrayWnd]", $pMan = ControlGetHandle("Program Manager","",1) Local $dt_W = @DesktopWidth, $dt_H = @DesktopHeight, $iPID Local $bGcolor = 0x000000, $tpValue = 0, $wlPaper = "", $windLst = "#m" Local $cCopy, $cCursor = 32512, $blkCursor, $style = 0x80000000, $fPath ;Create full screen window to prevent right mouse click desktop context menu. Local $iGUI = GUICreate("", $dt_W+10, $dt_H+10, -1, -1, $style) GuiSetState() WinSetTrans($iGUI, "", 1) ;Make window invisible. Local $iFold = _FileListToArray(@ScriptDir, "*", 2) ;Get folder(s) If @error = 4 Then Exit Local $nPath = "ImagePosition.txt", $nFile = FileOpen($nPath) If @error = -1 Then Exit Local $gHWnd, $gHWnd_, $iWidth_ = 0, $iHeight_ = 0, $FrBk = 1, $hImage, $CT = 0 Local $sColors[2], $nFold = $iFold[0], $rFold, $Btn[$iFold[0]+1], $ff, $SW = 1 ;Check for missing folders and invalid data Local $LineCnt = _FileCountLines($nPath) If $LineCnt = 0 OR $nFold <> $lineCnt Then _Reset($nFile, $nPath, $iFold) $SW = 0 EndIf If $SW Then For $i = 1 To $LineCnt $rFold = StringSplit(FileReadLine($nFile), ",") If @error OR Not StringIsDigit($rFold[2]) Then _Reset($nFile, $nPath, $iFold) $SW = 0 ExitLoop EndIf Next EndIf If $SW Then FileClose($nFile) $nFile = FileOpen($nPath) For $i = 1 To $LineCnt $rFold = StringSplit(FileReadLine($nFile), ",") For $j = 1 To $nFold If StringCompare($rFold[1], $iFold[$j], 1) = 0 Then $CT += 1 Next Next If $CT <> $nFold Then _Reset($nFile, $nPath, $iFold) EndIf If $iFold[0] = 1 Then ;Only one folder $fPath = $iFold[1] Else Local $fPos, $iMsg, $x, $y = 25, $iNum = $nFold For $i = 1 To $iNum Step 2 If $iNum = $i Then $iNum += 1 ;Check for odd number of folders Next ;Set GUI window height based on number of folders and create the window Local $hSize = (($iNum/2)*30)+90 Local $hGUI = GUICreate("", 262, $hSize, -1,-1, 0x00C00000, 0x00000200) For $i = 1 To $nFold ;Create folder buttons If Mod($i, 2) <> 0 Then $x = 25 If Mod($i, 2) = 0 Then $x = 140 If $i > 2 Then If $x = 25 Then $y += 30 EndIf $Btn[$i] = GUICtrlCreateButton($iFold[$i], $x, $y, 100, 25) Next $Btn[0] = GUICtrlCreateButton("Cancel", 95, $hSize-45, 75, 25, 0x0001) ;Setup window bar colors Local $aElements[2] = [2, 27], $aColors[2] = [Dec("ffff00"), Dec("00ffff")] $sColors[0] = _WinAPI_GetSysColor($aElements[0]) $sColors[1] = _WinAPI_GetSysColor($aElements[1]) DllCall("UxTheme.dll", "int", "SetWindowTheme","hwnd",$hGUI,"wstr",0,"wstr",0) _WinAPI_SetSysColors($aElements, $aColors) GUISetState() While 1 ;Get selected folder WinActivate($hGUI) $iMsg = GUIGetMsg() For $i = 0 To $nFold If $iMsg = $Btn[$i] Then $fPos = $i If $fPos > 0 Then ExitLoop 2 GUIDelete($hGUI) Exit ElseIf _IsPressed("1B", $hDLL) Then Sleep(250) GUIDelete($hGUI) Exit EndIf Next WEnd GUIDelete($hGUI) $fPath = $iFold[$fPos] EndIf ;Get number of images from folder and current number position within the list FileClose($nFile) $rFold = StringSplit(FileReadLine(FileOpen($nPath), $fPos), ",") Local $fList = _FileListToArray($fPath) Local $fNum = $rFold[2] -1 If $fNum < 0 OR $fNum > $fList[0] Then $fNum = 0 _HideShowTask(1) _GDIPlus_Startup() While 1 If $FrBk Then If $fNum = $fList[0] Then $fNum = 0 $fNum += 1 Else $fNum -= 1 If $fNum = 0 Then $fNum = $fList[0] EndIf ;Display the image/picture $hImage = _GDIPlus_ImageLoadFromFile($fPath & "\" & $fList[$fNum]) If NOT @error Then _Images($hImage) WEnd ;====================================== FUNCTIONS ====================================== Func _Images($hImage) Local $iWidth = _GDIPlus_ImageGetWidth($hImage) Local $iHeight = _GDIPlus_ImageGetHeight($hImage) If $iHeight > $dt_H Then $ff = $iHeight/$dt_H If ($iWidth/$ff) > $dt_W Then $ff = $iWidth/$dt_W $iWidth = $iWidth/$ff $iHeight = $iHeight/$ff Else $ff = $dt_H/$iHeight If ($iWidth*$ff) > $dt_W Then $ff = $dt_W/$iWidth $iWidth = $iWidth*$ff $iHeight = $iHeight*$ff EndIf ;Create window as place holder for the image/picture If $iWidth < $iWidth_ OR $iHeight < $iHeight_ Then _Fade($gHWnd_, 254, 0, -5, 10) $gHWnd = GUICreate("", $iWidth, $iHeight, -1, -1, $style) GUISetState() WinSetTrans($gHWnd, "", 0) Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($gHWnd) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, 0, 0, $iWidth, $iHeight) _Fade($gHWnd, 0, 255, 1, 10) _Sleep(4000) If IsHWnd($gHWnd_) Then GUIDelete($gHWnd_) $gHWnd_ = $gHWnd $iWidth_ = $iWidth $iHeight_ = $iHeight EndFunc Func _Sleep($delay) Local $tDelay = TimerInit() While TimerDiff($tDelay) < $delay If _IsPressed("01", $hDLL) OR _IsPressed("1B", $hDLL) Then Sleep(250) _EndProgram() ;Restore, Update, Close, Delete ElseIf _IsPressed("06", $hDLL) Then ;Next Task Sleep(250) $FrBk = 1 ElseIf _IsPressed("05", $hDLL) Then ;Previous Task Sleep(250) $FrBk = 0 ElseIf _IsPressed("02", $hDLL) Then ;Right Mouse Key Sleep(250) _Pause() ;Pause Program EndIf WEnd EndFunc Func _Pause() ;Create Window with Button. GUICreate("", 0, 0, 0, 0, $style) ;Used as blocking function. GUICtrlCreateButton("", 0, 0) ;NOTE: Window and button have no size? ;But, it works. Strange? While 1 If _IsPressed("02", $hDLL) Then ;Continue Program Sleep(250) GUIDelete() ;Delete the invisible Window ExitLoop EndIf WEnd EndFunc Func _HideShowTask($hst) If NOT $hst Then $bGcolor = $bG $tpValue = 255 $wlPaper = $wP $windLst = "#+m" EndIf Sleep(2000) RegWrite($key1, $val1, "REG_SZ", $wlPaper) ;Hide/Show wallpaper DllCall($hDLL,"int","SystemParametersInfo","int",20,"int",0,"str",$wlPaper,"int",0) RegWrite($key2, $val2, "REG_SZ", $bGcolor) ;Set/Get background color WinSetTrans($tBar, "", $tpValue) ;Hide/Show taskbar WinSetTrans($pMan, "", $tpValue) ;Hide/Show desktop icons Send($windLst) ;Hide/Show windows MouseMove($dt_W/2, $dt_H-60, 0) If $hst Then ;Hide/Show system pointer cursor $blkCursor = _WinAPI_LoadCursorFromFile("Blank_Cursor.cur") $cCopy = _WinAPI_CopyCursor(_WinAPI_LoadCursor(0, $cCursor)) _WinAPI_SetSystemCursor($blkCursor, $cCursor) Else _WinAPI_SetSystemCursor($cCopy, $cCursor) EndIf EndFunc Func _Fade($fhand, $v1, $v2, $v3, $v4) For $i = $v1 To $v2 Step $v3 WinSetTrans($fhand, "", $i) _Sleep($v4) Next EndFunc Func _Reset($nFile, $nPath, $iFold) FileClose($nFile) $nFile = FileOpen($nPath, 2) For $j = 1 To $nFold FileWriteLine($nFile, $iFold[$j] & ",1") Next EndFunc Func _EndProgram() If IsHWnd($gHWnd_) Then GUIDelete($gHWnd_) _Fade($gHWnd, 254, 0, -2, 10) _HideShowTask(0) _WinAPI_DestroyCursor($blkCursor) _WinAPI_SetSysColors($aElements, $sColors) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() GUIDelete($gHWnd) GuiDelete($iGUI) DllClose($hDLL) FileClose($nFile) Local $fRead = FileOpen($nPath) Local $wFile = FileOpen($nPath, 2) For $i = 1 To $nFold $rFold = StringSplit(FileReadLine($fRead), ",") If $i = $fPos Then FileWriteLine($wFile, $rFold[1] & "," & $fNum) Else FileWriteLine($wFile, $rFold[1] & "," & $rFold[2]) EndIf Next FileClose($wFile) FileClose($fRead) ControlSend("Program Manager", "", 1, "{F5}") MouseClick("") MsgBox(0,"","test",2) If ProcessExists($iPID) Then ProcessClose($iPID) $iPID = Run("Display_Images.exe") Exit EndFunc