Processing Ajax...

Title
Close Dialog

Message

Confirm
Close Dialog

Confirm
Close Dialog

Confirm
Close Dialog

Auto-Save Desktop Icon Profiles

Description
This functions runs forever and automatically saves your desktop icon profile every N minutes.
Language
C#.net
Minimum Version
Created By
kaweksl513742
Contributors
-
Date Created
Jan 5, 2015
Date Last Modified
Jan 5, 2015

Scripted Function (Macro) Code

using System;
using System.Collections.Generic;
using System.Drawing;

// Function saves icons layout automatically every some time
// Number after M means active monitoru count that layout is for
//
// It's needed for me since I enable monitors on demand with monitor profiles
// and icon saving its not relevant to monitor but overall desktop/multiple monitors
//
// * You may want to disable Icons save notification in Advanced Settings
// * If you want to start this function with logon put that into autostart
//	<PathToDisplayFusion>\DisplayFusionCommand.exe -functionrun "Icons AutoSave"
//
public static class DisplayFusionFunction
{
	public static void Run(IntPtr windowHandle)
	{
		// Refresh every n minutes
		const int refreshRate = 20;
		
		//Number of saves per Monitor setup
		const int MaxSaves = 3;

		int saveNr = 1;
		string saveAs = "";
		while (true)
		{
			if (saveNr > MaxSaves)
				saveNr = 1;
				
			Rectangle OverallRes = new Rectangle(0, 0, 0, 0); 
			Rectangle[] MBounds = BFS.Monitor.GetMonitorBounds();
			
			for (int i = 0; i < MBounds.Length; i++) 
				OverallRes = Rectangle.Union(OverallRes, MBounds[i]);

			//MBounds.Length == active monitors number
			saveAs = string.Format("AutoSave_M{0}_{1}x{2}_{3}", MBounds.Length, OverallRes.Width,OverallRes.Height,saveNr);
			BFS.DisplayFusion.SaveDesktopIconsProfile(saveAs);
			BFS.General.Sleep(refreshRate*60*1000);
			saveNr++;
		}
	}
}