Show Desktop

April 16th, 2011 Leave a comment Go to comments

Downloads:

Executable
Source Code (C#)

Description:

This is an application to replace the old Show Desktop Button, functionally all this application does is use the windows API to send LWin+D and the exits, it simple and sweet, but when pinned next to the start button it serves the desired effect.

Screen Shot(s):

Notable Code:

This application makes use of two different 3rd party products
inputsimulator – http://inputsimulator.codeplex.com/ (included in Source)
Input simulator is a wrapper for Pinvoke, and makes using the windows API much simpler

ILMerge – http://research.microsoft.com/en-us/people/mbarnett/ilmerge.aspx (included in source)
ILMerge allows for multiple assemblies to be combined into a single exe

using WindowsInput;

namespace ShowDesktop
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        //private Type typeShell = null;
        //private object objShell = Type.Missing;

        private void Form1_Load(object sender, EventArgs e)
        {
            /*
            typeShell=Type.GetTypeFromProgID("Shell.Application");
            objShell=Activator.CreateInstance(typeShell);
            typeShell.InvokeMember("MinimizeAll", System.Reflection.BindingFlags.InvokeMethod, null, objShell, null);
            */

            //http://inputsimulator.codeplex.com/
            //this is a wrapper for pinvoke, and works like it should, unlike the above method.
            InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.VK_D);
            Application.Exit();
        }
    }
}

Note the commented out section was an attempt to use the method suggested by Microsoft, but in reality Shell.Application.MinimizeAll does not produce the same behavior as Lwin+D

  1. No comments yet.
  1. No trackbacks yet.