Shoutbox

Script for webcam? - 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: Script for webcam? (/showthread.php?tid=89608)

Script for webcam? by Hen on 03-11-2009 at 09:09 AM

Hi,
In the scripting manual I didnt find "camera" in the search.
Can I operate the web cam from a script?
Will I be able to manipulate the web cam window? - move, resize, add text (headline for example) etc'?
How can I learn how to do that?
Is there any script that I can use as reference to learn from?
Thanks!


RE: Script for webcam? by mynetx on 03-11-2009 at 09:59 AM

Hello Hen,

Messenger Plus! does currently not have access to your or your contact's webcam. Therefore, you cannot control or access it either in scripting.


RE: RE: Script for webcam? by Hen on 03-11-2009 at 03:47 PM

quote:
Originally posted by mynetx


Messenger Plus! does currently not have access to your or your contact's webcam.

Can I do that? :
Write a program in TCL, enable the camera, output will be a nice window.

Call the TCL (or other C++) program from messenger plus, and thus bypassing this limitation?
Thanks!
RE: Script for webcam? by mynetx on 03-11-2009 at 04:28 PM

quote:
Originally posted by Hen
Can I do that? :
Write a program in TCL
I don't know if you can write TCL programs... ;)

quote:
Originally posted by Hen
enable the camera, output will be a nice window
I also don't know if you can access the camera from within TCL.
quote:
Originally posted by Hen
Call the TCL (or other C++) program from messenger plus
You can run any command in Messenger Plus! scripts. Just create a COM object and run your line:
jscript code:
var objShell = new ActiveXObject("WScript.Shell");
var strCommand = "calc"; // just example, should open the Calculator
var intResult = objShell.Run(strCommand);

You can find more information on the Run command in the MSDN documentation.
RE: Script for webcam? by Hen on 03-12-2009 at 10:39 AM

Thank you for your reply and help.
Hen.


RE: Script for webcam? by timeshifter on 03-16-2009 at 12:11 PM

quote:
Originally posted by mynetx
Hello Hen,

Messenger Plus! does currently not have access to your or your contact's webcam. Therefore, you cannot control or access it either in scripting.

Are there any plans to add this functionality in the near future? I've been thinking about doing something that would require said capability.
RE: Script for webcam? by CookieRevised on 03-17-2009 at 05:21 AM

Note that if you can do something with another program, you most likely can do it with Plus! scripting too as it has very few restrictions and allows you to use not only ActiveX/COM objects but also to use Windows APIs.

If there are some limits in Plus! scripting because you can't access certain objects, then those limitations would probably also apply to any other programming environment. The other way around is true also.

Aka, if you could manage to do want you want in TCL, then you could probably also do it in Plus! scripting.

(the above is not always true though, but in most cases it is and then it is just a question of how; Learning the Plus! scripting language (which is JScript) and its added components)


RE: Script for webcam? by timeshifter on 03-17-2009 at 11:57 AM

I'm just looking for a way to start a video call with a script... doesn't need to do anything aside from that. If WLM has an API that I could latch into with a service program written in C#, then fire that from the script, would that work?

<< complete noob with this scripting stuff... although I'm pretty well versed in JavaScript.


RE: Script for webcam? by Spunky on 03-17-2009 at 12:24 PM

I think you can use the SendMessage API from Windows to launch webcams. I can't remember the correct parameter for webcam  although it is on the forum somewhere if you search


RE: Script for webcam? by Hen on 05-01-2009 at 10:24 AM

Hi,
When I opened the windows visual basic => Tools => reference, I added the Messenger API.
Browsing the "object browser" and then looking under IMessenger2 there is this function:
Messenger.StartVideo (vContact)

Why doesn't it work? :
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
var Contacts = ChatWnd.Contacts;  // Deafult will be current chat window, or do I need to specify this?
var e = new Enumerator(Contacts);
var Contact = e.item();  // Assume a chat window with only one contact, no need to iterate
Debug.Trace(Contact.Email)
if (Message.match("Camera")!=null){
Messenger.StartVideo(Contact)
}
}

Do I need to use "Interop::Call " ? - if so, how?
Also the "Debug.trace" doesnt show the contact email in the debug window.

Cheers,
Hen.


RE: Script for webcam? by Spunky on 05-01-2009 at 10:50 AM

It doesn't work because you need to create the ActiveXObject in JScript rather than setting a reference in VB. Also, the messenger API you are refering to is actually Windows Messenger that ships with Windows XP, not Windows Live Messenger, so it will probably try to start the wrong programs webcam anyway.

Use the SendMessage API as I stated above.

EDIT:

js code:
Interop.Call('user32', 'SendMessageW', ChatWnd.Handle, 0x0111, 40279, 0);
// This code is untested.  Replace 40279 with 40049 for Video Call

Source:
quote:
Originally posted by djdannyp

MENUITEM "Start a Video &Call", 40049, MFT_STRING, MFS_ENABLED
MENUITEM "&Show your webcam", 40279, MFT_STRING, MFS_ENABLED

40049 is for video call
40279 is for webcam

RE: Script for webcam? by Hen on 05-01-2009 at 02:47 PM

Hi,
Ok cool, that works.
Now you have to teach me you how you found it....
I searched the forum after you published it and found some similiar posts, however in none I found any explanations as for the parameters and the reference for it.
I opened the msdn:
http://msdn.microsoft.com/en-us/library/ms644950(VS.85).aspx
and found only SendMessage. Is there a difference with SendMessageW ?
In the MSDN I didnt find the reference to the numbers you wrote.
Could you explain a bit about it?
What is the logic of this function? - it sends a hanle (?) to where? and then what exactly do these numbers represent.

ahh.. and do you know why the Debug.trace didnt work for me?

Sorry for my ignorance.
Cheers,
Hen.


RE: Script for webcam? by matty on 05-01-2009 at 02:52 PM

1) Download ResHack.
2) Open the msglang.dll (I think it is) in C:\Program Files\Windows Live\Messenger
3) View the menus and find the code.


RE: Script for webcam? by Spunky on 05-01-2009 at 05:50 PM

0x0111 means send a command to the window specified by ChatWnd.Handle.

SendMessageW is because JScript is unicode (SendMessageA would be for ANSI)

It's Debug.Trace(); not Debug.trace();

As matty said, the codes to webcams and other menu functions can be found by using ResHack


RE: Script for webcam? by CookieRevised on 05-04-2009 at 03:51 AM

quote:
Originally posted by Hen
Hi,
When I opened the windows visual basic => Tools => reference, I added the Messenger API.
Browsing the "object browser" and then looking under IMessenger2 there is this function:
Messenger.StartVideo (vContact)

Why doesn't it work? :
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
var Contacts = ChatWnd.Contacts;  // Deafult will be current chat window, or do I need to specify this?
var e = new Enumerator(Contacts);
var Contact = e.item();  // Assume a chat window with only one contact, no need to iterate
Debug.Trace(Contact.Email)
if (Message.match("Camera")!=null){
Messenger.StartVideo(Contact)
}
}

Do I need to use "Interop::Call " ? - if so, how?
Also the "Debug.trace" doesnt show the contact email in the debug window.

Cheers,
Hen.
To add to what has been explained already:

If you would program in VB, then yes that is what you need todo; referencing that object. However you are now programming in JScript in Messenger Plus! which is another language and thus works differently. To get the object from Messenger in order to use it functions in JScript in Plus! you need to do what Spunky said in his first reply: first make and call the ActiveXObject.

But, there is a much easier way to do what you want, also shown by Spunky: use the SendMessage API again...

You can do this because the functions to start a webcam exist in Windows Live Messenger as a menu option. You can use the specific command for that menu item (which essentially is a sent number) to "simulate" a mouse click on that specific menu item and thus start the webcam.

This command number is also often known as the cmdid (command ID) and is of course program specific and even window specific (hence you also need to specify the window handle to where that cmdid needs to be send).

So, that parameter you ask for, that magic number can be found out by looking at the menu resources from the Windows Live Messenger program. This can be done with a program like ResHacker, as explained by Matty.

If you read the help on MSDN you see that the second parameter for the SendMessage API needs to be the "Message" (this name has got nothing todo with Instant Messaging!). This Message in this case is WM_COMMAND which has the numerical value 0x0111. As the third parameter you provide the cmdid of the menu item you whish to invoke.

I suggest to read the next page for detailed info:
http://www.msgpluslive.net/skins/resources/tut-How-to-find-CmdIds/


PS: don't try to use just any number. You're dealing with internal window stuff here and you can really screw things up if you don't provide the correct values.