<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Huddled Masses &#187; Popup</title>
	<atom:link href="http://joelbennett.net/tag/popup/feed/" rel="self" type="application/rss+xml" />
	<link>http://joelbennett.net</link>
	<description>The internet home of Joel "Jaykul" Bennett...</description>
	<lastBuildDate>Sat, 28 Jan 2012 21:37:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<cloud domain='joelbennett.net' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>More Growl for Windows from PowerShell</title>
		<link>http://joelbennett.net/more-growl-for-windows-from-powershell/</link>
		<comments>http://joelbennett.net/more-growl-for-windows-from-powershell/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 05:45:05 +0000</pubDate>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
				<category><![CDATA[Huddled]]></category>
		<category><![CDATA[Growl]]></category>
		<category><![CDATA[Growl for Windows]]></category>
		<category><![CDATA[Notifications]]></category>
		<category><![CDATA[Popup]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://huddledmasses.org/?p=1237</guid>
		<description><![CDATA[Well, I&#8217;m back already with an update for the Growl module I posted yesterday &#8230; This new version is a true PowerShell 2.0 only module, because I found that the Growl callbacks can only be handled in PowerShell 2.0 anyway, so in order to add support for that, I went ahead and upgraded the rest. [...]]]></description>
			<content:encoded><![CDATA[	<p>Well, I&#8217;m back already with an update for the Growl module <a href="http://huddledmasses.org/growl-for-windows-from-powershell/">I posted yesterday</a> &#8230;</p>

	<p>This new version is a true PowerShell 2.0 only module, because I found that the Growl callbacks can only be handled in PowerShell 2.0 anyway, so in order to add support for that, I went ahead and upgraded the rest.</p>

	<p>The Growl module is now designed to be used BY your PowerShell scripts and modules.  The idea is that if you wrote, say, a script/module to check for email and called it PoshMail &#8230; you could start up Growl like this:</p>

	<div class="posh code posh" style="font-family:monospace;"><br />
<span style="color: #0066cc; font-style: italic;">Import-<span style="font-style: normal;">Module</span></span> Growl<br />
<br />
<span style="color: #666666; font-style: italic;">## At least once (e.g.: on the first Type you register) you should include an AppIcon :)</span><br />
<span style="color: #0066cc; font-style: italic;">Register-<span style="font-style: normal;">GrowlType</span></span> PoshMail NewMail <span style="color: #000066;">-AppIcon</span> <span style="color: #660033; font-weight: bold;">$PoshMailFolder</span>\Email<span style="color: #66cc66;">-</span>48.<span style="color: #003366;">png</span> <br />
<span style="color: #666666; font-style: italic;">## If you want to, you can still override the icon per notice type</span><br />
<span style="color: #0066cc; font-style: italic;">Register-<span style="font-style: normal;">GrowlType</span></span> PoshMail Hotmail <span style="color: #000066;">-Icon</span> <span style="color: #660033; font-weight: bold;">$PoshMailFolder</span>\Hotmail<span style="color: #66cc66;">-</span>48.<span style="color: #003366;">png</span><br />
<span style="color: #0066cc; font-style: italic;">Register-<span style="font-style: normal;">GrowlType</span></span> PoshMail GMail <span style="color: #000066;">-Icon</span> <span style="color: #660033; font-weight: bold;">$PoshMailFolder</span>\GMail<span style="color: #66cc66;">-</span>48.<span style="color: #003366;">png</span> <br />
&nbsp;</div>

	<p>Now, technically that&#8217;s all we have to do. At that point, we could pop up Growl notices for either Hotmail or GMail &#8230; let&#8217;s say our fictitious script (which is running in the background on an event timer) discovers a new message &#8230;  you could notify the user with a Url callback.  Let&#8217;s assume that you have a few variables set after checking for email:
	<ul>
		<li>$Number is the number of email messages</li>
		<li>$Subjects is an array of email subject lines</li>
	</ul>
	<ul>
		<li>$Urls is an array of links to the emails</li>
	</ul></p>

	<div class="posh code posh" style="font-family:monospace;"><br />
<span style="color: #0066cc; font-style: italic;">Send-<span style="font-style: normal;">Growl</span></span> PoshMail GMail <span style="color: #009900;">&quot;You have $number new messages&quot;</span> <span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$Summary</span><span style="color: #333;">&#91;</span>0..2<span style="color: #333;">&#93;</span> <span style="color: #000066;">-join</span> <span style="color: #009900;">&quot;<span style="color: #000099; font-weight: bold;">`n</span>&quot;</span><span style="color: #333;">&#41;</span> <span style="color: #000066;">-Url</span> <span style="color: #660033; font-weight: bold;">$Urls</span><span style="color: #333;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #333;">&#93;</span><br />
<span style="color: #666666; font-style: italic;"># OR ...</span><br />
<span style="color: #0066cc; font-style: italic;">Send-<span style="font-style: normal;">Growl</span></span> PoshMail Hotmail <span style="color: #009900;">&quot;You have $number new messages&quot;</span> <span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$Summary</span><span style="color: #333;">&#91;</span>0..2<span style="color: #333;">&#93;</span> <span style="color: #000066;">-join</span> <span style="color: #009900;">&quot;<span style="color: #000099; font-weight: bold;">`n</span>&quot;</span><span style="color: #333;">&#41;</span> <span style="color: #000066;">-Url</span> <span style="color: #660033; font-weight: bold;">$Urls</span><span style="color: #333;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #333;">&#93;</span><br />
&nbsp;</div>

	<p>Of course, if you wanted to launch your Outlook 2010 preview because you discovered new <span class="caps">POP</span> or <span class="caps">IMAP</span> mail &#8230; or because you want to use Outlook to read your Hotmail/GMail &#8230; then a callback <span class="caps">URL</span> isn&#8217;t going to cut it.  In that case, you want to handle the click event yourself:</p>

	<div class="posh code posh" style="font-family:monospace;"><br />
<br />
<span style="color: #666666; font-style: italic;">## We would need it to launch something appropriate on receipt of new POP3 email, for instance.</span><br />
<span style="color: #0066cc; font-style: italic;">Register-<span style="font-style: normal;">GrowlCallback</span></span> <span style="color: #333;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #666699; font-weight: bold;">PARAM</span><span style="color: #333;">&#40;</span> <span style="color: #660033; font-weight: bold;">$response</span>, <span style="color: #660033; font-weight: bold;">$context</span> <span style="color: #333;">&#41;</span><br />
&nbsp; &nbsp;<span style="color: #666666; font-style: italic;"># This is just here for your sake, because I know you want to know what else is in there:</span><br />
&nbsp; &nbsp;<span style="color: #0066cc; font-style: italic;">Write-<span style="font-style: normal;">Host</span></span> $<span style="color: #333;">&#40;</span><span style="color: #009900;">&quot;Response Type: {0}<span style="color: #000099; font-weight: bold;">`n</span>Notification ID: {1}<span style="color: #000099; font-weight: bold;">`n</span>Callback Data: {2}<span style="color: #000099; font-weight: bold;">`n</span>Callback Data Type: {3}&quot;</span> <span style="color: #000066;">-f</span> <span style="color: #660033; font-weight: bold;">$context</span>.<span style="color: #003366;">Result</span>, <span style="color: #660033; font-weight: bold;">$context</span>.<span style="color: #003366;">NotificationID</span>, <span style="color: #660033; font-weight: bold;">$context</span>.<span style="color: #666699; font-weight: bold;">Data</span>, <span style="color: #660033; font-weight: bold;">$context</span>.<span style="color: #003366; font-weight: bold;">Type</span><span style="color: #333;">&#41;</span> <span style="color: #000066;">-fore</span> Yellow<br />
&nbsp; &nbsp;<span style="color: #666699; font-weight: bold;">if</span><span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$context</span>.<span style="color: #003366;">Result</span> <span style="color: #000066;">-eq</span> <span style="color: #009900;">&quot;Click&quot;</span><span style="color: #333;">&#41;</span> <span style="color: #333;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">## Start the default email client</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0066cc; font-style: italic;">Start-<span style="font-style: normal;">Process</span></span> $<span style="color: #333;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #660033; font-weight: bold;">$MailTo</span> <span style="color: #66cc66;">=</span> <span style="color: #333;">&#40;</span><span style="color: #660033;">gp</span> Registry::<span style="color: #003366;">HKEY_CLASSES_ROOT</span>\mailto\shell\open\command<span style="color: #333;">&#41;</span>.<span style="color: #009900;">&quot;(default)&quot;</span> <span style="color: #000066;">-split</span> <span style="color: #009900;">&quot; &quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666699; font-weight: bold;">for</span><span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$i</span><span style="color: #66cc66;">=</span><span style="color: #cc66cc;">0</span>;<span style="color: #660033; font-weight: bold;">$i</span><span style="color: #66cc66;">-</span><span style="color: #333399; font-weight: bold; font-style: italic;">lt</span><span style="color: #660033; font-weight: bold;">$mailto</span>.<span style="color: #003366;">Count</span>;<span style="color: #660033; font-weight: bold;">$i</span><span style="color: #66cc66;">++</span><span style="color: #333;">&#41;</span> <span style="color: #333;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #660033; font-weight: bold;">$email</span> <span style="color: #66cc66;">=</span> <span style="color: #009900;">&quot;$($mailto[0..$i])&quot;</span>.<span style="color: #003366;">Trim</span><span style="color: #333;">&#40;</span><span style="color: #009900;">'&quot;'</span><span style="color: #333;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666699; font-weight: bold;">if</span><span style="color: #333;">&#40;</span><span style="color: #0066cc; font-style: italic;">Resolve-<span style="font-style: normal;">Path</span></span> <span style="color: #660033; font-weight: bold;">$email</span><span style="color: #333;">&#41;</span><span style="color: #333;">&#123;</span> <span style="color: #666699; font-weight: bold;">return</span> <span style="color: #660033; font-weight: bold;">$email</span> <span style="color: #333;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #333;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #333;">&#41;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #333;">&#125;</span><br />
<span style="color: #333;">&#125;</span><br />
&nbsp;</div>

	<p>Something like that should work regardless of your actual email client, and then you just have to pass a callback value to make sure your function gets called:</p>

	<div class="posh code posh" style="font-family:monospace;"><br />
<span style="color: #666666; font-style: italic;"># This would trigger the callback REGARDLESS of whether it was clicked.</span><br />
<span style="color: #0066cc; font-style: italic;">Send-<span style="font-style: normal;">Growl</span></span> PoshMail NewMail <span style="color: #009900;">&quot;You have $number new messages&quot;</span> <span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$Summary</span><span style="color: #333;">&#91;</span>0..2<span style="color: #333;">&#93;</span> <span style="color: #000066;">-join</span> <span style="color: #009900;">&quot;<span style="color: #000099; font-weight: bold;">`n</span>&quot;</span><span style="color: #333;">&#41;</span> <span style="color: #000066;">-CallbackData</span> <span style="color: #009900;">&quot;Data&quot;</span> <span style="color: #009900;">&quot;POP3 Callback&quot;</span><br />
&nbsp;</div>

	<p>There are a lot of other possibilities here, from alerting when long running commands finish (think PSJobs, or even remote jobs) to &#8230; writing popup-based PowerShell instant messengers, or even &#8230; using Growl as a ghetto inter-process communication medium which works on multiple PCs.  Ok, that&#8217;s maybe a bit much, but the point is: sky&#8217;s the limit. Have a little fun.  Note that the machine <span class="caps">SENDING</span> the popups doesn&#8217;t necessarily have to have Growl installed &#8212; you could just copy the libraries over and then send remote growls&#8230;.</p>

	<p><script type="text/javascript" src="http://poshcode.org/embed/1276"></script></p>]]></content:encoded>
			<wfw:commentRss>http://joelbennett.net/more-growl-for-windows-from-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Growl for Windows &#8211; From PowerShell</title>
		<link>http://joelbennett.net/growl-for-windows-from-powershell/</link>
		<comments>http://joelbennett.net/growl-for-windows-from-powershell/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 06:10:35 +0000</pubDate>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
				<category><![CDATA[Huddled]]></category>
		<category><![CDATA[Growl]]></category>
		<category><![CDATA[Growl for Windows]]></category>
		<category><![CDATA[Notifications]]></category>
		<category><![CDATA[Popup]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://huddledmasses.org/?p=1231</guid>
		<description><![CDATA[This is just a quick post (as I promised, recently) to let you all know that I&#8217;ve published the first release of my Growl for Windows module for PowerShell over on PoshCode. I haven&#8217;t been able to get callbacks to work, and I spent way too much time playing with them instead of publishing this, [...]]]></description>
			<content:encoded><![CDATA[<div class="zemanta-img"><div><dl class="wp-caption alignright"><a href="http://GrowlForWindows.com"><img src="http://www.GrowlForWindows.com/gfw/images/growl4windows.jpg" alt="Growl" title="Growl" /></a></dl></div></div>

	<p>This is just a quick post (as I promised, recently) to let you all know that I&#8217;ve published the first release of my <a href="http://GrowlForWindows.com">Growl for Windows</a> module for PowerShell over on PoshCode.</p>

	<p>I haven&#8217;t been able to get callbacks to work, and I spent way too much time playing with them instead of publishing this, or working on remote growls &#8230; but nonetheless, it&#8217;s sufficient to let you pop up growl notifications from scripts, which you can, of course, customize in Growl itself. </p>

	<p>You can add a few additional notice types very simply (you just hard code them in the script, copying lines 19 and 21 &#8212; remember you need to use the same notice names each time anyway) ... and then tweak them in Growl to have different display types, or to make some of your notice types sticky, or have them forwarded to your iPhone or whatever. </p>

	<h3>Here&#8217;s the first version of the script:</h3>

<script type="text/javascript" src="http://PoshCode.org/embed/1274"></script>

	<p>Note: if you want to use this on PowerShell 1.0, just comment out the <code>[Parameter(</code> lines, and dot-source it, it <em>should</em> work fine.  In PowerShell 2.0 you&#8217;ll want to load it as a module, because doing so will hide some of those ugly script variables.</p>]]></content:encoded>
			<wfw:commentRss>http://joelbennett.net/growl-for-windows-from-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

