#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=icons\shell32_dll_Ico257_ico_Ico1.ico #AutoIt3Wrapper_Outfile=vistas.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; ================================================================================================================ ; LANGUAGE OPTIONS Opt("TrayMenuMode",1) AutoItSetOption("MustDeclareVars", 0) ; ================================================================================================================ ; INCLUDES (update as needed) #Include #include #include #include #include #include ; ================================================================================================================ ; SCRIPT IDENTITY (this is based on the filename of the script/executable) $sAppDescp = "" $sAppName = "Vistas" $sAppAuthor = "Sean Shrum" $sAppVersion = "2.04" $sAppEmail = StringLower($sAppName)& "@shrum.net" $sAppHome = "http://www.shrum.net/sean/code/" & StringLower($sAppName) $sAppNews = $sAppHome & "/updates.html" $sAppSupport = $sAppHome & "/support.html" $sAppFileType ="." & StringLower($sAppName) $aAppBuild = FileGetTime(@ScriptFullPath) $sAppBuild = $aAppBuild[0] & "." & $aAppBuild[1] & "." & $aAppBuild[2] & " @ " & $aAppBuild[3] & ":" & $aAppBuild[4] & ":" & $aAppBuild[5] $sAppTitle = $sAppName & " v." & $sAppVersion $sAppSettings = "HKCU\software\shrum.net\" & $sAppName ; ================================================================================================================ ; VARIABLE DECLARATIONS / DEFAULTS Global $bDebug=False, $bVerbose=True Dim $aTypes = StringSplit("jpg,jpeg,bmp,gif", ",") Dim $sPanoramic = "" Global $iDesktopID ; current desktop identifier Global $aMonitorInfo ; all monitor(s) info: #,x,y,w,h Global $aEnabledMonitorInfo ; enabled monitors, sorted (left to right) info: #,x,y,w,h Global $aGuiHandles ; GUI handles Global $aPictureHandles ; Picture handles Global $aContextMenuHandles ; GUI context menus handles Global $aImageInfo ; image filename(s) array Global $aRecentInfo ; recent profile filename(s) array Global $aVistasMenu ; context menus... Global $aVistasHeaderMenu Global $aDisplayHeaderMenu Global $aProjectHeaderMenu Global $aRecentHeaderMenu Global $aImageHeaderMenu Global $aImageInfoMenu Global $aImageEditMenu Global $aPanoramicMenu Global $aSaveMenu Global $aEditMenu Global $aLoadMenu Global $aDisplaySettingsMenu Global $aDisplayAppearanceMenu Global $aDisplayThemesMenu Global $aDisplayScreenSaverMenu Global $aUpdatesMenu Global $aHomepageMenu Global $aNewsMenu Global $aSupportMenu Global $aDonateMenu Global $aAboutMenu Global $aExitMenu Global $aRecentMenu ; ================================================================================================================ ; TRAY ICON AND TOOLTIP SET (looks for .ico in same folder as .exe otherwise uses the build icon) TraySetToolTip($sAppTitle) TraySetIcon($sAppName & ".ico") ; ================================================================================================================ ; SPLASH SCREEN / TRAYTIP BUBBLE (*only* if no command line params are present: automated run/batch call) if $CmdLine[0] = 0 Then Traytip($sAppTitle,$sAppHome & @CRLF & "By " & $sAppAuthor & " :: " & $sAppEmail,5) ; ================================================================================================================ ; REGISTRY UPDATES (location, version, runcount) $iRunCount = RegRead($sAppSettings, "Executed") RegWrite($sAppSettings, "Executed", "REG_SZ", $iRunCount + 1) RegWrite($sAppSettings, "", "REG_SZ", @Scriptdir) RegWrite($sAppSettings, "Version", "REG_SZ", $sAppVersion) ; ================================================================================================================ ; PROGRAM GROUP / SHORTCUTS CREATION (fires only when Executed reg value = "" from above) If $iRunCount = "" Then DirCreate(@ProgramsCommonDir & "\shrum.net\" & $sAppName) FileCreateShortcut(@ScriptFullPath, @ProgramsCommonDir & "\shrum.net\" & $sAppName & "\" & $sAppName & ".lnk") FileCreateShortcut($sAppHome, @ProgramsCommonDir & "\shrum.net\" & $sAppName & "\Homepage.lnk") FileCreateShortcut(@ScriptFullPath, @UserProfileDir & "\application data\microsoft\Internet Explorer\Quick Launch\" & $sAppName & ".lnk") EndIf ; ================================================================================================================ ; FILE ASSOCIATION RegWrite($sAppSettings, "Executed", "REG_SZ", $iRunCount + 1) RegWrite("HKEY_CLASSES_ROOT\" & $sAppFileType, "", "REG_SZ", $sAppName) RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & $sAppFileType & "\OpenWithList", "a", "REG_SZ", @ScriptName) RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & $sAppFileType & "\OpenWithList", "MRUList", "REG_SZ", "a") RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & $sAppFileType & "\OpenWithProgids", "vistas_auto_file", 0, 0) RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & $sAppFileType & "\UserChoice", "Progid", "REG_SZ", "Applications\" & $sAppname) RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\" & $sAppFileType, "", "REG_SZ", $sAppname) ; ================================================================================================================ ; SYSTRAY MENU DEFINITIONS (if any) TrayCreateItem ("[ Vistas ]") $mDefine = TrayCreateItem ("...Define Ctrl+Alt+V") TrayItemSetState (-1, $TRAY_DEFAULT) $mSave = TrayCreateItem ("...Save profile") $mLoad = TrayCreateItem ("...Load profile") TrayCreateItem ("") TrayCreateItem ("[ Project ]") $mAbout = TrayCreateItem ("...About") $mUpdate = TrayCreateItem ("...Update") $mHomepage = TrayCreateItem ("...Homepage") $mNews = TrayCreateItem ("...News") $mSupport = TrayCreateItem ("...Support") $mDebug = TrayCreateItem ("...Debug") $mExit = TrayCreateItem ("...Exit") TraySetState () TraySetClick (16) ; ================================================================================================================ ; LAST RUN SETTINGS LOAD _SettingsLoad() ; ================================================================================================================ ; COMMAND-LINE / .INI EVALUATION if $CmdLine[0] <> 0 Then ; Profile loading (*.vistas) if $CmdLine[0] = 1 and stringinstr($CmdLine[1], $sAppFileType) then $iDesktopID = IniRead($CmdLine[1], $sAppName, "DesktopID", "") for $i = 1 to 10 $sTemp = IniRead($CmdLine[1], $sAppName, $i,"//\\") if $sTemp <> "//\\" then RegWrite($sAppSettings & "\" & $iDesktopID, $i, "REG_SZ", $sTemp) Next RegWrite($sAppSettings & "\" & $iDesktopID, "Active", "REG_SZ", IniRead($CmdLine[1], $sAppName, "Active", "")) EndIf ; Image updates via command line for $i = 1 to $CmdLine[0] $aParam = StringSplit($CmdLine[$i], "=") $sParam = StringUpper(stringleft($aParam[1],1)) RegWrite($sAppSettings & "\" & Regread($sAppSettings, "Current"), $sParam, "REG_SZ", $aParam[2]) next EndIf ; ================================================================================================================ ; DUPLICATE INSTANCE CHECK (may need to remove or move this around depending on where it is needed) If UBound(ProcessList(@ScriptName)) > 2 Then Exit ; ================================================================================================================ ; ARGUMENT CHECKS / PROMPTS ; N/A ; ================================================================================================================ ; SETTINGS SAVE (all user passed params should be formatted to program-desired formats by this point) _SettingsSave() ; ================================================================================================================ ; HOTKEY DEFINITIONS (if any) _HotkeysSet() ; ================================================================================================================ ; DEBUG WINDOW (notepad; if requested) if $bDebug then _DebugSetup() ; ================================================================================================================ ; MAIN PROGRAM TraySetToolTip($sAppTitle & " :: Collecting monitor info") While 1 _MenuMonitor() _GUIMonitor() $iCurrentID = _DesktopID() if $iDesktopID <> $iCurrentID Then $iDesktopID = $iCurrentID trayTip($sAppTitle,"App started or display change detected." & @CRLF & "Updating display information...", 5) _DesktopPrepare() if RegRead($sAppSettings & "\" & $iDesktopID, "Active") = "" then msgbox(0,$sAppTitle,"No profile has been defined for the current desktop dimensions." & @CRLF & "We'll display the Background Selection dialog so you can set one up.") _VistasGUI() EndIf $bRefresh = True EndIf for $i = 1 to $aEnabledMonitorInfo[0][0] + 1 $sResult = _ImageRead($i) if $aImageInfo[$i] <> $sResult Then $bRefresh = true if $i = $aEnabledMonitorInfo[0][0] + 1 Then RegWrite($sAppSettings & "\" & $iDesktopID, "Active", "REG_SZ", $i) EndIf next if $bRefresh Then $bRefresh = False trayTip($sAppTitle,"Image / monitor change detected." & @CRLF & "Updating display information...", 5) _ImageRead() _RecentRead() _DesktopUpdate() EndIf WEnd ; ================================================================================================================ ; FUNCTIONS Func _AboutDialog() _ConsoleWrite("+ _AboutDialog()") msgbox(0,"About", $sAppTitle & " ( build " & $sAppBuild & " ) by " & $sAppAuthor & @crlf & $sAppHome & " :: " & StringLower($sAppName) & "@shrum.net") _ConsoleWrite("- _AboutDialog()") EndFunc func _ConsoleWrite($sMsg) _DebugOut($sMsg) Consolewrite($sMsg & @CRLF) EndFunc Func _ContextMenu($iMonitorNum) GUICtrlDelete($aContextMenuHandles[$iMonitorNum]) GUICtrlCreateMenuitem ("", $aContextMenuHandles[$iMonitorNum]) $aContextMenuHandles[$iMonitorNum] = GUICtrlCreateContextMenu ($aPictureHandles[$iMonitorNum]) $aVistasHeaderMenu[$iMonitorNum] = GUICtrlCreateMenuitem ("[ Vistas ]", $aContextMenuHandles[$iMonitorNum]) $aVistasMenu[$iMonitorNum] = GUICtrlCreateMenuitem ("...Vistas [ " & $iMonitorNum & " ]", $aContextMenuHandles[$iMonitorNum]) $aPanoramicMenu[$iMonitorNum] = GUICtrlCreateMenuitem ("...Panoramic", $aContextMenuHandles[$iMonitorNum]) if $iMonitorNum = $aEnabledMonitorInfo[0][0]+1 then GUICtrlSetState(-1,$GUI_CHECKED) $aSaveMenu[$iMonitorNum] = GUICtrlCreateMenuitem ("...Save profile", $aContextMenuHandles[$iMonitorNum]) $aLoadMenu[$iMonitorNum] = GUICtrlCreateMenuitem ("...Load profile", $aContextMenuHandles[$iMonitorNum]) for $i = 1 to 10 $sFilename = $aRecentInfo[$i] if $sFilename <> "" Then if $i = 1 then GUICtrlCreateMenuitem ("", $aContextMenuHandles[$iMonitorNum]) $aRecentHeaderMenu[$iMonitorNum] = GUICtrlCreateMenuitem ("[ Recent Profiles ]", $aContextMenuHandles[$iMonitorNum]) EndIf $sBasename = StringRight($sFilename, stringlen($sFilename) - StringInStr($sFilename, "\", 0, -1)) $aRecentMenu[$iMonitorNum][$i] = GUICtrlCreateMenuitem("..." & $sBasename, $aContextMenuHandles[$iMonitorNum]) EndIf next GUICtrlCreateMenuitem ("", $aContextMenuHandles[$iMonitorNum]) $aImageHeaderMenu[$iMonitorNum] = GUICtrlCreateMenuitem ("[ Image ]", $aContextMenuHandles[$iMonitorNum]) $aImageInfoMenu[$iMonitorNum] = GUICtrlCreateMenuitem ("...Info", $aContextMenuHandles[$iMonitorNum]) $aImageEditMenu[$iMonitorNum] = GUICtrlCreateMenuitem ("...Open / Edit", $aContextMenuHandles[$iMonitorNum]) GUICtrlCreateMenuitem ("", $aContextMenuHandles[$iMonitorNum]) $aDisplayHeaderMenu[$iMonitorNum] = GUICtrlCreateMenuitem ("[ Display ]", $aContextMenuHandles[$iMonitorNum]) $aDisplayThemesMenu[$iMonitorNum] = GUICtrlCreateMenuitem ("...Themes", $aContextMenuHandles[$iMonitorNum]) $aDisplayScreenSaverMenu[$iMonitorNum] = GUICtrlCreateMenuitem ("...Screensaver", $aContextMenuHandles[$iMonitorNum]) $aDisplayAppearanceMenu[$iMonitorNum] = GUICtrlCreateMenuitem ("...Appearance", $aContextMenuHandles[$iMonitorNum]) $aDisplaySettingsMenu[$iMonitorNum] = GUICtrlCreateMenuitem ("...Settings", $aContextMenuHandles[$iMonitorNum]) GUICtrlCreateMenuitem ("", $aContextMenuHandles[$iMonitorNum]) $aProjectHeaderMenu[$iMonitorNum] = GUICtrlCreateMenuitem ("[ Project ]", $aContextMenuHandles[$iMonitorNum]) $aAboutMenu[$iMonitorNum] = GUICtrlCreateMenuitem ("...About", $aContextMenuHandles[$iMonitorNum]) $aExitMenu[$iMonitorNum] = GUICtrlCreateMenuitem ("...Exit", $aContextMenuHandles[$iMonitorNum]) EndFunc func _DesktopID() $aMonitorInfo = _MonitorInfo() $iDetectedMonitors = $aMonitorInfo[0][0] $aMonitorInfo = _EnabledMonitorInfo($aMonitorInfo) $aEnabledMonitorInfo[0][0] = $aMonitorInfo[0][0] $sTemp = "" For $i = 1 to $aMonitorInfo[0][0] $sTemp &= "[" & $aMonitorInfo[$i][3] & "x" & $aMonitorInfo[$i][4] & "] " Next $sTemp = StringStripWS($sTemp,2) return $sTemp endFunc func _DesktopPrepare() if isarray($aGuiHandles) then for $i = 1 to ubound($aGuiHandles)-1 GUIDelete($aGuiHandles[$i]) Next EndIf Dim $aImageInfo[$aEnabledMonitorInfo[0][0]+2] Dim $aRecentInfo[11] Dim $aGuiHandles[$aEnabledMonitorInfo[0][0]+2] Dim $aPictureHandles[$aEnabledMonitorInfo[0][0]+2] Dim $aContextMenuHandles[$aEnabledMonitorInfo[0][0]+2] Dim $aVistasHeaderMenu[$aEnabledMonitorInfo[0][0]+2] Dim $aRecentHeaderMenu[$aEnabledMonitorInfo[0][0]+2] Dim $aDisplayHeaderMenu[$aEnabledMonitorInfo[0][0]+2] Dim $aProjectHeaderMenu[$aEnabledMonitorInfo[0][0]+2] Dim $aVistasMenu[$aEnabledMonitorInfo[0][0]+2] Dim $aImageHeaderMenu[$aEnabledMonitorInfo[0][0]+2] Dim $aImageInfoMenu[$aEnabledMonitorInfo[0][0]+2] Dim $aImageEditMenu[$aEnabledMonitorInfo[0][0]+2] Dim $aSaveMenu[$aEnabledMonitorInfo[0][0]+2] Dim $aEditMenu[$aEnabledMonitorInfo[0][0]+2] Dim $aLoadMenu[$aEnabledMonitorInfo[0][0]+2] Dim $aRecentMenu[$aEnabledMonitorInfo[0][0]+2][11] Dim $aPanoramicMenu[$aEnabledMonitorInfo[0][0]+2] Dim $aDisplayThemesMenu[$aEnabledMonitorInfo[0][0]+2] Dim $aDisplayAppearanceMenu[$aEnabledMonitorInfo[0][0]+2] Dim $aDisplayScreenSaverMenu[$aEnabledMonitorInfo[0][0]+2] Dim $aDisplaySettingsMenu[$aEnabledMonitorInfo[0][0]+2] Dim $aAboutMenu[$aEnabledMonitorInfo[0][0]+2] Dim $aExitMenu[$aEnabledMonitorInfo[0][0]+2] For $i = 1 to $aEnabledMonitorInfo[0][0] + 1 $aGuiHandles[$i] = GuiCreate("backgroundguimadebyvistas" & $i,$aMonitorInfo[$i][3],$aMonitorInfo[$i][4],$aMonitorInfo[$i][1],$aMonitorInfo[$i][2],$WS_POPUP,$WS_EX_TOOLWINDOW) $aPictureHandles[$i] = GUICtrlCreatePic($aImageInfo[$i],0,0,$aMonitorInfo[$i][3],$aMonitorInfo[$i][4]) Next EndFunc func _DesktopUpdate() if RegRead($sAppSettings & "\" & $iDesktopID, "Active") = $aEnabledMonitorInfo[0][0]+1 Then GUICtrlSetImage($aPictureHandles[$aEnabledMonitorInfo[0][0]+1], _ImageRead($aEnabledMonitorInfo[0][0]+1)) GUISetState(@SW_SHOW, $aGuiHandles[$aEnabledMonitorInfo[0][0]+1]) _contextmenu($aEnabledMonitorInfo[0][0]+1) $aResult = DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $aGuiHandles[$aEnabledMonitorInfo[0][0]+1], "hwnd", 0x00000001, "int", $aMonitorInfo[$aEnabledMonitorInfo[0][0]+1][1], "int", $aMonitorInfo[$aEnabledMonitorInfo[0][0]+1][2], "int", $aMonitorInfo[$aEnabledMonitorInfo[0][0]+1][3], "int", $aMonitorInfo[$aEnabledMonitorInfo[0][0]+1][4], "int", 0) For $i = 1 to $aEnabledMonitorInfo[0][0] GUISetState(@SW_HIDE, $aGuiHandles[$i]) Next Else For $i = 1 to $aEnabledMonitorInfo[0][0] if $aImageInfo[$i] <> "" then GUICtrlSetImage($aPictureHandles[$i], $aImageInfo[$i]) GUISetState(@SW_SHOW, $aGuiHandles[$i]) _contextmenu($i) $aResult = DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $aGuiHandles[$i], "hwnd", 0x00000001, "int", $aMonitorInfo[$i][1], "int", $aMonitorInfo[$i][2], "int", $aMonitorInfo[$i][3], "int", $aMonitorInfo[$i][4], "int", 0) EndIf Next GUISetState(@SW_HIDE, $aGuiHandles[$aEnabledMonitorInfo[0][0]+1]) EndIf _RecentRead() for $i = 1 to $aEnabledMonitorInfo[0][0] + 1 _ContextMenu($i) $aResult = DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $aGuiHandles[$i], "hwnd", 0x00000001, "int", $aMonitorInfo[$i][1], "int", $aMonitorInfo[$i][2], "int", $aMonitorInfo[$i][3], "int", $aMonitorInfo[$i][4], "int", 0) Next TraySetToolTip($sAppTitle & " :: " & $iDesktopID) Regwrite($sAppSettings, "Current", $iDesktopID) for $i = 1 to $aEnabledMonitorInfo[0][0] + 1 Regwrite("HKEY_CLASSES_ROOT\*\shell\" & $sAppname & "." & $i & "\command", "", "REG_SZ", @ScriptFullPath & ' ' & $i & '="%1"') Next EndFunc Func _DefineSetting($sSetting="", $sValue="") _consolewrite("+ _DefineSetting()") _ConsoleWrite(": Setting '" & $sSetting & "' = '" & $sValue & "'") if $sSetting = "" or $sSetting = "" Then ;~ ****** EndIf if $sSetting = "" or $sSetting = "Debug" Then if $sValue then $bDebug = $sValue Else if not $bDebug then $bDebug = True Else $bDebug = False EndIf endif if $bDebug Then _DebugSetup($sAppTitle & " - debugging info") _ConsoleWrite("Debug console :: " & $sAppTitle & " :: build " & $sAppBuild) _ConsoleWrite("========================[ START ]=============================") opt("TrayIconDebug",1) TrayItemSetState($mDebug,1) Else _ConsoleWrite("=========================[ END ]==============================") opt("TrayIconDebug",0) TraySetToolTip($sAppTitle) TrayItemSetState($mDebug,4) EndIf EndIf _consolewrite("- _DefineSetting()") EndFunc func _EnabledMonitorInfo($aMonitorInfo) Dim $aEnabledMonitorInfo[1][5] Dim $iIndex = 0 $msg = "" _ArraySort($aMonitorInfo,0,0,5,1) for $i = 1 to $aMonitorInfo[0][0] if ($aMonitorInfo[$i][3] <> 0) AND ($aMonitorInfo[$i][4] <> 0) Then $iIndex += 1 ReDim $aEnabledMonitorInfo[$iIndex+1][5] $aEnabledMonitorInfo[$iIndex][0] = $aMonitorInfo[$i][0] $msg &= "Display "& $iIndex & " #=" & $aMonitorInfo[$i][0] & @CRLF $aEnabledMonitorInfo[$iIndex][1] = $aMonitorInfo[$i][1] $msg &= "Display "& $iIndex & " x=" & $aMonitorInfo[$i][1] & @CRLF $aEnabledMonitorInfo[$iIndex][2] = $aMonitorInfo[$i][2] $msg &= "Display "& $iIndex & " y=" & $aMonitorInfo[$i][2] & @CRLF $aEnabledMonitorInfo[$iIndex][3] = $aMonitorInfo[$i][3] $msg &= "Display "& $iIndex & " w=" & $aMonitorInfo[$i][3] & @CRLF $aEnabledMonitorInfo[$iIndex][4] = $aMonitorInfo[$i][4] $msg &= "Display "& $iIndex & " h=" & $aMonitorInfo[$i][4] & @CRLF & @CRLF EndIf next $aEnabledMonitorInfo[0][0] = $iIndex $iWidth = 0 $iHeight = 0 $iTop = 0 for $i = 1 to $aEnabledMonitorInfo[0][0] if $iTop > $aMonitorInfo[$i][2] then $iTop = $aMonitorInfo[$i][2] $iWidth += $aMonitorInfo[$i][3] if $iHeight < $aMonitorInfo[$i][4] then $iHeight = $aMonitorInfo[$i][4] next ReDim $aEnabledMonitorInfo[$aEnabledMonitorInfo[0][0]+2][5] $aEnabledMonitorInfo[$aEnabledMonitorInfo[0][0]+1][0]="Panoramic" $aEnabledMonitorInfo[$aEnabledMonitorInfo[0][0]+1][1]=$aMonitorInfo[1][1] $aEnabledMonitorInfo[$aEnabledMonitorInfo[0][0]+1][2]=$iTop $aEnabledMonitorInfo[$aEnabledMonitorInfo[0][0]+1][3]=$iWidth $aEnabledMonitorInfo[$aEnabledMonitorInfo[0][0]+1][4]=$iHeight return $aEnabledMonitorInfo EndFunc Func _Exit() _ConsoleWrite("+ _Exit()") for $i = 1 to $aEnabledMonitorInfo[0][0] + 1 RegDelete("HKCR\*\shell\" & $sAppname & "." & $i) Next GUIDelete() Exit EndFunc func _GUIMonitor() $msg = GUIGetMsg() if $msg <> 0 Then for $i = 1 to $aEnabledMonitorInfo[0][0] + 1 if WinActive("backgroundguimadebyvistas" & $i) Then $aResult = DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $aGuiHandles[$i], "hwnd", 0x00000001, "int", $aMonitorInfo[$i][1], "int", $aMonitorInfo[$i][2], "int", $aMonitorInfo[$i][3], "int", $aMonitorInfo[$i][4], "int", 0) EndIf Next for $i = 1 to $aEnabledMonitorInfo[0][0] + 1 if $msg = $aVistasMenu[$i] Then if _ImageChange($i) <> "" then GUICtrlSetImage($aPictureHandles[$i], $aImageInfo[$i]) EndIf if $msg = $aPanoramicMenu[$i] Then if RegRead($sAppSettings & "\" & $iDesktopID, "Active") = $aEnabledMonitorInfo[0][0] + 1 Then RegWrite($sAppSettings & "\" & $iDesktopID, "Active", "REG_SZ", "1") Else RegWrite($sAppSettings & "\" & $iDesktopID, "Active", "REG_SZ", $aEnabledMonitorInfo[0][0] + 1) EndIf _DesktopUpdate() EndIf if $msg = $aImageInfoMenu[$i] then _ImageInfo($i) if $msg = $aImageEditMenu[$i] Then _ImageEdit($i) if $msg = $aSaveMenu[$i] Then _ProfileSave() if $msg = $aLoadMenu[$i] Then _ProfileLoad() for $y = 1 to 10 if $msg = $aRecentMenu[$i][$y] Then _ProfileLoad(RegRead($sAppSettings & "\" & $iDesktopID & "\Recent", $y)) Next if $msg = $aDisplayThemesMenu[$i] Then run("RunDll32.exe shell32.dll,Control_RunDLL desk.cpl,,-1") if $msg = $aDisplayScreenSaverMenu[$i] then run ("RunDll32.exe shell32.dll,Control_RunDLL desk.cpl,,1") if $msg = $aDisplayAppearanceMenu[$i] then run("RunDll32.exe shell32.dll,Control_RunDLL desk.cpl,,2") if $msg = $aDisplaySettingsMenu[$i] Then run("RunDll32.exe shell32.dll,Control_RunDLL desk.cpl,,3") if $msg = $aAboutMenu[$i] Then _AboutDialog() if $msg = $aExitMenu[$i] Then Exit Next EndIf EndFunc func _HotkeysSet() _ConsoleWrite("+ _HotkeysSet()") HotKeySet("!^v", "_VistasGUI") _ConsoleWrite("- _HotkeysSet()") EndFunc func _ImageChange($iMonitorNum) $sResult = _ImageDefine($iMonitorNum) if $sResult <> "" Then _ImageWrite($iMonitorNum, $sResult) return $sResult EndFunc Func _ImageDefine($iMonitorNum) $sFilename = RegRead($sAppSettings & "\" & $iDesktopID, string($iMonitorNum)) if $sFilename <> "" Then $sLastPath = StringLeft($sFilename, Stringlen($sFilename) - (Stringlen($sFilename) - StringInStr($sFilename, "\",0,-1))) Else $sFilename = RegRead($sAppSettings & "\" & $iDesktopID, "Last") if $sFilename = "" then $sFilename = RegRead($sAppSettings, "Last") if $sFilename <> "" Then $sLastPath = StringLeft($sFilename, Stringlen($sFilename) - (Stringlen($sFilename) - StringInStr($sFilename, "\",0,-1))) Else $sLastPath = @UserProfileDir EndIf EndIf $sImageFilename = FileOpenDialog("Specify a background for display " & $iMonitorNum, $sLastPath, "Image files (*.jpeg;*.jpg;*.gif;*.bmp)|All files (*.*)", 3) If @error Then Return "" if $sImageFilename <> $sFilename then _ImageWrite($iMonitorNum, $sImageFilename) return $sImageFilename Else return "" EndIf EndFunc func _ImageEdit($iMonitorNum) ShellExecutewait(RegRead($sAppSettings & "\" & $iCurrentID, $iMonitorNum)) _DesktopUpdate() EndFunc func _ImageInfo($iMonitorNum) $sName = Stringright($aImageInfo[$iMonitorNum], Stringlen($aImageInfo[$iMonitorNum]) - StringInStr($aImageInfo[$iMonitorNum], "\",0,-1)) $sPath = StringLeft($aImageInfo[$iMonitorNum], Stringlen($aImageInfo[$iMonitorNum]) - (Stringlen($aImageInfo[$iMonitorNum]) - StringInStr($aImageInfo[$iMonitorNum], "\",0,-1) + 1)) $fSize = round(fileGetSize($aImageInfo[$iMonitorNum])/1024,2) $aModTime = FileGetTime($aImageInfo[$iMonitorNum]) $sMsg = "" $sMsg = "Name:" & @CRLF & " " & $sName & @CRLF $sMsg &= "Path:" & @CRLF & " " & $sPath & @CRLF $sMsg &= "Size:" & @CRLF & " " & $fSize & " KB" & @CRLF $sMsg &= "Attributes: " & @CRLF & " " & FileGetAttrib($aImageInfo[$iMonitorNum]) & @CRLF $sMsg &= "Modified:" & @CRLF & " " & $aModTime[1] & "/" & $aModTime[2] & "/" & $aModTime[0] & " @ " & $aModTime[3] & ":" & $aModTime[4] & @CRLF $sMsg &= @CRLF & "Would you like to open this location with Explorer?" if MsgBox(4+256,$sAppTitle & " - Monitor " & $iMonitorNum & " - Image Information", $sMsg) = 6 then run('explorer "' & $sPath & '"') EndFunc func _ImageRead($iMonitorNum=0) if $iMonitorNum = 0 Then for $i = 1 to $aEnabledMonitorInfo[0][0] $aImageInfo[$i] = RegRead($sAppSettings & "\" & $iDesktopID, $i) Next $aImageInfo[$aEnabledMonitorInfo[0][0]+1] = RegRead($sAppSettings & "\" & $iDesktopID, $aEnabledMonitorInfo[0][0] + 1) $aImageInfo[0] = $aEnabledMonitorInfo[0][0]+1 Elseif $iMonitorNum = $aEnabledMonitorInfo[0][0] + 1 then return RegRead($sAppSettings & "\" & $iDesktopID, $aEnabledMonitorInfo[0][0] + 1) Else return RegRead($sAppSettings & "\" & $iDesktopID, $iMonitorNum) EndIf return $aImageInfo EndFunc Func _ImageWrite($iMonitorNum, $sFilename) RegWrite($sAppSettings & "\" & $iDesktopID, $iMonitorNum, "REG_SZ", $sFilename) RegWrite($sAppSettings & "\" & $iDesktopID, "Last", "REG_SZ", $sFilename) RegWrite($sAppSettings, "Last", "REG_SZ", $sFilename) RegWrite($sAppSettings & "\" & $iDesktopID, "Active", "REG_SZ", $iMonitorNum) $aImageInfo[$iMonitorNum] = $sFilename EndFunc Func _MonitorInfo() ;;Const $ENUM_CURRENT_SETTINGS = -1 ;;Const $ENUM_REGISTRY_SETTINGS = -2 Const $MONITORINFO = "int;int[4];int[4];int" Const $DISPLAY_DEVICE = "int;char[32];char[128];int;char[128];char[128]" Const $DEVMODE = "byte[32];short;short;short;short;int;int[2];int;int;short;short;short;short;short;byte[32];short;ushort;int;int;int;int" $dll = DllOpen("user32.dll") Dim $aMonitorInfo[1][5] $dev = 0 $id = 0 $msg = "" Dim $dd = DllStructCreate($DISPLAY_DEVICE) DllStructSetData($dd, 1, DllStructGetSize($dd)) $EnumDisplays = DllCall($dll, "int", "EnumDisplayDevices", "ptr", 0, "int", $dev, "ptr", DllStructGetPtr($dd), "int", 0) $StateFlag = Number(StringMid(Hex(DllStructGetData($dd, 4)), 3)) While $EnumDisplays[0] <> 0 ;;If ($StateFlag <> $DISPLAY_DEVICE_MIRRORING_DRIVER) And ($StateFlag <> 0) Then If ($StateFlag <> 0) Then Dim $dm = DllStructCreate($DEVMODE) DllStructSetData($dm, 4, DllStructGetSize($dm)) $EnumDisplaysEx = DllCall($dll, "int", "EnumDisplaySettingsEx", "str", DllStructGetData($dd, 2), "int", $ENUM_CURRENT_SETTINGS, "ptr", DllStructGetPtr($dm), "int", 0) If $EnumDisplaysEx[0] = 0 Then DllCall($dll, "int", "EnumDisplaySettingsEx", "str", DllStructGetData($dd, 2), "int", $ENUM_REGISTRY_SETTINGS, "ptr", DllStructGetPtr($dm), "int", 0) EndIf Dim $hm Dim $mi = DllStructCreate($MONITORINFO) DllStructSetData($mi, 1, DllStructGetSize($mi)) If Mod($StateFlag, 2) <> 0 Then $hm = DllCall($dll, "hwnd", "MonitorFromPoint", "int", DllStructGetData($dm, 7, 1), "int", DllStructGetData($dm, 7, 2), "int", 0) If $hm[0] <> 0 Then DllCall($dll, "int", "GetMonitorInfo", "hwnd", $hm[0], "ptr", DllStructGetPtr($mi)) $id += 1 ReDim $aMonitorInfo[$id+1][5] $aMonitorInfo[$id][0] = Number(Hex($hm[0])) $aMonitorInfo[$id][1] = number(DllStructGetData($mi, 3, 1)) $aMonitorInfo[$id][2] = Number(DllStructGetData($mi, 3, 2)) $aMonitorInfo[$id][3] = Number(DllStructGetData($mi, 3, 3) - $aMonitorInfo[$id][1]) $aMonitorInfo[$id][4] = Number(DllStructGetData($mi, 3, 4) - $aMonitorInfo[$id][2]) EndIf EndIf EndIf $dev += 1 $EnumDisplays = DllCall($dll, "int", "EnumDisplayDevices", "ptr", 0, "int", $dev, "ptr", DllStructGetPtr($dd), "int", 0) $StateFlag = Number(StringMid(Hex(DllStructGetData($dd, 4)), 3)) WEnd $aMonitorInfo[0][0] = $id $dd = 0 $dm = 0 $mi = 0 DllClose($dll) $iTotalMonitors = $id Return $aMonitorInfo EndFunc Func _MonitorInfoDisplay() $msg = "" for $i = 1 to ubound($aMonitorInfo)-1 $msg &= "Display " & $i & " #=" & $aMonitorInfo[$i][0] & @CRLF $msg &= "Display " & $i & " x=" & $aMonitorInfo[$i][1] & @CRLF $msg &= "Display " & $i & " y=" & $aMonitorInfo[$i][2] & @CRLF $msg &= "Display " & $i & " w=" & $aMonitorInfo[$i][3] & @CRLF $msg &= "Display " & $i & " h=" & $aMonitorInfo[$i][4] & @CRLF & @CRLF Next _consolewrite($msg) EndFunc func _MenuMonitor() $msg = TrayGetMsg () Select Case $msg = $TRAY_EVENT_PRIMARYDOWN _VistasGUI() Case $msg = $mDefine _VistasGUI() Case $msg = $mSave _ProfileSave() Case $msg = $mLoad _ProfileLoad() Case $msg = $mAbout _AboutDialog() Case $msg = $mDebug _DefineSetting("Debug", Not $bDebug) case $msg = $mUpdate _UpdateCheck() case $msg = $mHomepage _ShellExecute($sAppHome) case $msg = $mSupport _ShellExecute($sAppSupport) case $msg = $mNews _ShellExecute($sAppNews) case $msg = $mExit _Exit() EndSelect EndFunc Func _ProfileLoad($sFilename="") if $sFilename = "" Then $sLastPath = RegRead($sAppSettings & "\" & $iDesktopID & "\" & "Recent", "1") if $sLastPath = "" Then $sLastPath = @UserProfileDir Else $sLastPath = StringLeft($sLastPath, Stringlen($sLastPath) - (Stringlen($sLastPath) - StringInStr($sLastPath, "\",0,-1))) EndIf $sFilename = FileOpenDialog($sAppTitle & " - Load " & $sAppName, $sLastPath, $sAppName & " files (*" & $sAppFileType & ")|All files (*.*)", 16) if @error Then Return EndIf if Iniread($sFilename, $sAppname, "DesktopID", "") <> $iDesktopID Then if MsgBox(0,$sAppname,"This profile appears to have been created with an earler version of " & $sAppname & " or under a different desktop layout. Loading the images to your current desktop my produce strange streching/compression of the images. Do you want to continue loading this profile?") = 7 then Return EndIf _RecentWrite($sFilename) for $i = 1 to $aEnabledMonitorInfo[0][0] + 1 _ImageWrite($i, "") $sImageFilename = Iniread($sFilename, $sAppname, $i, "") if $sImageFilename <> "" then if FileExists($sImageFilename) Then _ImageWrite($i, $sImageFilename) Else msgbox(0,$sAppTitle & " - File not found", "Defined profile for screen #" & $i & " not found: " & @CRLF & @CRLF & " " & $sImageFilename & @CRLF & @CRLF & " Most likely it was moved, renamed, or deleted. Skipping.") EndIf EndIf Next RegWrite($sAppSettings & "\" & $iDesktopID, "Active", "REG_SZ", Iniread($sFilename, $sAppname, "Active", "1")) _DesktopUpdate() EndFunc Func _ProfileSave() $sLastPath = RegRead($sAppSettings & "\" & $iDesktopID & "\" & "Recent", "1") if $sLastPath = "" Then $sLastPath = @UserProfileDir Else $sLastPath = StringLeft($sLastPath, Stringlen($sLastPath) - (Stringlen($sLastPath) - StringInStr($sLastPath, "\",0,-1))) EndIf $sFilename = FileSaveDialog($sAppTitle & " - Save Vistas", $sLastPath, $sAppName & " files (*" & $sAppFileType & ")|All files (*.*)", 16) if @error Then return if not stringinstr($sFilename, $sAppFileType) then $sFilename &= $sAppFileType for $i = 1 to $aEnabledMonitorInfo[0][0] + 1 IniWrite($sFilename, $sAppname, $i, $aImageInfo[$i]) Next IniWrite($sFilename, $sAppname, "DesktopID", $iDesktopID) IniWrite($sFilename, $sAppname, "Active", RegRead($sAppSettings & "\" & $iDesktopID, "Active")) _RecentWrite($sFilename) _DesktopUpdate() EndFunc Func _RecentRead() for $i = 1 to 10 $aRecentInfo[$i] = RegRead($sAppSettings & "\" & $iDesktopID & "\Recent", $i) next EndFunc Func _RecentWrite($sFilename) for $i = 1 to 10 if $sFilename = RegRead($sAppSettings & "\" & $iDesktopID & "\Recent", $i) then return next For $i = 9 to 1 step -1 $sResult = RegRead($sAppSettings & "\" & $iDesktopID & "\Recent", $i) RegWrite($sAppSettings & "\" & $iDesktopID & "\Recent", $i + 1, "REG_SZ", $sResult) $aRecentInfo[$i+1] = $sResult Next RegWrite($sAppSettings & "\" & $iDesktopID & "\Recent", "1", "REG_SZ", $sFilename) $aRecentInfo[1] = $sFilename EndFunc Func _SettingsLoad() _ConsoleWrite("+ _SettingsLoad()") ;~ ****** $bVerbose = RegRead($sAppSettings, "Verbose") _ConsoleWrite("- _SettingsLoad()") EndFunc Func _SettingsSave() _ConsoleWrite("+ _SettingsSave()") ;~ ****** Regwrite($sAppSettings, "Verbose", "REG_SZ", $bVerbose) _ConsoleWrite("- _SettingsSave()") EndFunc Func _ShellExecute($sCmd) _ConsoleWrite("+ _ShellExecute()") if $sCmd = "" Then _ConsoleWrite(": No command passed") Else _ConsoleWrite(": Running '" & $sCmd & "'") shellExecute($sCmd) EndIf _ConsoleWrite("- _ShellExecute()") endfunc Func _ShellExecuteWait($sCmd) _ConsoleWrite("+ _ShellExecuteWait()") if $sCmd = "" Then _ConsoleWrite(": No command passed") Else _ConsoleWrite(": Running '" & $sCmd & "'") ShellExecuteWait($sCmd) EndIf _ConsoleWrite("- _ShellExecuteWait()") endfunc func _UpdateCheck() _ConsoleWrite("+ _UpdateCheck()") $sTemp = "" $aTemp = stringsplit(_InetGetSource($sAppHome & "/" & stringlower($sAppName) & ".au3"), @CRLF) For $i = 1 to $aTemp[0] if StringInStr($aTemp[$i], "$sAppVersion") then $sTemp = $aTemp[$i] ExitLoop endif Next if $sTemp <> "" then $aOnlineVersion = StringSplit($sTemp, "=") $sOnlineVersion = StringReplace(StringStripWS($aOnlineVersion[2], 8), '"', "") _ConsoleWrite(": Online = " & $sOnlineVersion) _ConsoleWrite(": User = " & $sAppVersion) if $sOnlineVersion <> "" and Not Stringinstr($sOnlineVersion, "") Then If $sAppVersion < $sOnlineVersion Then _ConsoleWrite(": User is OLDER") $sMsg = "A newer version of this program is available for download." & @CRLF & @CRLF $sMsg &= "Do you want to visit the " & $sAppname & " site to download v." & $sOnlineVersion & "?" & @CRLF & @CRLF $sMsg &= "Selecting 'Yes' will close this app and take you to the website." If MsgBox(4, $sAppTitle, $sMsg) = 6 Then _ConsoleWrite(": Launching default web browser to " & $sAppHome) _ShellExecute($sAppHome) Exit EndIf ElseIf $sAppVersion >= $sOnlineVersion Then _ConsoleWrite(": User is UP-TO-DATE") TrayTip($sAppTitle, "Your version is up-to-date.",5) EndIf Else _ConsoleWrite(": Data received but no version info found") traytip($sAppTitle,"Unable to locate versioning info in data received." & @CRLF & "Please go to the homepage for further update details.",5) EndIf Else _ConsoleWrite(": Unable to obtain version content") traytip($sAppTitle,"Unable to obtain online version info." & @CRLF & "Check your connection and try again.",5) EndIf _ConsoleWrite("- _UpdateCheck()") EndFunc func _VistasGUI() $iGUIHeight = 160 + ($aEnabledMonitorInfo[0][0] * 30) $hDialog = GuiCreate($sAppTitle & " - Background Selection", 330, $iGUIHeight, -1, -1, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS)) Global $aFilename[$aEnabledMonitorInfo[0][0]+2] Global $aButton[$aEnabledMonitorInfo[0][0]+2] $oLabel1 = GuiCtrlCreateLabel("Displays are identified from far left (1) to far right (" & $aEnabledMonitorInfo[0][0] & ") with (P) standing for Panoramic. Using the buttons below will facilitate image selection for the cooresponding display after which the selected image will be stretched to fit the display specified." & @CRLF & @CRLF & "Once a image is defined, you can right-click the background to change the image and toggle between 1-to-1 and panoramic display.", 10, 10, 300, 110) for $i = 1 to $aEnabledMonitorInfo[0][0] $aButton[$i] = GuiCtrlCreateButton("&" & $i, 10, 100+($i*30), 20, 20) $aFilename[$i] = GuiCtrlCreateInput(RegRead($sAppSettings & "\" & $iDesktopID, $i), 40, 100+($i*30), 280, 20) next $aButton[$aEnabledMonitorInfo[0][0]+1] = GuiCtrlCreateButton("&P", 10, 100+(($aEnabledMonitorInfo[0][0]+1)*30), 20, 20) $aFilename[$aEnabledMonitorInfo[0][0]+1] = GuiCtrlCreateInput(RegRead($sAppSettings & "\" & $iDesktopID, $aEnabledMonitorInfo[0][0]+1), 40, 100+(($aEnabledMonitorInfo[0][0]+1)*30), 280, 20) GuiSetState() While 1 $msg = GuiGetMsg() $iMonitorNum=0 for $i = 1 to $aEnabledMonitorInfo[0][0]+1 if $msg = $aButton[$i] then $iMonitorNum = $i next if $iMonitorNum <> 0 Then _ImageChange($iMonitorNum) GUICtrlSetImage($aPictureHandles[$iMonitorNum],$aImageInfo[$iMonitorNum]) GUICtrlSetData($aFilename[$iMonitorNum], $aImageInfo[$iMonitorNum]) _ImageRead() _DesktopUpdate() WinActivate($sAppTitle, "Displays are identified from far left") $iMonitorNum = 0 EndIf if $msg = $GUI_EVENT_CLOSE then ExitLoop WEnd GUIDelete($hDialog) EndFunc