Yeah, multiple timers will work, didn't thought of that...
Bit 'messy', but it will work.
You don't need to repeat the timers though.
EDIT:
Something I quickly cooked up:
jscript code:
function OnEvent_ChatWndSendMessage(pChatWnd, sMessage) {
if (sMessage === '/shake') {
ShakeWindow(pChatWnd.Handle);
return '';
}
}
// global variables
var arrShakeWindow = {}; // array, will hold original window positions
// global constants
var g_nSquare = 4; // movement factor in pixels (-? to +? of original position)
var g_nCount = 40; // amount of moves
var g_nDelay = 40; // delay between moves in milliseconds
function ShakeWindow(hWnd) {
var lpRect = Interop.Allocate(16);
Interop.Call('User32.dll', 'GetWindowRect', hWnd, lpRect.DataPtr);
var x = lpRect.ReadDWord(0);
var y = lpRect.ReadDWord(4);
arrShakeWindow[hWnd] = {x:x, y:y, w:lpRect.ReadDWord(8) - x, h:lpRect.ReadDWord(12) - y};
for (var i = 0; i < g_nCount; i++) {
MsgPlus.AddTimer('shakeit' + (i<10?'0':'')+i + hWnd, 100 + i*g_nDelay)
}
MsgPlus.AddTimer('shakedone' + hWnd, 100 + i*g_nDelay)
}
function OnEvent_Timer(sTimerId) {
var hWnd = sTimerId.substr(9)*1;
var x = arrShakeWindow[hWnd].x;
var y = arrShakeWindow[hWnd].y;
var w = arrShakeWindow[hWnd].w;
var h = arrShakeWindow[hWnd].h;
if (sTimerId.substring(0, 7) === 'shakeit') {
// move window a random amount between +g_nSquare and -g_nSquare pixels
x += Math.floor((2 * g_nSquare + 1) * Math.random() - g_nSquare);
y += Math.floor((2 * g_nSquare + 1) * Math.random() - g_nSquare);
} else {
// last call, thus also remove array element
delete arrShakeWindow[hWnd];
}
Interop.Call('User32.dll', 'MoveWindow', hWnd, x, y, w, h, true);
}
EDIT: that
arrShakeWindow global array should/can be removed from the global scope by applying the different array elements in the timer's name. But I cba to change it for this proof-of-concept
The other global variables/constants are just there for convenience to easy experiment with different values (thought the current ones are very close to the real thing I think). In a final code I would simply replace them with the hard coded values.