blog’s amazing Rotating Header Image

Active Desktop replacement with Adobe AIR

Interested in simulating XP’s Active Desktop without Active Desktop? We’ve had taken the challenge!

Why?

One of our clients wanted a central web application running on the desktop which provides nearly realtime business information for more than a hundred users in a company. After some discussion with the company’s IT staff we’ve chosen Active Desktop as all the PCs run Windows XP which supports this technology. Desktop locking also helps preventing users from disabling the application (you wouldn’t how users stick to their favourite background images! :)

We’ve finished the application on time, it had been successfully deployed on many PCs, and was working really fine!

…well, in most cases. It turned out that there is also a notebook which is running Vista (guess who? You’re right, the CEO himself! :) , and some others where Active Desktop freezes for unknown reasons. As the Active Desktop technology is now discontinued we couldn’t find solution for these cases. Sidebars and widgets are not alternatives in this case, as they don’t support locking the settings.

How?

Long story short: we’ve chosen Adobe AIR as an alternative. To simulate Active Desktop on any computer we did the following:

- set up options: we wanted a chromeless window without the taskbar icon

var options          = new air.NativeWindowInitOptions();
options.systemChrome = air.NativeWindowSystemChrome.NONE;
options.type         = air.NativeWindowType.LIGHTWEIGHT;
// lightweight: so it wont show up in the taskbar

- create the application window leaving space for three columns of icons on the left (about 230px wide), and fill the rest of the desktop on the right:

// handle multi-monitor setups gracefully
function getCurrentScreen(){
  var current;
  var screens = air.Screen.getScreensForRectangle( window.nativeWindow.bounds );
  ( screens.length > 0 ) ? current = screens[0] : current = air.Screen.mainScreen;
  return current;
}

var currentScreen = getCurrentScreen().visibleBounds;
// we take the taskbar size into consideration
var windowBounds = new air.Rectangle(
  currentScreen.y + currentScreen.width - 230, currentScreen.x,
  230, currentScreen.height
);
var htmlLoader = air.HTMLLoader.createRootWindow(true, options, false, windowBounds );
var newWindow  = htmlLoader.window.nativeWindow; //the window we just created

- observe window activation event and send the window behind all the other applications:

newWindow.addEventListener( air.Event.ACTIVATE, function( event ) {
  newWindow.orderToBack(); // if we get focus, send us back
});

newWindow.visible = true;
newWindow.orderToBack();

- and at last launch the application:

htmlLoader.navigateInSystemBrowser = true;
// redirect links to the default browser
htmlLoader.load( new air.URLRequest('app:/mainpage.html') );

This solution looks really fine both under Windows XP and Vista too, even when the Windows + M key combination (minimize all windows) is used.

One more thing

The solution above is working perfectly until you click on the “Show desktop” icon next to the Start button/orb, which hides the application and shows the desktop.

This special icon invokes an internal method (toggleDesktop) of Windows Explorer through an .scf (Shell Command File) script file located under %APPDATA%\Microsoft\Internet Explorer\Quick Launch\Show Desktop.scf. There are no workarounds to this, you cannot change it to minimizeAll, nor you have an option in Adobe AIR to avoid this effect.

However, thanks to the closed enterprise environment we had another option: we’ve simply removed the SCF file and copied a small EXE file in the same directory. The EXE file was created using the faboulous AutoHotKey: this executable simply sends the Windows + M keystrokes thus minimizing all the windows and shows the desktop with our application.

download the minimizeAll.zip file containing the executable

Conclusion

Even though the Active Desktop feature is discontinued we find it absolutely relevant in several cases. Though the solution above is not the 101% perfect one we’re constantly looking for, we feel it does the job quite frankly – fortunately the workaround described only affects a few computers.

We’re still open to other alternatives though it looks that these are the limitations of the technology currently. We don’t expect any Windows versions to change in this manner: maybe the growth of Adobe AIR will lead to a better solution.

Until that happens we take some rest: we’ve already made another client happy – right now.

Bookmark and Share

8 Comments

  1. Jeremy says:

    Excellent article, I have been looking for just this kind of solution. I am currently running flex builder 3, and would like to do what you are talking about. The syntax is clearly compatible but i cannot call ‘air.NativeWindowInitOptions()’ for example. What do i need to build your samples, and/or can i get the full source code including imports?

  2. d-a-m says:

    You should find an airaliases.js file in your SDK which provides several factory shortcuts to reduce typing. Just include it, and you’ll have things go like:

    air.NativeWindowInitOptions = window.runtime.flash.display.NativeWindowInitOptions;

  3. Mconn says:

    It seems you’re still leaving a gap for the icons to the left you said. Is there anyway to get this to fit the full screen, under the desktop icons, like in active desktop?

  4. brian says:

    This is really great but I tried to reproduce it and am still getting the icon of the AIR app appearing in the taskbar. Is there a special way to remove the icon?

  5. brian says:

    To follow up, I was able to figure a way out to reproduce this functionality using Flash Builder 4 — and it also negates the need to use AutoHotKey (which is an awesome app to know about–thanks!!). Here is how it works:

    Create a new AIR app (for which an taskbar icon is required). This app spawns a new application component based on mx:Window with the HTMLLoader in it. I used a separate component for this so it could function independently from the main app. Child apps in AIR do *not* require an icon so you can set the type=NativeWindowType.LIGHTWEIGHT on this new component when you open it. As soon as this new window opens it dispatches a complete event. The main app listens for the complete event and then closes itself — taking the taskbar icon with it. Since (I believe) in Windows 7 the shortcut “Windows/M” works from the items in the task bar, the fact that the child app is not in the task bar prevents it from being minimized by the shortcut.

    By the way, this seems to work only on Windows — not Mac — so a different solution would be required for that.

    Thanks for the starting point on on this solution!

  6. enko says:

    Excellent solution ! .
    but one thing … I am trying to create a menu in our LIGHTWEIGHT widow’
    but no success

  7. sreekumar says:

    Thanx Brain!!!
    You are the man!!!
    you saved my time…

  8. michael dearing says:

    I am trying to run the script but am getting an error “Air is undefined” line 1 character 1 can someone help me please? Also i am giving the file a .js extension is this correct?

Leave a Reply