Shoutbox

Detecting 'receive msg when minimised' & running a batch - 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: Detecting 'receive msg when minimised' & running a batch (/showthread.php?tid=75006)

Detecting 'receive msg when minimised' & running a batch by Dauntless on 06-03-2007 at 09:28 AM

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


RE: Detecting 'receive msg when minimised' & running a batch by Volv on 06-03-2007 at 10:02 AM

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);
    }
}

RE: Detecting 'receive msg when minimised' & running a batch by Dauntless on 06-03-2007 at 10:06 AM

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


RE: Detecting 'receive msg when minimised' & running a batch by Dauntless on 06-03-2007 at 10:44 AM

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!
RE: Detecting 'receive msg when minimised' & running a batch by TheSteve on 06-03-2007 at 01:03 PM

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


RE: Detecting 'receive msg when minimised' & running a batch by Dauntless on 06-03-2007 at 01:16 PM

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


RE: Detecting 'receive msg when minimised' & running a batch by CookieRevised on 06-03-2007 at 01:43 PM

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.

;)
RE: Detecting 'receive msg when minimised' & running a batch by Dauntless on 06-03-2007 at 01:46 PM

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.


RE: Detecting 'receive msg when minimised' & running a batch by Volv on 06-03-2007 at 02:16 PM

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.
RE: Detecting 'receive msg when minimised' & running a batch by Dauntless on 06-03-2007 at 02:20 PM

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! :)


RE: Detecting 'receive msg when minimised' & running a batch by Volv on 06-03-2007 at 02:22 PM

Optional parameters usually say "Optional" somewhere :p (I believe they also have their parameters in square brackets: [Param1])