Reviving MS Clippy with PowerShell

During a conversation about automation with a colleague, we jokingly mentioned that we should automate sending insults to each other. I thought this would be a fun idea and thought it would be even better if the messenger was the classic hero, MS Clippy.


If you don’t remember this guy, he was an excellent addition to Office versions 97 to 2003. The idea was to smooth the transition for users to this new version of the Office suite, popping up occasionally to give you productivity tips and offer help if it thought you needed it. The poor guy didn’t get much love at the time, but I thought he would be perfect for this project.

Firstly, I want to give credit to Stephen Owen who runs as he came up with a lot of the code I’ve used, in his PowerClippy module.

So given that basis, I stripped out the stuff I didn’t want and rewrote the messaging part of the script as this was all I really needed. I needed it handle more than one phrase, which is really easy in PowerShell, you just assign multiple comma separated strings to a variable and you’ve got an array. Then I wrote a small function to pick a random item in the array and assign that to the GUI’s TextBlock.

function randomPhrase{
$x = $Text.Count
Write-Host $x
$i = Get-Random -Maximum $x
$ClippyText.Text = $Text[$i]

Having done this, I needed it to repeat the process every X seconds and display a new message. It was quite easy to get it to popup periodically as I just wrapped my message function in a while($true) statement, which means it will repeat forever. Then I hid the window and then after a short wait, reopened it. However, I came across a bit of difficulty with refreshing the message in the UI. I was sure that the content of the TextBlock was changing because I had that value output to the console, but the UI would just display whatever it did initially.

In the end I managed to fix this by wrapping the entire script in my while statement and using the following to close the window, instead of hiding it and then popping up again after a set time. This meant that the window was completely redrawn every time.

Start-Sleep -Seconds 5
Start-Sleep -Seconds 5

To run the script, you copy the folder with the image and the script to a computer and kick it off with a PSSession and you can revive the joy MS Clippy brought :). Note – If you want to kill it you have to kill the process as its been designed so you can’t close it easily.

Download it from GitHub, here.

Reviving MS Clippy with PowerShell

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s