How to make a menu and commands? |
Author: |
Message: |
Dr Nick
Junior Member
Firefox > IE
Posts: 59 Reputation: 1
31 / /
Joined: Dec 2008
|
O.P. How to make a menu and commands?
Hi, I have developed a script that rotates my PM, and changes it depending on what my status is.
I wish to develop a menu (in the scripts menu) that will allow me to enable/ disable this script (I have made a variable that will allow me to do this, but I have to be able to change this variable with a menu click [this is only if there is no easier way to disable the script]).
I also want to make a command that will call a function to force the PM to rotate if I wish to make it rotate faster than the normal speed.
How would I do this?
Thanks for your help!
Nick
<?
while(!success) { $try++; }
?>
-----------------
Windows 7 Ultimate (6.1.7000)
Windows Live Messenger 14.0.0206
Messenger Plus! Live 4.81.0.358
|
|
02-11-2009 02:51 AM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: How to make a menu and commands?
Menu functions:
js code: function OnGetScriptMenu(nLocation){
var oMenu = new ScriptMenu();
with (oMenu) {
AddSubMenu('My Menu'));
AddItem('/mycommand1', 'My Command without parameter');
AddItem('/mycommand1 5', 'My command with parameter');
AddSeperator();
AddItem('', 'Disabled item', false);
CloseSubMenu();
}
return oMenu.ExportMenu();
}
function OnEvent_MenuClicked(sMenuId, nLocation, oChatWnd){
OnEvent_ChatWndSendMessage(oChatWnd, sMenuId);
}
Command functions:
js code: function OnGetScriptCommands(){
var oCommand = new Commands();
with (oCommand) {
AddCommand('mycommand1', 'My command without parameter');
AddCommand('mycommand1', 'My command with parameter', 5);
}
return oCommand.ExportCommands();
}
function OnEvent_ChatWndSendMessage(oChatWnd, sMessage) {
if (/^\/([^\s\/]+)\s*([\s\S]*)$/.exec(sMenuId) !== null) {
var _command = RegExp.$1.toLowerCase();
var _param = RegExp.$2;
switch (_command) {
case 'mycommand':
if ( _param !== '' ) {
/*
Do stuff here
*/
} else {
/*
Do stuff here
*/
}
break;
}
}
}
Attachment: script classes.zip (1022 bytes)
This file has been downloaded 78 time(s).
This post was edited on 02-11-2009 at 03:18 PM by matty.
|
|
02-11-2009 01:46 PM |
|
|
Spunky
Former Super Mod
Posts: 3658 Reputation: 61
36 / /
Joined: Aug 2006
|
RE: How to make a menu and commands?
quote: Originally posted by matty
js code:
Shouldn't that be:
js code: function OnGetScriptCommands(){
var oCommand = new Commands();
with (oCommand) {
AddCommand('mycommand1', 'My command without parameter');
AddCommand('mycommand1', 'My command with parameter', 5);
}
return oCommand.ExportCommands();
}
This post was edited on 02-11-2009 at 02:36 PM by Spunky.
<Eljay> "Problems encountered: shit blew up"
|
|
02-11-2009 02:35 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: How to make a menu and commands?
quote: Originally posted by Spunky
quote: Originally posted by matty
js code:
Shouldn't that be:
js code: function OnGetScriptCommands(){
var oCommand = new Commands();
with (oCommand) {
AddCommand('mycommand1', 'My command without parameter');
AddCommand('mycommand1', 'My command with parameter', 5);
}
return oCommand.ExportCommands();
}
Yes you are correct!
|
|
02-11-2009 03:18 PM |
|
|
Dr Nick
Junior Member
Firefox > IE
Posts: 59 Reputation: 1
31 / /
Joined: Dec 2008
|
O.P. RE: How to make a menu and commands?
Thanks, But I have tried this and when I try to start the script after changing it, I am told that I dont have the permissions to run it, or it is defective. Am I doing something wring here?
Thanks
Nick Now it works (I removed a ")" in the menu bit) but i get the following error, and the commands / menu dont work:
Error: Object expected (code: -2146823281)
File: __commands.js. Line: 15.
Function OnGetScriptCommands returned an error. Code: -2147352567 And when I try to send a message
Function called: OnEvent_ChatWndSendMessage
Error: 'sMenuId' is undefined (code: -2146823279)
File: Status Checker.js. Line: 145.
Function OnEvent_ChatWndSendMessage returned an error. Code: -2147352567
<?
while(!success) { $try++; }
?>
-----------------
Windows 7 Ultimate (6.1.7000)
Windows Live Messenger 14.0.0206
Messenger Plus! Live 4.81.0.358
|
|
02-12-2009 06:30 AM |
|
|
djdannyp
Elite Member
Danny <3 Sarah
Posts: 3546 Reputation: 31
38 / /
Joined: Mar 2006
|
RE: How to make a menu and commands?
post your entire code using [code=xml][/code] tags around it so that it get highlighted properly, as matty and Spunky did
|
|
02-12-2009 10:50 AM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: How to make a menu and commands?
Wow I guess I should look at my coding before posting it...
Ok first things first in __commands.js we need to edit a line
js code: (typeof sParameter === 'undefined' ? '' : '<Parameters><'+LoadString('CommandDelay')+'></Parameters>')+
Change to:
js code: >>>(typeof sParameter === 'undefined' ? '' : '<Parameters><'+sParameter+'></Parameters>')+<<<
Glad I found this because the code is used in Screenshot Sender as well! Oopsies!
And these functions needs to be changed:
js code: function OnGetScriptCommands(){
var oCommand = new Commands();
with (oCommand) {
AddCommand('mycommand1', 'My command without parameter');
>>> AddCommand('mycommand1', 'My command with parameter', 'Enter a parameter');<<<
}
return oCommand.ExportCommands();
}
function OnEvent_ChatWndSendMessage(oChatWnd, sMessage) {
>>> if (/^\/([^\s\/]+)\s*([\s\S]*)$/.exec(sMessage) !== null) {<<<
var _command = RegExp.$1.toLowerCase();
var _param = RegExp.$2;
switch (_command) {
case 'mycommand':
if ( _param !== '' ) {
/*
Do stuff here
*/
} else {
/*
Do stuff here
*/
}
break;
}
}
}
This post was edited on 02-12-2009 at 01:58 PM by matty.
|
|
02-12-2009 01:56 PM |
|
|
Dr Nick
Junior Member
Firefox > IE
Posts: 59 Reputation: 1
31 / /
Joined: Dec 2008
|
O.P. RE: How to make a menu and commands?
Better, but i renamed the commands, and edited the menu etc, but nothing works.
The commands show up in the command list, but when i enter them, it says the command was not recognised...
Also, when the button in the menu is clicked, the function is not called...
Here is my code...
The code for the menu and command is down the very bottom
xml code: var originalPSM;
var idleSeconds;
var isIdle;
var isBusy;
var PSMnumber;
var seconds = 60;
function OnEvent_Initialize(MessengerStart)
{
idleSeconds = 0;
isIdle = false;
isBusy = false;
MsgPlus.AddTimer('rotate', seconds * 1000);
}
function OnEvent_Uninitialize(MessengerExit)
{
}
function updateMessage() {
if(PSMnumber==1) {
originalPSM = "Growing old is mandatory, growing up is optional";
PSMnumber=2;
} else {
originalPSM = "There are only two ways to live your life. One is as though nothing is a miracle. The other is as if everything is.";
PSMnumber=1;
}
Messenger.MyPersonalMessage = originalPSM;
}
function OnEvent_MyStatusChange(NewStatus)
{
if( NewStatus == 7 || NewStatus == 6 )
{
Messenger.MyPersonalMessage = "Text/ ring me and I'll be back ASAP! 0hrs:0mins:0secs";
MsgPlus.AddTimer( "incIdle", 1000 );
MsgPlus.AddTimer( "updateDisplay", 6000 );
isIdle = true;
isBusy = false;
} else if(NewStatus == 4) {
Messenger.MyPersonalMessage = "Text me! I'm in a full screen app and mssngr alerts are off! :)";
isBusy = true;
isIdle = false;
idleSeconds = 0;
}
else
{
isIdle = false;
isBusy = false;
idleSeconds = 0;
updateMessage();
MsgPlus.AddTimer('rotate', seconds * 1000);
}
}
function OnEvent_Timer(sTimerId)
{
if( isIdle == false && isBusy == false)
{
updateMessage();
MsgPlus.AddTimer('rotate', seconds * 1000);
return 0;
}
else if( sTimerId == "incIdle" )
{
if(isIdle==true) {
idleSeconds ++;
MsgPlus.AddTimer( "incIdle", 1000 );
}
}
else if( sTimerId == "updateDisplay" )
{
if(isIdle==true) {
var cIdleSeconds = idleSeconds;
var idleHours = 0;
var idleMinutes = 0;
while( cIdleSeconds > 59 )
{
cIdleSeconds -= 60;
idleMinutes ++;
}
while( idleMinutes > 59 )
{
idleMinutes -= 60;
idleHours ++;
}
Messenger.MyPersonalMessage = "Text/ ring me and I'll be back ASAP! "+idleHours+"hrs:"+idleMinutes+"mins:"+cIdleSeconds+"secs";
MsgPlus.AddTimer( "updateDisplay", 6000 );
}
}
}
function OnGetScriptCommands(){
var oCommand = new Commands();
with (oCommand) {
AddCommand('PMrotate', 'Rotate your Personal Message'); }
return oCommand.ExportCommands();
}
function OnEvent_ChatWndSendMessage(oChatWnd, sMessage) {
if (/^\/([^\s\/]+)\s*([\s\S]*)$/.exec(sMessage) !== null) { var _command = RegExp.$1.toLowerCase();
var _param = RegExp.$2;
switch (_command) {
case 'PMrotate':
if ( _param !== '' ) {
updateDisplay();
} else {
updateDisplay();
}
break;
}
}
}
function OnGetScriptMenu(nLocation){
var oMenu = new ScriptMenu();
with (oMenu) {
AddSubMenu('My Menu');
AddItem('/PMrotate', 'Roate your Personal Message');
CloseSubMenu();
AddItem('/PMrotate', 'Roate your Personal Message');
}
return oMenu.ExportMenu();
}
function OnEvent_MenuClicked(sMenuId, nLocation, oChatWnd){
OnEvent_ChatWndSendMessage(oChatWnd, sMenuId);
}
I also have the two files from Matty
<?
while(!success) { $try++; }
?>
-----------------
Windows 7 Ultimate (6.1.7000)
Windows Live Messenger 14.0.0206
Messenger Plus! Live 4.81.0.358
|
|
02-13-2009 06:55 AM |
|
|
Dr Nick
Junior Member
Firefox > IE
Posts: 59 Reputation: 1
31 / /
Joined: Dec 2008
|
O.P. RE: How to make a menu and commands?
I also plan on adding a command such as:
/addPM "This is my PM"
So the Pm's will be stored in an array or something, and you can add to it with a command.
Any ideas on how I could do this?
Thanks for all the help!
Nick
<?
while(!success) { $try++; }
?>
-----------------
Windows 7 Ultimate (6.1.7000)
Windows Live Messenger 14.0.0206
Messenger Plus! Live 4.81.0.358
|
|
02-13-2009 06:58 AM |
|
|
Th3rmal
Veteran Member
Peek-a-boo! I see you!!
Posts: 1226 Reputation: 26
32 / /
Joined: Aug 2005
|
RE: How to make a menu and commands?
quote: Originally posted by Dr Nick
I also plan on adding a command such as:
/addPM "This is my PM"
So the Pm's will be stored in an array or something, and you can add to it with a command.
Any ideas on how I could do this?
Thanks for all the help!
Nick
I dont script, but IIRC the solution to this kind of thing is usually to store it in a text file, then get the script to read it off the text file. Although i could be horribly wrong
You have the intellect comparable to that of a rock. Be proud.
|
|
02-13-2009 07:06 AM |
|
|
Pages: (2):
« First
[ 1 ]
2
»
Last »
|
|