Shoutbox

[beta] Voicemail 1.0 (released 12/08/2011) - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [beta] Voicemail 1.0 (released 12/08/2011) (/showthread.php?tid=97426)

[beta] Voicemail 1.0 (released 12/08/2011) by whiz on 04-21-2011 at 10:06 PM

Beta version has been released!  Click here to try it out, and let me know any issues you come across.  In particular, please try the nudge shake option, both with and without the broken switch on, and tell me which works and with what version of WLM you are using.



I've been working on a little answer machine-type script that can take messages, grab your attention and tell other contacts when you return.  You just turn Voicemail on, then it takes over conversations as needed.  You can make it contact-specific if you like, as well as letting it automatically turn itself on and off automatically (e.g. when set to away/idle, locking messenger and so on).

[Image: attachment.php?pid=1013242]

Suggestions welcome.  It's nearly ready to go, but I can still add stuff in if you have any other ideas.  :)
RE: [preview] Voicemail 1.0 by CookieRevised on 04-21-2011 at 10:56 PM

looks cool (y)

The only things I see which might be nice to have are:

Maybe change the radio buttons into checkboxes for the "On attention command" so that the user can choose to play only a sound but not display a toast nor alert dialog. Or that he can choose both a toast (which will dissapear by nature) and a dialog ( which is permanent by nature).

Also, a nice and original* addition to the "On attention command" to choose from would be a simulated nudge (move/shake the chat window quickly, while playing the nudge sound.... well, you get the idea).

Ability to choose among the statusses for "enable whilst status is ..." and "disable whilst status is ..." in the form of a checkbox list of all statusses (maybe even incl. 'on the phone', etc, since those are still very valid).

;)

* AFAIK no script has ever done that.


RE: [preview] Voicemail 1.0 by whiz on 04-23-2011 at 12:26 PM

quote:
Originally posted by CookieRevised
Maybe change the radio buttons into checkboxes for the "On attention command" so that the user can choose to play only a sound but not display a toast nor alert dialog. Or that he can choose both a toast (which will dissapear by nature) and a dialog ( which is permanent by nature).
Will do.  :)

quote:
Originally posted by CookieRevised
Also, a nice and original* addition to the "On attention command" to choose from would be a simulated nudge (move/shake the chat window quickly, while playing the nudge sound.... well, you get the idea).
I could play the sound, but how would I shake the window?  I guess maybe moving it a couple of pixels and then setting a timer a few times would do it...  maybe make the taskbar button blink - is that possible with scripting?

quote:
Originally posted by CookieRevised
Ability to choose among the statusses for "enable whilst status is ..." and "disable whilst status is ..." in the form of a checkbox list of all statusses (maybe even incl. 'on the phone', etc, since those are still very valid).
I'll see what I can do...
RE: [preview] Voicemail 1.0 by CookieRevised on 04-23-2011 at 02:16 PM

quote:
Originally posted by whiz
I could play the sound, but how would I shake the window?  I guess maybe moving it a couple of pixels and then setting a timer a few times would do it...
Indeed.

You would need to use a timer in a loop for this. Each iteration of the loop you move the window a bit (one pixels is too small I think though), then wait a bit, and then go to the next iteration, etc. It is the exact same way as Messenger does it.

To realy simulate a nudge and see what it actually does to the window you could record a video of a chatwindow when a nudge is recieved and then play that back slowly (frame by frame) so you can see how much pixels the window moved each time and in what direction. I guess the actual nudge is like 10 to 20 moves actually (and probably random) each with an interval in the order of millisecs. The final move is back to the original position of course.

Ideal would be to call that specific routine inside Messenger itself, but that would require some reverse engeneering I guess.

quote:
Originally posted by whiz
maybe make the taskbar button blink - is that possible with scripting?
yup, very possible. See the Windows API FlashWindow and FlashWindowEx if I'm not mistaken. Though, note that the taskbar button will already flash if the chat window wasn't in focus though (done by Messenger itself upon recieving incomming message).

-------

EDIT: just did a quick'n dirty test for the random placement of the window. Works perfectly so far. But the big problem is that MsgPlus.AddTimer does not allow a time of less than 100ms... and for the simulation you would need something like 10ms... :/
So, another possebility would be to use Windows timers. But you can't do that assyncroniously. So that would mean you 'lock' up all execution of Messenger for as long as the nudge simulation runs (=approx. 1 sec I think).
RE: [preview] Voicemail 1.0 by whiz on 04-23-2011 at 03:49 PM

quote:
Originally posted by CookieRevised
EDIT: just did a quick'n dirty test for the random placement of the window. Works perfectly so far. But the big problem is that MsgPlus.AddTimer does not allow a time of less than 100ms... and for the simulation you would need something like 10ms... :/
So, another possebility would be to use Windows timers. But you can't do that assyncroniously. So that would mean you 'lock' up all execution of Messenger for as long as the nudge simulation runs (=approx. 1 sec I think).
Something I've thought about before with timers - is it possible, for example, to set two timers, one at 100ms and the other at 150ms, and then loop both so that something can be done every 50ms?

And then for this, maybe 10 timers, from 100ms to 190ms, and then repeat all 10 timers 10 times (in order to make it last 1s)?  I'll try it in a moment and see if it works.

Edit: seems to...  :P
RE: [preview] Voicemail 1.0 by CookieRevised on 04-23-2011 at 09:23 PM

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.
:P

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 :p

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.
RE: [preview] Voicemail 1.0 by whiz on 04-24-2011 at 11:39 AM

Hmm...  a bit more complicated than my attempt.  :P  I just tried moving it in 3-pixel jumps every 25ms for 1 second (so it kind of goes round in circles)...

JScript code:
// on attention command, with shake enabled
if (Options.Attention.Shake)
{
    MsgPlus.AddTimer("AttentionShakeWindow:" + ChatWnd.Handle + ":A:1", 100);
    MsgPlus.AddTimer("AttentionShakeWindow:" + ChatWnd.Handle + ":B:1", 125);
    MsgPlus.AddTimer("AttentionShakeWindow:" + ChatWnd.Handle + ":C:1", 150);
    MsgPlus.AddTimer("AttentionShakeWindow:" + ChatWnd.Handle + ":D:1", 175);
}
 
// ---------------------------
 
// timer event
if (TimerId.substr(0, 20) === "AttentionShakeWindow")
{
    var Data = TimerId.substr(21, TimerId.length).split(":"); // [ChatWnd, Pos, Cycle]
    Data[0] = Number(Data[0]);
    Data[2] = Number(Data[2]);
    var Rect = Interop.Allocate(32);
    Interop.Call("user32", "GetWindowRect", Data[0], Rect);
    var Pos = [Rect.ReadDWORD(0), Rect.ReadDWORD(4), Rect.ReadDWORD(8), Rect.ReadDWORD(12)]; // [Left, Top, Width, Height]
    switch (Data[1])
    {
        case "A":
            Pos[0] += 3;
            break;
        case "B":
            Pos[1] += 3;
            break;
        case "C":
            Pos[0] -= 3;
            break;
        case "D":
            Pos[1] -= 3;
            break;
    }
    Interop.Call("user32", "SetWindowPos", Data[0], 0, Pos[0], Pos[1], Pos[2], Pos[3], 0);
    if (Data[2] < 10)
    {
        MsgPlus.AddTimer("AttentionShakeWindow:" + Data[0] + ":" + Data[1] + ":" + (Data[2] + 1), 100);
    }
}

Although that doesn't work, it just causes the window to kind of freeze (the rest of Messenger works fine, just the conversation gets stuck).

I'll give your code a go and see what happens...



Edit: seems a similar problem occurs (this might be due to the skin I'm using, not sure yet):

Before...
[Image: 1tD1Z.png]

After...
[Image: ZBveJ.png]

The window still works, but only in the bottom bit (where it 'moved' to).  So the "Add to contact list" link that's higher up doesn't do anything, but the lower one still works.



Edit (2): applying the code to a Plus! window seems to work without any problems!

And no, skins don't affect it...
[Image: attachment.php?pid=1013300]
RE: [preview] Voicemail 1.0 by CookieRevised on 04-24-2011 at 06:13 PM

Hmmm... my code works without any glitches here though (incl. with skins).

I don't know why it wont work with you. There is no reason why it wouldn't work since it is essentially just a MoveWindow/SetWindowPos call. It might indicate something else is wrong on your system maybe?

Haven't tested your code yet, but personally and at first sight I think I would replace the SetWindowPos API with the MoveWindow API because SetWindowPos (at least like you used it) also activates the window and there might also be other Windows messages it might not send which MoveWindow does (iirc SetWindowsPos is just a subset of what MoveWindow actually does). But this is just a personal pref though.

But what I realy would do is to remove the GetWindowRec API from the timer event function in your code, and move it to the 'start shaking' function. Because getting the size each time is kind of useless in the timer event since it never changes (the same for the position; it doesn't change if you don't rely on the 'moved' position, but instead rely on the original position of the window). And each call to an API takes time too, so...

But all this said, I don't think it would fix the issue you're having though. :/


RE: [preview] Voicemail 1.0 by whiz on 04-25-2011 at 06:55 PM

Found something else out: the amount by which it moves depends on where the window is in relation to the top-left corner of the screen.

Example: when the conversation is in the top-left corner, the inner bit only moves a little.  When the window is moved to the centre of the screen, it moves a lot more.

...so by using x and y as 0, it seems to work (but only shakes the inner window, i.e. not the title bar/border, just the content).

Do you think this might be version-dependant?  I'm using WLM 2011 and Plus! 5 on Windows 7 64-bit.


RE: [preview] Voicemail 1.0 by foaly on 04-25-2011 at 07:52 PM

quote:
Originally posted by whiz
Found something else out: the amount by which it moves depends on where the window is in relation to the top-left corner of the screen.

Example: when the conversation is in the top-left corner, the inner bit only moves a little.  When the window is moved to the centre of the screen, it moves a lot more.

...so by using x and y as 0, it seems to work (but only shakes the inner window, i.e. not the title bar/border, just the content).

Do you think this might be version-dependant?  I'm using WLM 2011 and Plus! 5 on Windows 7 64-bit.
your code gave the same effect on my machine:
WLM 2011 and Plus! 5 on Windows 7 32-bit
haven't tried cookies code

edit:
cookies also gives the same strange behavior...
RE: [preview] Voicemail 1.0 by whiz on 04-28-2011 at 12:54 PM

quote:
Originally posted by foaly
your code gave the same effect on my machine:
WLM 2011 and Plus! 5 on Windows 7 32-bit
haven't tried cookies code
Hmm...  Cookie, what version of WLM/Windows are you using?  Maybe this is an issue with WLM 2011.

Can someone on WLM 2009 test the code and see what happens?
RE: [preview] Voicemail 1.0 by KoenLemmen on 04-29-2011 at 02:20 PM

I do have MSG Plus!
But when I use this script, will it work to people how don't have MSG Plus?

Koen

PS. Maybe my English is bad. But I am from the Netherlands.


RE: [preview] Voicemail 1.0 by whiz on 04-30-2011 at 11:35 AM

quote:
Originally posted by KoenLemmen
I do have MSG Plus!
But when I use this script, will it work to people how don't have MSG Plus?

Koen

PS. Maybe my English is bad. But I am from the Netherlands
The script monitors received messages, so any of your contacts can interact with it, regardless of whether they have Plus! installed or not.
RE: [preview] Voicemail 1.0 by whiz on 05-05-2011 at 01:10 PM

Bump...  Can someone on WLM 2009 please try both mine and Cookie's code?  :P


RE: [preview] Voicemail 1.0 by SmokingCookie on 05-08-2011 at 07:42 AM

Cookie's code works just fine :)
@Whiz: your code moves the chat window downward, off the screen :P


RE: [preview] Voicemail 1.0 by whiz on 05-08-2011 at 01:04 PM

Hmm, strange...  are you using WLM 2009?

I think I'll go with Cookie's code anyway, much better than mine.  :P  If this is an issue with WLM 2011, then we can just set the X and Y values to 0, instead of the original position.  Must be something to do with child windows or something...

Edit: this isn't something to do with Plus! tabbed chats, is it?  (I)


RE: [preview] Voicemail 1.0 by SmokingCookie on 05-08-2011 at 03:23 PM

I've tried your code with only one chat window open and tabs disabled completely. Still, the window goes off-screen. The direction seems random though. The chat window moves off-screen in a direction that is a multiple of 45 degrees.


RE: [preview] Voicemail 1.0 by whiz on 05-08-2011 at 04:07 PM

Does the original position of the window have any effect on the direction it moves (e.g. put it in the top-left corner and it'll move that way)?


RE: [preview] Voicemail 1.0 by SmokingCookie on 05-08-2011 at 05:07 PM

I don't think so. I've tried various sizes and positions, it just keeps disappearing off the screen. It moves to the bottom-right corner of the screen.

Dunno if you're into physics, but it seems like an accelerated motion: it starts off slowly, then goes faster and faster (like 1/2 * a * t^2).


RE: [preview] Voicemail 1.0 by whiz on 06-02-2011 at 02:12 PM

Okay, an update on this:

I've implemented the shake feature with a compatibility mode.  By default, it uses Cookie's code, but if that doesn't work, check the 'Broken' option to set X and Y to 0 (instead of the relative position of the window)...

Any other suggestions for the script?

quote:
Originally posted by SmokingCookie
Dunno if you're into physics, but it seems like an accelerated motion: it starts off slowly, then goes faster and faster (like 1/2 * a * t^2).
Yeah, I do A-level physics so I know what you mean.  :P  Certainly strange behaviour, though...

Here's an example of how the script works in a conversation (I've highlighted events that occur, which otherwise wouldn't be visible from a conversation alone).
Spoiler:
quote:
WhizWeb Community says (20:56)
hi

John says (20:56)
hello

WhizWeb Community says (20:57)
brb

*changes status to away, Voicemail auto-enables*

John says (21:10)
you back yet?

WhizWeb Community says (21:10)
[Voicemail] This is WhizWeb Community's voicemail.  WhizWeb Community is currently away, or otherwise not available at the moment.
To leave a message for later, send !message <message>.
To attract WhizWeb Community's attention, send !attention.
To be alerted when WhizWeb Community returns, send !return.

John says (21:10)
!return

WhizWeb Community says (21:10)
[Voicemail] A notification has been set - you will be notified when voicemail is disabled.  You can clear this notification by sending !return again.

John says (21:12)
still not back?

WhizWeb Community says (21:12)
[Voicemail] This is WhizWeb Community's voicemail.  WhizWeb Community is currently away, or otherwise not available at the moment.
To leave a message for later, send !message <message>.
To attract WhizWeb Community's attention, send !attention.
To be alerted when WhizWeb Community returns, send !return.

John says (21:12)
!message can't hang around, but need to tell you something... will discuss it tomorrow

*message sound plays*

WhizWeb Community says (21:12)
[Voicemail] Your message has been stored successfully.

John says (21:13)
!attention

*displays toast/alert, plays alert sound, shakes window (as per settings)*

WhizWeb Community says (21:14)
[Voicemail] Your request for attention has timed out or was denied - please try again later.

WhizWeb Community says (21:17)
back...

*changes status to online, Voicemail auto-disables*

WhizWeb Community says (21:18)
[Voicemail] Voicemail appears to have been disabled now...

*message reminder toast/sound*

A venture into the Script Menu, shows one unread message, which, when clicked...

[Image: attachment.php?pid=1014456]

[beta] Voicemail 1.0 (released 12/08/2011) by whiz on 08-12-2011 at 06:22 PM

Beta version is attached here, see first post for info.