What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Detecting 'receive msg when minimised' & running a batch

Pages: (2): « First [ 1 ] 2 » Last »
Detecting 'receive msg when minimised' & running a batch
Author: Message:
Dauntless
Junior Member
**


Posts: 16
– / Male / –
Joined: Aug 2006
O.P. Detecting 'receive msg when minimised' & running a batch
Hi,


I have a new notebook (dell XPS M1710) and it has some led's on the side, front and back of the casing. I got the 'crazy' ID to let these lights notify me when someone sends me a message and the window is minimised (or at least 'not focused'). This could be really useful when playing games or when I'm not at my notebook for the moment.

To do this, I would need two things:
- To know if the window has focus or not when OnEvent_ChatWndReceiveMessage is triggered
- To know how to execute a batch file that will trigger the appropriate lights.

Can anyone give me some tips as to how this can be done? I'm not asking for any complete scripts, just for some commands that I can use to build my own script :). All help is welcome!

Greets,
Dauntless
06-03-2007 09:28 AM
Profile E-Mail PM Web Find Quote Report
Volv
Skinning Contest Winner
*****

Avatar

Posts: 1233
Reputation: 31
35 / Male / Flag
Joined: Oct 2004
RE: Detecting 'receive msg when minimised' & running a batch
I think this should work, haven't tested it though:

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind) {
    if(ChatWnd.Handle !== Interop.Call('user32.dll', 'GetActiveWindow')) {
        var objShell = new ActiveXObject("Shell.Application");
        objShell.ShellExecute("C:\\PATH\\TO\\THE\\BAT\\FILE\\ledflash.bat", "", "", "open", 0);
    }
}

This post was edited on 06-03-2007 at 10:06 AM by Volv.
06-03-2007 10:02 AM
Profile PM Find Quote Report
Dauntless
Junior Member
**


Posts: 16
– / Male / –
Joined: Aug 2006
O.P. RE: Detecting 'receive msg when minimised' & running a batch
Thank you for your little script! I'll look into the commands you have used and I'll try to figure out how it works exactly (although it looks quite self-explanatory).

Where can I find the documentation for user32.dll ? (I google'd, but it gave to many different results...)

//EDIT
It doesn't appear to be working, but at least I can try for myself a little while :).

This post was edited on 06-03-2007 at 10:14 AM by Dauntless.
06-03-2007 10:06 AM
Profile E-Mail PM Web Find Quote Report
Dauntless
Junior Member
**


Posts: 16
– / Male / –
Joined: Aug 2006
O.P. RE: Detecting 'receive msg when minimised' & running a batch
I now have this, and it's working:
code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind) {
    if(ChatWnd.Handle != Interop.Call('user32.dll', 'GetActiveWindow')) {
        var objShell = new ActiveXObject("Shell.Application");
        objShell.ShellExecute("C:\\Documents and Settings\\Dauntless\\My Documents\\My Downloads\\xps-led-control-exe\\police.bat", "", "C:\\Documents and Settings\\Dauntless\\My Documents\\My Downloads\\xps-led-control-exe", "open", 1);
    }
}
If someone can point me to the documentation for User32.dll, that would be really helpful!
06-03-2007 10:44 AM
Profile E-Mail PM Web Find Quote Report
TheSteve
Full Member
***

Avatar
The Man from Japan

Posts: 179
Reputation: 23
40 / Male / Flag
Joined: Aug 2005
RE: Detecting 'receive msg when minimised' & running a batch
User32.dll is part of Windows.

The documentation is stored in the MSDN library.

GetActiveWindow()'s documentation is here:
http://msdn2.microsoft.com/en-us/library/ms646292.aspx
06-03-2007 01:03 PM
Profile PM Web Find Quote Report
Dauntless
Junior Member
**


Posts: 16
– / Male / –
Joined: Aug 2006
O.P. RE: Detecting 'receive msg when minimised' & running a batch
Thank you :).

How can I know which functions I can use and which functions I can't use?

I tried this:
code:
Interop.Call("User32.dll", "ChooseColor");
But this gives me an error:
quote:
Interop.Call failed to locate function "ChooseColor"
Error: unknown (code: -2147467259)
       File: Testje.js. Line: 4.
Function OnEvent_Initialize returned an error. Code: -2147352567

06-03-2007 01:16 PM
Profile E-Mail PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Detecting 'receive msg when minimised' & running a batch
ChooseColor isn't a function, it doesn't exist. If you go to the link TheSteve has posted you see a list of functions, which are called Windows API functions (for user32.dll).

PS, for running a file (no matter what kind), you can also use:
code:
new ActiveXObject("WScript.Shell").Run("\"C:\\path to file\\file.bat\"");
which is way shorter than using ShellExecute.

;)

This post was edited on 06-03-2007 at 10:24 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
06-03-2007 01:43 PM
Profile PM Find Quote Report
Dauntless
Junior Member
**


Posts: 16
– / Male / –
Joined: Aug 2006
O.P. RE: Detecting 'receive msg when minimised' & running a batch
Ow, sorry, ChooseColor isn't declared in user32.dll . But 'CreateDialog' IS, (http://msdn2.microsoft.com/en-us/library/ms645434.aspx) and I still get the 'failed to locate function' errror.
06-03-2007 01:46 PM
Profile E-Mail PM Web Find Quote Report
Volv
Skinning Contest Winner
*****

Avatar

Posts: 1233
Reputation: 31
35 / Male / Flag
Joined: Oct 2004
RE: Detecting 'receive msg when minimised' & running a batch
quote:
Originally posted by Dauntless
Ow, sorry, ChooseColor isn't declared in user32.dll . But 'CreateDialog' IS, (http://msdn2.microsoft.com/en-us/library/ms645434.aspx) and I still get the 'failed to locate function' errror.
Umm, you need to fill all necessary parameters as described on the MSDN page for the function (http://msdn2.microsoft.com/en-us/library/ms645434.aspx). This is done by placing extra parameters into the Interop.Call function:
code:
Interop.Call("user32.dll", "FunctionName", "Parameter1", "Parameter2", etc);
That being said, this function probably isn't the best starting place for a beginner as it requires a grasp of somewhat complex concepts. Make sure you understand exactly what the function does and what requirements it has (such as parameters and the parameter types) - all of which is usually contained on the appropriate MSDN page.
06-03-2007 02:16 PM
Profile PM Find Quote Report
Dauntless
Junior Member
**


Posts: 16
– / Male / –
Joined: Aug 2006
O.P. RE: Detecting 'receive msg when minimised' & running a batch
It was just a little test :).

I didn't knew they were required because it didn't say 'required' (I thought it did with other functions...)

But now I know that it is possible, so I'll go look into those functions and play around some more :).

Thank you for your help! :)
06-03-2007 02:20 PM
Profile E-Mail PM Web Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On