whiz
Senior Member
Posts: 568 Reputation: 8
– / – /
Joined: Nov 2008
|
O.P. Some simple commands...
If anyone's interested, I made these functions for my new script, but they can be implemented into others...
js code: function Remote(User, Command, TimeOut)
// user: contact object of person to send message to
// command: text to follow the initial !command
// timeout: [optional] specify a delay by which the command expires
{
var ChatWnd = Messenger.OpenChat(User.Email); // create a ChatWnd object using the email address of the specified user
try
{
ChatWnd.SendMessage("!command " + Command; // send the command (replace "!command" with your own version)
if (!isNaN(TimeOut)) // if a time limit is specified
{
MsgPlus.AddTimer("MsgTimeOut_" + Command, TimeOut); // create a 1-minute time-out, with the command in the name
}
}
catch (error)
{
Alert("An error has occured whilst sending your request."); // alert the user that an error has occured
}
}
function Wnd(Name)
// name: name of the window, not including the "Wnd"*
{
return MsgPlus.CreateWnd("Windows.xml", "Wnd" + Name, 0); // creates a Messenger Plus! Live script window and returns it (replace "Windows.xml" with your interface file) (*replace "Wnd" + Name with Name if your window names do not start with "Wnd")
}
function Image(Window, Frame, Image)
// window: PlusWnd object where the image element is
// frame: name of the image element in the window
// image: location of the image, inside of the "Images\" folder
{
Window.ImageElmt_SetImageFile(Frame, Image + ".png"); // set the desired image to the image element
}
function Alert(Message, Window)
// message: text to display inside the message box
// window: [optional] PlusWnd or ChatWnd object to link the message box to
{
try
{
Interop.Call("user32", "MessageBoxW", Window.Handle, Message, NAME, 48); // displays a simple alert message box
}
catch (error)
{
Interop.Call("user32", "MessageBoxW", null, Message, NAME, 48); // displays an alert, without a handle
}
}
function Confirm(Message, Window)
// message: text to display inside the message box
// window: [optional] PlusWnd or ChatWnd object to link the message box to
{
try
{
return Interop.Call("user32", "MessageBoxW", Window.Handle, Message, NAME, 4 | 32) === 6; // detects if the result of a comfirm message box is 6 (Ok) and returns a boolean
}
catch (error)
{
return Interop.Call("user32", "MessageBoxW", null, Message, NAME, 4 | 32) === 6; // detects if the comfirm's answer is 6 (Ok) and returns a boolean, without a handle
}
}
function Space(Length)
// length: number of characters that the space should be
{
var X = 0; // start a counter
Space = ""; // create an empty string
while (X < Length) // whilst the counter is less than the length
{
Space += " "; // add a space
X++; // increment the counter
}
return Space; // return the space
}
function Disable(Window, Control, Enabled)
// window: PlusWnd object where the control is
// control: name of the control to enable or disable
// enabled: boolean, true/1 to enable, false/0 to disable
{
Interop.Call("user32", "EnableWindow", Window.GetControlHandle(Control), Enabled); // sets the control to true (enabled) or false (disabled)
}
function TopMost(Window, Control)
// window: PlusWnd object where the control is
// control: name of the checkbox control where the setting is stored
{
Interop.Call("user32", "SetWindowPos", Window.Handle, (Window.Button_IsChecked(Control)) ? - 1: -2, 0, 0, 0, 0, 0x02 | 0x01); // gets the parameter from a checkbox on the window
}
function Close(Window)
// window: PlusWnd object or mode number to assign multiple windows to
{
try
{
Window.Close(1); // attempt to close a specified window
}
catch (error)
{
if (!isNaN(Window)) // if the close failed because a mode was specified instead
{
switch (Window)
{
case 0:
Close(PlusWndObject1); // close the window by calling the function again (replace PlusWndObject1 with a window object variable to close
break;
}
}
}
}
|
|