This is a gadget for the Windows Vista sidebar. It embeds a snippet of any webpage you like into the sidebar. It comes with some suggestions -- Seattle traffic maps and weather, news headlines from BBC, a webcam of Times Square -- but it's more fun to point it at your own favourite webpage. Use its handy drag-and-resize interface (the red rectangle in the picture) to let you chose which bit of the webpage you want to appear in your sidebar.
The gadget refreshes itself every ten minutes. Of course, some pages refresh update themselves quicker than that (e.g. webcams) so if you point at them you'll get quicker updates. And you can have the gadget point directly to an online image (jpeg or gif). Most pages will work just fine. You can even put Youtube videos right there in your sidebar! But don't point to pages with popup windows, because they'll be a pain.
Source code: gadgets are written in Javascript. So you can just download the gadget file, rename it to "zip", and look inside. Here: EyeOnTheWeb.zip. One neat feature of the gadget is that it detects system idle time: if doesn't refresh itself while you're away from your computer. I wrote a small Windows utility for this purpose, GetIdleTime.exe, which returns as its exit-code the number of milliseconds elapsed since the last input. Source code (Visual C++, 3k).
This is javascript code to obtain the system idle time for a gadget. It uses System.Gadget.path because I keep my GetIdleTime.exe in the same directory as the gadget. It uses shell.Run to launch the utility and obtain the exit code. Note that this requires local privileges. (which Vista grants to gadgets).
function GetIdleTime() { var cmd = "GetIdleTime.exe"; if (gok) cmd=System.Gadget.path+"\\"+cmd; return shell.Run("\""+cmd+"\"",0,true); }
This is the C++ code for the GetIdleTime utility:
#define _WIN32_WINNT 0x0500 #include <windows.h> extern int _stdcall mainCRTStartup(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow) { LASTINPUTINFO lii; lii.cbSize=sizeof(lii); GetLastInputInfo(&lii); int i = GetTickCount()-lii.dwTime; char buf[100]; wsprintf(buf,"%i",i); WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),buf,lstrlen(buf),0,0); return i; }
I used mainCRTStartup, and WriteFile, so as to bypass the CRT. This brings the size of the GetIdleTime.exe executable down to just 2888 bytes.