::::::::: PowerShell :::::::::
Friday, November 11, 2005
  Show Desktop in MSH way
Ok, I have modified "/\/\o\/\/" yet further.
I have lost that darn "show desktop" button and it was a pain in the ass to get it back on to my "quick launch". Ah, and yeah, when i program, I need to title windows either horizontally or vertically so that i could compare two code side by side.

But oh well, to tile windows, i had to select windows one by one pressing controls and then title'em all... So i created another MSH script that do just what I mentioned.

There are many options that Shell.Application offers and I will be extending this script to support all the functionalities that Shell.Application offers...


# ShellUtil.msh
# author: dance2die
# original code author: /\/\o\/\/# date: 11/11/2005 @ 08:51PM


[System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms")

function ShellUtil {

$shell = new-object -com shell.application

$form = new-object System.Windows.Forms.form
$cm = new-object System.Windows.Forms.ContextMenu
$mi = new-object System.Windows.Forms.MenuItem
$ni = new-object System.Windows.Forms.NotifyIcon


# Display "Show Desktop" menu
$miToggle = new-object System.Windows.Forms.MenuItem
$miToggle.Index = 0
$miToggle.Text = "&Show Desktop"

# Display "Minimize All" menu
$miMinAll = new-object System.Windows.Forms.MenuItem
$miMinAll.Text = "&Minimize All Windows"
$miMinAll.Index = 1

# Display "Undo Minimize All" menu
$miUndoMinAll = new-object System.Windows.Forms.MenuItem
$miUndoMinAll.Index = 2
$miUndoMinAll.Text = "&Undo Minimize All Windows";

# Display "Tray Properties" menu
$miTrayProps = new-object System.Windows.Forms.MenuItem
$miTrayProps.Index = 3
$miTrayProps.Text = "&Tray Properties..."

# Display "Cascade Windows" menu
$miCascade = new-object System.Windows.Forms.MenuItem
$miCascade.Index = 4
$miCascade.Text = "&Cascade Windows"

# Display "Tile Horizontally" menu
$miTileH = new-object System.Windows.Forms.MenuItem
$miTileH.Index = 5
$miTileH.Text = "Tile Windows &Horizontally"

# Display "Tile Vertically" menu
$miTileV = new-object System.Windows.Forms.MenuItem
$miTileV.Index = 6
$miTileV.Text = "Tile Windows &Vertically"

# Display "Exit" menu
$miExit = new-object System.windows.Forms.MenuItem
$miExit.Index = 10
$miExit.Text = "E&xit"


$form.contextMenu = $cm
$form.contextMenu.MenuItems.Add($miToggle)
$form.contextMenu.MenuItems.Add($miMinAll)
$form.contextMenu.MenuItems.Add($miUndoMinAll)
$form.contextMenu.MenuItems.Add($miTrayProps)
$form.contextMenu.MenuItems.Add($miCascade)
$form.contextMenu.MenuItems.Add($miTileH)
$form.contextMenu.MenuItems.Add($miTileV)
$form.contextMenu.MenuItems.Add($miExit)


$form.ShowInTaskbar = $False
$form.WindowState = "minimized"
$form.add_Closing({ $form.ShowInTaskBar = $False })

$ni = $ni
$ni.Icon = New-object System.Drawing.Icon("c:\programming\msh\icons\test.ico")
$NI.ContextMenu = $cm
$NI.Text += "Shell Utility";

$tipTitle = "Bah"
$tipText = "Bah"

$miToggle.add_Click({
$shell.ToggleDesktop()
$tipTitle = "Show Desktop"
$tipText = "Toggle Desktop..."
})
$miMinAll.add_Click({
$shell.MinimizeAll()
$tipTitle = "Minimize All..."
$tipText = "Minimize All windows..."
})
$miUndoMinAll.add_Click({
$shell.UndoMinimizeAll()
$tipTitle = "Undo minimize all"
$tipText = "Undo minimize all"
})
$miTrayProps.add_Click({
$shell.TrayProperties()
$tipTitle = "Display Tray Properties"
$tipText = "Modify system tray properties..."
})
$miCascade.add_Click({
$shell.CascadeWindows()
$tipTitle = "Cascade windows"
$tipText = "Cascade all windows"
})
$miTileH.add_Click({
$shell.TileHorizontally()
$tipTitle = "Tile Horizontally"
$tipText = "Tile windows horizontally"
})
$miTileV.add_Click({
$shell.TileVertically()
$tipTitle = "Tile Vertically"
$tipText = "Tile windows vertically"
})
$miExit.add_Click({
$form.Close()
$NI.visible = $false
})

$ni.ShowBalloonTip(0, $tipTitle, $tipText, [System.Windows.Forms.ToolTipIcon]"Info")

$NI.Visible = $True
$form.showDialog()
}


ShellUtil
 
Comments:
As I past this script, All the LineBreaks are gone.

(I did solve that on my blog by using the COnvert to Whitespace option of CodeHTMLer.)

gr /\/\o\/\/
 
Post a Comment

Links to this post:

Create a Link



<< Home
Let's get lazy with PowerShell!

Name:
Location: Flushing, NY, United States

Experimenting with a different format of blogs...

Links
ARCHIVES
10/01/2005 - 11/01/2005 / 11/01/2005 - 12/01/2005 / 12/01/2005 - 01/01/2006 / 01/01/2006 - 02/01/2006 / 02/01/2006 - 03/01/2006 / 03/01/2006 - 04/01/2006 / 04/01/2006 - 05/01/2006 / 05/01/2006 - 06/01/2006 / 06/01/2006 - 07/01/2006 / 07/01/2006 - 08/01/2006 / 08/01/2006 - 09/01/2006 / 10/01/2006 - 11/01/2006 / 11/01/2006 - 12/01/2006 /


Powered by Blogger