The window.external.window.center() is a handy function in the AIM Modules API that you can use when all you want to do is center a window without regard for the buddy list. If you want to center a plugin window in a way that accounts for the buddy list, then you will need to write your own function. A solution I actually needed in one of my plugins.
In order to center a window, we need to know what monitor it’s in. Here is a function that returns the monitor for a given window:
function findMonitorForWindow(tWnd) { // loop over all monitors until we find the one where // the top left corner of the target window is in for (var i=0; true; i++) { var m = client.findWindow('_monitor'+i); if (m.exists) { if ( tWnd.x >= m.x && tWnd.x < (m.x + m.width) && tWnd.y >= m.y && tWnd.y < (m.y + m.height) ) return m; } else break; } // default to first monitor return client.findWindow('_monitor0'); }
NOTE: ‘client’ above is the window.external.client object that has been assigned to a global variable.
Now that we can find the monitor for a given window, we can center the window any way we want in this monitor. Here is a function that centers the window over the region not occupied by a docked buddy list.
function BuddyListAwareCenterWindow(tWnd) { // The standard center function: var center = function(o,w,n) { return (o + ((w-n)/2) ); } var tWndMonitor = findMonitorForWindow(tWnd); var blWnd = client.findWindow('_buddylist'); var blWndMonitor = findMonitorForWindow(blWnd); var blWidth = 0, blOffset = 0; // are both windows in the same monitor? if (tWndMonitor.monitorIndex == blWndMonitor.monitorIndex) { // adjust centering width if bl is docked on either left or right if (blWnd.x == 0 || (blWndMonitor.width - blWnd.width) == blWnd.x ) blWidth = blWnd.width; // adjust centering offset if docked on left. if (blWnd.x == 0) blOffset = blWnd.width; } tWnd.move( center(tWndMonitor.x + blOffset, tWndMonitor.width - blWidth, tWnd.width), center(tWndMonitor.y, tWndMonitor.height, tWnd.height) ); }
There are some edge cases like when a window is bigger than the space it’s centered on, but this solution should help you get started.
You can install a plugin by running the .amo file. I typically do “start plugin.amo” from the command line or make file. AIM registers itself as a handler for this file extension. You can install a plugin even while offline.
You should enable the debugging setting in IE for other apps. This helps you attach the JavaScript debugger during development and warns you about unhandled exceptions. With debugging enabled (i.e. not disabled), you can insert “debugger;” statements in your code to trigger the debugger. Go to the Internet Settings control panel and uncheck the highlighted option is to do this.
Create aliases for the window.external.* objects. This makes it easier to use these by assigning them to a variable. I put these at the top of my JavaScript file:
Set the AMO_TRACE_ENABLE environment variable to “true” in order to use the window.external.client.trace(msg) function that sends output to the debugger. I do it via the Environment Variables dialog in the System Properties control panel (Windows+Break key, click on Advanced tab, then “Environment Variables” button.)
If your plugin fails to install for some reason, make sure your plugin.xml file is 

