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"
Click here to download the Script
[?]
