Write-StickyNote

Here’s a fun script that uses the new “Sticky Notes” in WIndows 7.

The script is based on a simple function that uses the SendKeys() method through the Wscript.Shell COM object. This is a nice example on how you can handle COM objects through PowerShell.

I’ve also included an if statement that checks if StickyNotes is active. If that’s the case, the text will be started in a new StickyNotes.. note..

Anyway, here’s the function.


function Write-StickyNote ([string]$Text) {

	if (gps | Where { $_.ProcessName -match "stikynot" }) {

		$StickyNote = $True
	}

	$Wscript = New-Object -Com Wscript.Shell
	[void]$Wscript.Run("stikynot.exe")
	start-sleep 1

	if ($StickyNote -eq $True) {

		$Wscript.SendKeys("^n")	
	}

	$Wscript.SendKeys($Text)
}

And here’s an example on running the function.


PS > .\Write-StickyNote.ps1 "Hello from PowerShell.nu"

stickynotes01

Click here to download the Script

Rating 3.50 out of 5
[?]

One thought on “Write-StickyNote

  1. Hello,

    Thank you for this very useful script, yet I have a question :

    How can I resize the stickynote ?

    I took a look threw
    New-Object -Com Wscript.Shell | get-member

    and I didn’t find anything helping to do that.

    regards,
    Ahmad

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Anti-Spam Protection by WP-SpamFree