Hello There, Guest! (LoginRegister)

Skinning Documentation

Introduction to Scripting
Getting Started
What's a Messenger Plus! Script?
Scripting Environment
Your First Script
Working with Scripts
From Plugins to Scripts
Packaging your Script
Windows for your Script
Testing your Windows
Objects Reference
Debug Object
Description
Functions
Trace
ClearDebuggingWindow
Properties
DebuggingWindowVisible
Messenger Object
Description
Functions
AutoSignin
Signout
OpenChat
Properties
Version
VersionBuild
ContactListWndHandle
CurrentChats
ReceiveFileDir
MyContacts
MyEmail
MyUserId
MyStatus
MyName
MyPersonalMessage
MyCurrentMedia
MyDisplayPicture
CustomEmoticons
MsgPlus Object
Description
Functions
DisplayToast
DisplayToastContact
CreateWnd
CreateChildWnd
AddTimer
CancelTimer
PlaySound
LockMessenger
LogEvent
RemoveFormatCodes
DownloadFile
UploadFileFTP
LoadScriptFile
ExtractFromZIP
Properties
Version
VersionBuild
ScriptRegPath
ScriptFilesPath
MessengerIsLocked
UILangCode
ChatWnds Object
Description
Functions
Iterator
Properties
Count
ChatWnd Object
Description
Functions
SendMessage
SendFile
AddContact
DisplayInfoMessage
ResetInfoMessage
EditText_GetCurSelStart
EditText_GetCurSelEnd
EditText_SetCurSel
EditText_ReplaceSel
HistoryText_GetCurSelStart
HistoryText_GetCurSelEnd
HistoryText_GetTextRange
Properties
Handle
Contacts
EditText
EditChangeAllowed
ChatLogEnabled
OverrideFmtEnabled
IsMobileChat
Contacts Object
Description
Functions
Iterator
GetContact
Properties
Count
Contact Object
Description
Properties
Email
Network
Status
Name
PersonalMessage
CurrentMedia
Blocked
DisplayPicture
IsFloating
Emoticons Object
Description
Functions
Iterator
GetEmoticon
Properties
Count
Emoticon Object
Description
Properties
Shortcut
Name
PictureFile
PlusWnd Object
Description
Functions
Close
RegisterMessageNotification
GetControlHandle
SendControlMessage
GetControlText
SetControlText
GetElementPos
Button and Checkmark Controls
Button_IsChecked
Button_SetCheckState
Button_SetElementText
ComboBox Controls
Combo_AddItem
Combo_RemoveItem
Combo_GetCurSel
Combo_SetCurSel
Combo_GetItemData
Combo_GetCount
ListBox Controls
LstBox_AddItem
LstBox_GetItemText
LstBox_RemoveItem
LstBox_GetCurSel
LstBox_SetCurSel
LstBox_GetItemData
LstBox_GetCount
ListView Controls
LstView_AddItem
LstView_SetItemText
LstView_GetItemText
LstView_RemoveItem
LstView_GetItemData
LstView_GetCount
LstView_GetSelectedState
LstView_SetSelectedState
LstView_GetCheckedState
LstView_SetCheckedState
LstView_SetItemIcon
Edit and RichEdit Controls
EditBox_SetCurSel
EditBox_ReplaceSel
EditBox_GetCurSelStart
EditBox_GetCurSelEnd
RichEdit_GetTextRange
RichEdit_SetCharFormat
Browser Controls
Browser_GetInterface
Image Elements
ImageElmt_SetImageFile
Properties
Handle
Visible
WindowId
Interop Object
Description
Functions
Call
Call2
FreeDll
GetLastError
Allocate
GetCallbackPtr
DataBloc Object
Description
Functions
GetAt
SetAt
ReadString
WriteString
ReadBSTR
WriteBSTR
ReadWORD
WriteWORD
ReadDWORD
WriteDWORD
ReadInterfacePtr
WriteInterfacePtr
Properties
Size
DataPtr
Events Reference
Messenger Events
OnEvent_Signin
OnEvent_SigninReady
OnEvent_Signout
OnEvent_MyStatusChange
OnEvent_MyNameChange
OnEvent_MyPsmChange
OnEvent_MyMediaChange
OnEvent_ContactSignin
OnEvent_ContactSignout
OnEvent_ContactStatusChange
OnEvent_ContactNameChange
OnEvent_ContactPsmChange
OnEvent_ContactMediaChange
OnEvent_ContactBlocked
OnEvent_ContactUnblocked
OnEvent_ContactListWndCreated
OnEvent_ContactListWndDestroyed
OnEvent_ChatWndCreated
OnEvent_ChatWndDestroyed
OnEvent_ChatWndContactAdded
OnEvent_ChatWndContactRemoved
OnEvent_ChatWndReceiveMessage
OnEvent_ChatWndSendMessage
OnEvent_ChatWndEditKeydown
Messenger Plus! Events
OnEvent_Initialize
OnEvent_Uninitialize
OnEvent_MessengerLocked
OnEvent_MessengerUnlocked
OnEvent_Timer
OnEvent_MenuClicked
OnEvent_EnterPersonalizedStatus
OnEvent_LeavePersonalizedStatus
OnEvent_DownloadFileComplete
OnEvent_UploadFileComplete
OnGetScriptMenu
OnGetScriptCommands
Events Templates
ScriptsCommandTemplate
ToastCallbackTemplate
Interface Windows Events
OnWindowidEvent_Cancel
OnWindowidEvent_Destroyed
OnWindowidEvent_MessageNotification
OnWindowidEvent_CtrlClicked
OnWindowidEvent_ComboSelChanged
OnWindowidEvent_EditTextChanged
OnWindowidEvent_LstBoxSelChanged
OnWindowidEvent_LstBoxDblClicked
OnWindowidEvent_LstViewClicked
OnWindowidEvent_LstViewRClicked
OnWindowidEvent_LstViewDblClicked
OnWindowidEvent_LstViewSelStateChanged
XML Schemas Reference
ScriptInfo File
Information
Examples
Schema Documentation
Interface Windows
Information
Examples
Schema Documentation

Interop::Call

The Interop::Call function allows scripts to call functions located in external libraries. For example, it can be used to call functions from the Windows API.

Syntax

[number] Call(
    [string] DllName,
    [string] FunctionName,
    [var, optional] Param1,
    [var, optional] Param2,
    [var, optional] Param3,
    [var, optional] Param4,
    [var, optional] Param5,
    [var, optional] Param6,
    [var, optional] Param7,
    [var, optional] Param8,
    [var, optional] Param9,
    [var, optional] Param10,
    [var, optional] Param11,
    [var, optional] Param12
);

Parameters

DllName
[string] Path to the DLL file where the function to call is located. If multiple calls are made to the same DLL, the DLL is loaded only once and stays in memory until FreeDll is called or the script is terminated. The DLL file will be located by using the standard "LoadLibrary" mechanism described here. As no "current directory" is guaranteed for your script, you'll need to use MsgPlus.ScriptFilesPath to load a library from your script's directory.
FunctionName
[string] Name of the function as specified in the export table of the library. The function must use the __stdcall calling convention. See Remarks.
Param1
[var, optional] First parameter to send to the function, if any.
Here is how the data will be sent to the function depending on its type:
  • If the parameter is a plain number (positive or negative), it is sent as is.

  • If the parameter is a floating point number, it is rounded up and sent as a plain number.

  • If the parameter is a boolean, a number is sent: 1 for true, 0 for false.

  • If the parameter is null, 0 is sent.

  • If the parameter is a string, a pointer to a Unicode string is sent.

  • If the parameter is a DataBloc object, a pointer to its underlying data is sent.

  • If the parameter is any other object, a pointer to its IDispatch interface is sent. The reference count of the object is not increased.

Param2
[var, optional] Second parameter to send to the function, if any. See Param1.
Param3
[var, optional] Third parameter to send to the function, if any. See Param1.
Param4
[var, optional] Fourth parameter to send to the function, if any. See Param1.
Param5
[var, optional] Fifth parameter to send to the function, if any. See Param1.
Param6
[var, optional] Sixth parameter to send to the function, if any. See Param1.
Param7
[var, optional] Seventh parameter to send to the function, if any. See Param1.
Param8
[var, optional] Eighth parameter to send to the function, if any. See Param1.
Param9
[var, optional] Ninth parameter to send to the function, if any. See Param1.
Param10
[var, optional] Tenth parameter to send to the function, if any. Accepted only in Messenger Plus! Live 4.21 and above. See Param1.
Param11
[var, optional] Eleventh parameter to send to the function, if any. Accepted only in Messenger Plus! Live 4.21 and above. See Param1.
Param12
[var, optional] Twelfth parameter to send to the function, if any. Accepted only in Messenger Plus! Live 4.21 and above. See Param1.

Return Value

A number, returned by the function. The meaning of this number depends on the function called.

This function typically fails for the following reasons:

  • The DLL couldn't be located on the system.
  • The function couldn't be located in the specified DLL.
  • An exception was thrown during the function call.

Messenger Plus! Live 4.10 and above: an error is logged in the Script Debugging window when an exception is thrown during the call (often caused by incorrect parameters).

Remarks

Developers who use this function must be very careful about the functions they call and the parameters they accept. Here is a list of requirements for this function to succeed:

  • The function called must use the __stdcall calling convention, also referred as WINAPI in some places.
  • The function must return something (it can't be "void") even if the value has no particular meaning.
  • The function must not take more than 12 parameters in Messenger Plus! Live 4.21+ and 9 parameters in older versions.
  • The function must accept Unicode string (although ANSI string may be sent with a DataBloc).

Most functions from the Windows API use the __stdcall convention, although you have to be careful to always use the "wide" version of each function. This means for example that to display a message box, you need to call "MessageBoxW". Calling a function with incorrect parameters will corrupt the Messenger memory space and eventually crash the program.

Messenger Plus! Live 4.10 and above: Messenger Plus! tries to detect bad calling conventions (when __stdcall was not used to declare the function that's being called) and logs the corresponding error in the Script Debugging window. Do NOT ignore these errors, they will cause instabilities and eventually crash Messenger in random places.

Example

This code displays a "Hello!" message box.

Interop.Call("User32.dll", "MessageBoxW", 0, "Hello!", "Example Message", 0);

Function Information

Object Interop
Availability Messenger Plus! Live 4.00

See Also

Interop Object, DataBloc Object, Call2.