Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Desktop layout

$
0
0
Hi
I have found mani example about save/restore desktop layout, i need something simple and i have do this:
[ autoit ]         
#include <GuiListView.au3> #NoTrayIcon Global $hWnd_LV = ControlGetHandle("Program Manager", "", "[CLASS:SysListView32]") Global $sINI = @ScriptDir & "\Configuration.ini" Global $Screen = WinGetHandle("Program Manager") If @OSArch = "X64" And @AutoItX64 = 0 Then  MsgBox(16, "Error", "This version is 32-bit compiled" & @CRLF & _    "and will not run correctly with a 64-bit OS" & @CRLF & @CRLF & _    "Please recompile as a 64-bit executable")  Exit EndIf Opt("TrayMenuMode", 3) Local $SaveItem = TrayCreateItem("Save") Local $RestoreItem = TrayCreateItem("Restore") TrayCreateItem("") Local $ExitItem = TrayCreateItem("Exit") TraySetState() While 1  Switch TrayGetMsg()   Case $SaveItem    Save_Item()   Case $RestoreItem    Restore_Item()   Case $ExitItem    Exit  EndSwitch WEnd Func Save_Item()  WinMinimizeAll() ;show desktop  FileDelete($sINI)  $aScreen_Res = WinGetPos($Screen)  IniWrite($sINI, "Data", "Date", @MDAY & "/" & @MON & "/" & @YEAR)  IniWrite($sINI, "Data", "Resolution", $aScreen_Res[2] & "x" & $aScreen_Res[3])  IniWrite($sINI, "Data", "Unknown_Icon", "MyFolder")  For $nIdx = 0 To _GUICtrlListView_GetItemCount($hWnd_LV) - 1   $sIconText = _GUICtrlListView_GetItemText($hWnd_LV, $nIdx)   $aPos = _GUICtrlListView_GetItemPosition($hWnd_LV, $nIdx)   If @error Then ConsoleWrite("Error: " & $sIconText)   IniWrite($sINI, "Icons", $sIconText, $aPos[0] & ":" & $aPos[1])  Next EndFunc   ;==>Save_Item Func Restore_Item()  Local $i = 0  While $i <= 2 ; Sometime not work at first time   For $nIdx = 0 To _GUICtrlListView_GetItemCount($hWnd_LV) - 1    $sIconText = _GUICtrlListView_GetItemText($hWnd_LV, $nIdx)    $sPosSaved = IniRead($sINI, "Icons", $sIconText, "0:0")    If $sPosSaved <> "" Then     $aPos = StringSplit($sPosSaved, ":")     _GUICtrlListView_SetItemPosition($hWnd_LV, $nIdx, $aPos[1], $aPos[2])    EndIf   Next   $i += 1  WEnd EndFunc   ;==>Restore_Item

The last thing i'd like to add is:
If a icon isn't in the INI ( so is unrecognized ) but is on the desktop create a folder and move in inside.
Please an help, thanks

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>