DevMSN+

酷酷的MSN插件,随心所欲MSN

Messenger Plus! Live - Scripting Documentation

Getting Started

Your First Script

Creating a new script is easy, even for a non-developer. All you have to do is go to the Scripts section in the Preferences and click on "Create New". The script's name will be used to create the new directory for the script as well as the first JScript file. Nothing else will be created as nothing else is necessary. So, start by creating a new script called "My First Script", click on "Create New", enter the name of the script and press OK. The file will be created, the new script automatically enabled and the editor window will popup with the following code:

创建一个新的脚本是很容易,即使是一个非开发人员。所有你必须
做的是去的<font color="#808080">剧本< /字体>一节中的偏好
并点击“创建新的” 。该脚本的名字将被用来创造新的
目录中的脚本,以及作为第一JScript的文件。无
否则,将创造作为没有别的是必要的。所以,开始建立
新的讲稿所谓的“我的第一个脚本” ,点击“创建新的” ,输入姓名
该脚本,并按下确定。该文件将可创造,新的脚本
自动启用和编辑器窗口将弹出具有下列
代码:

function OnEvent_Initialize(MessengerStart)
{
}

function OnEvent_Uninitialize(MessengerExit)
{
}

Two empty functions are automatically added to every new script: OnEvent_Initialize and OnEvent_Uninitialize. These functions are event handlers known by Messenger Plus!, they are called in your script automatically when a specific event occurs. Those two are called when your script is started and when it's ended. They both have one parameter, specifying when the script was launched or stopped (you can check the documentation of these events later on for more information).

两个空洞的职能是自动添加到每一个新的脚本:
的<a href="ref-plusevents-initialize.htm"> onevent_initialize < /一>和
的<a href="ref-plusevents-uninitialize.htm"> onevent_uninitialize < /一> 。这些职能是事件处理
众所周知,由Messenger Plus! ,他们是所谓的在您的脚本时自动
具体的事件发生。这两个被称为当您的脚本
开始时,它的结束。他们都有一个参数,指定当
脚本发起或停止(您可以检查这些文件
事件后来就获取更多信息) 。

If the Script Debugging window is not visible, open it now (Plus! menu, check "Show Script Debugging". If you don't have this menu, please read Scripting Environment). Make sure the combo box in the Script Debugging window is set on "My First Script" then, in the editor window, click on "Save All" and "OK" for the confirmation message. Back in the Script Debugging window you'll notice the following entries:

如果脚本调试窗口是不可见,打开它,现在(的<font color="#808080">加! < /字体>
菜单中,选中“显示脚本调试” 。如果您没有这个菜单,请参阅
的<a href="script_environment.htm">脚本环境< /一> ) 。确保组合
方块中,脚本调试窗口中设置“我的第一个脚本” ,那么,
在编辑器窗口中,单击“全部保存”和“确定”为确认邮件。早在上脚本调试
窗口,您会发现下列项目:

Script has been stopped
Script is starting
Script is now loaded and ready
Function called: OnEvent_Initialize

Each time a script file is modified and saved, the script has to be stopped and restarted to apply the changes. Clicking on "Save All" stops the script, saves the files and displays a confirmation message. When the confirmation message is dismissed, the script is restarted, JScript files are loaded and if no major syntax error is detected, the "Script is now loaded and ready" message is displayed in the debugging window. Global variables and function calls are immediately executed during the loading procedure (your new script does not have any).

每一次一个脚本文件是修改和保存,脚本已被停止
并重新启动应用更改。点击“保存所有”站脚本,
保存文件并显示一个确认邮件。当确认
信息是被解雇,脚本是重新启动, JScript文件加载,如果
没有大的语法错误是发现, “脚本现在已载入且准备好”的讯息
是显示在调试窗口。全局变量和函数调用是
立即执行期间,加载程序(您的新脚本没有
任何) 。

The first thing Messenger Plus! does once a script has been loaded is to call the OnEvent_Initialize function, if it exists. When an event is called, it is automatically mentioned in the debugging window. Depending on the kind of event your script is handling, it can be preferable to disable this behavior to avoid getting too many useless traces. To do so, click on the "Debug" menu of the script debugging window and uncheck "Trace Event Calls". The debugging window is the best place for developers to output diagnostic messages to keep track of what's going on in their scripts. Scripts that produce little or no diagnostic text at all are generally harder to debug, that's why you should always remember to send some kind of diagnostic information based on where you are in the script, variables that you are using, etc...

第一件事,Messenger Plus!是否一旦脚本已经加载是呼吁
在<b> onevent_initialize < / b >的功能,如果它存在。当事件是所谓的,这是
自动提到,在调试窗口。根据对种事件
您的脚本是处理,便可以,最好禁用此行为,以避免
收到太多无用的痕迹。这样做
因此,点击“调试”菜单中的脚本调试窗口,并取消勾选“追踪
活动要求“ 。调试窗口,是最好的地方,为开发输出
诊断讯息,以保持轨道是怎么回事,在他们的脚本。脚本
生产很少或没有诊断文本在所有一般较难调试,
这就是为什么你应该永远记住把一些种诊断
信息的基础上您身在何处脚本,变数您所使用的,
等..

Because JScript alone wouldn't be enough to create scripts that interact well with Messenger, the Messenger Plus! Live scripting system comes with over 100 functions and properties as well as nearly 50 events, all specifically designed for your Messenger needs. Functions and properties are organized into two kinds of objects: global objects and instantiated objects.

因为JScript的单是不足够的创建脚本互动
以及与Messenger ,将Messenger Plus! Live脚本系统,拥有超过
100的功能和性能,以及近50的事件,所有专为您的
即时通讯的需要。职能和性质组织成二种
物体:全球的<a href="ref-objects.htm">对象和实例对象< /一> 。

  • Global objects are available instantly from anywhere in your script. Global objects act as name spaces for functions of general interest through out the scripts. An example of such object is Debug which allows to send text to the script debugging window.
  • Instantiated objects are returned by some functions of the API or passed as parameters in events. They refer to a particular instance of an object in Messenger that can exist more than once. An example of such object is ChatWnd which lets you interact with the various chat windows of Messenger.

Let's start with the this famous international example of what a good program should say to its creator when emerging from the cyber-void. Simply replace the empty OnEvent_Initialize function of your new script by this one:

function OnEvent_Initialize(MessengerStart)
{
	Debug.Trace("Hello World!");
}

Click on "Save All", dismiss the confirmation message and take a look as the debugging window. The last entry will say "Hello World!". That's because the OnEvent_Initialize function, which is called when the script starts, now calls the Trace function from the Debug object. If you look as the documentation for Trace, you'll see that it takes a single string parameter which is the text that's sent to the debugging window. You can experiment adding calls to Debug.Trace in OnEvent_Uninitialize, you'll see that they are executed when you click on "Save All", before dismissing the confirmation message (because the script has been stopped which triggered the Uninitialize event).

Of course, a script that just says hi to its developer is not very useful to a

copyright devmsn.com