Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Shell_NotifyIcon uses IUserNotification under the hood. I played around with it and made a <a href="http://www.paralint.com/projects/notifu">utility out of it</a>. I heard of a visually impaired sysadmin who uses it to make his scripts screen reader compatible. It is command line, it does not have a message loop. </p> <p>It is self aware, meaning that notifications sent to it will be queued (you have control over it). For that to work, I provided a IQueryContinue implementation. The project is in C++ and is open source, help yourself. </p> <p>Here is the guts of it :</p> <pre><code> HRESULT NotifyUser(const NOTIFU_PARAM&amp; params, IQueryContinue *querycontinue, IUserNotificationCallback *notifcallback) { HRESULT result = E_FAIL; IUserNotification *un = 0; IUserNotification2 *deux = 0; //French pun : "un" above stands for UserNotification but it also means 1 in French. deux means 2. //First try with the Vista/Windows 7 interface //(unless /xp flag is specified if (!params.mForceXP) result = CoCreateInstance(CLSID_UserNotification, 0, CLSCTX_ALL, IID_IUserNotification2, (void**)&amp;deux); //Fall back to Windows XP if (!SUCCEEDED(result)) { TRACE(eWARN, L"Using Windows XP interface IUserNotification\n"); result = CoCreateInstance(CLSID_UserNotification, 0, CLSCTX_ALL, IID_IUserNotification, (void**)&amp;un); } else { TRACE(eINFO, L"Using Vista interface IUserNotification2\n"); un = (IUserNotification*)deux; //Rather ugly cast saves some code... } if (SUCCEEDED(result)) { const std::basic_string&lt;TCHAR&gt; crlf_text(L"\\n"); const std::basic_string&lt;TCHAR&gt; crlf(L"\n"); std::basic_string&lt;TCHAR&gt; text(params.mText); size_t look = 0; size_t found; //Replace \n with actual CRLF pair while ((found = text.find(crlf_text, look)) != std::string::npos) { text.replace(found, crlf_text.size(), crlf); look = found+1; } result = un-&gt;SetIconInfo(params.mIcon, params.mTitle.c_str()); result = un-&gt;SetBalloonInfo(params.mTitle.c_str(), text.c_str(), params.mType); //Looks like it controls what happends when the X button is //clicked on result = un-&gt;SetBalloonRetry(0, 250, 0); if (deux) result = deux-&gt;Show(querycontinue, 250, notifcallback); else result = un-&gt;Show(querycontinue, 250); un-&gt;Release(); } return result; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload