What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Plug-Ins » VB Help With /Commands

Pages: (2): « First [ 1 ] 2 » Last »
VB Help With /Commands
Author: Message:
f3nd3r
Junior Member
**


Posts: 20
Reputation: 1
Joined: Jun 2002
O.P. Huh?  VB Help With /Commands
Hey,

How can I make something happen on a particular Command Argument?  Have a look at my code below. It may help you see what i'm trying to do. It doesnt work though.

Any help is much appreciated



code:
Public Function ParseCommand(ByVal sCommand As String, ByVal sCommandArg As String, ByVal oConversationWnd As Object, ByRef sResult As String) As Boolean
      If (StrComp(LCase(sCommand), "/xtest", vbTextCompare) = 0) & sCommandArg = "%test" Then
       
        MsgBox "Test"
       
        ParseCommand = True
        Exit Function
End Function

11-05-2003 06:22 PM
Profile PM Web Find Quote Report
Jutx
Junior Member
**

Avatar
Shocking.......

Posts: 98
– / Male / –
Joined: May 2003
RE: VB Help With /Commands
I would use a nested if statement
the code below would display a message box if the user types /xtest hello

code:
Public Function ParseCommand(ByVal sCommand As String, ByVal sCommandArg As String, ByVal oConversationWnd As Object, ByRef sResult As String) As Boolean
      If (StrComp(LCase(sCommand), "/xtest", vbTextCompare) = 0) Then

If sCommandArg = "hello" then
       
        MsgBox "This Msgbox will be activated if user sends /xtest hello"
       
End if

        ParseCommand = True
        Exit Function
End Function
Hard work pays off in the long run but laziness pays off NOW (H) :banana:
11-05-2003 06:33 PM
Profile PM Find Quote Report
f3nd3r
Junior Member
**


Posts: 20
Reputation: 1
Joined: Jun 2002
O.P. RE: VB Help With /Commands
Thats sweet dude. Thanks very much. That method didnt occur to me, yet its so obvious now I think about it.

Ok now my next problem is how do i get the sResult to display written text aswell as something a command has triggered...Look at the source below.

code:
Public Function ParseCommand(ByVal sCommand As String, ByVal sCommandArg As String, ByVal oConversationWnd As Object, ByRef sResult As String) As Boolean
      If (StrComp(LCase(sCommand), "/xtest", vbTextCompare) = 0) Then

If sCommandArg = "%hello" then
       
        sResult = "Hello"
       
End if
End if

        ParseCommand = True
        Exit Function
End Function


if someone types /xtest this is me saying %hello

How do i get sResult to display "this is me saying hello" ?
11-05-2003 07:31 PM
Profile PM Web Find Quote Report
Jutx
Junior Member
**

Avatar
Shocking.......

Posts: 98
– / Male / –
Joined: May 2003
RE: VB Help With /Commands
I think i get what you mean you want sResult to display what the command argument said but with text added to it. Correct me if i am wrong.

code:
Public Function ParseCommand(ByVal sCommand As String, ByVal sCommandArg As String, ByVal oConversationWnd As Object, ByRef sResult As String) As Boolean
      If (StrComp(LCase(sCommand), "/xtest", vbTextCompare) = 0) Then

If sCommandArg = "%hello" then
       
        sResult = "You just said to this plug-in: " & Replace(sCommandArg,"%","")

       
End if
End if

        ParseCommand = True
        Exit Function
End Function

The Replace bit just gets rid of the percent. If you want it there you could just say:

sResult = "You just said to this plug-in: " & sCommandArg
Hard work pays off in the long run but laziness pays off NOW (H) :banana:
11-05-2003 11:21 PM
Profile PM Find Quote Report
f3nd3r
Junior Member
**


Posts: 20
Reputation: 1
Joined: Jun 2002
O.P. RE: VB Help With /Commands
This is almost what im looking for, but not quite. I think %hello is a bad example. I will eventually be making it to show something like CPU speed...so i want to be able to make something like this
/xtest this is my CPU speed %cpu     but i want it so the user can type anything...for example /xtest hey, my spu speed is %cpu    or /xtest %cpu  ...thats my CPU speed.    So want i want is the %cpu to be able to be replaced anywhere in the message but keeping what the user is saying. I hope this makes sense
11-05-2003 11:40 PM
Profile PM Web Find Quote Report
Jutx
Junior Member
**

Avatar
Shocking.......

Posts: 98
– / Male / –
Joined: May 2003
RE: VB Help With /Commands
Ah i think i understand what you mean so you would want to show CPU speed for example but in the format the user wants. Perhaps a tag is better than this instead of a command so instead of the user typing:

/xtest My Computer zooms at %cpu

The user would write:

My Computer Zooms at (!CPU)


(The code is pretty much the same except it is the ParseTag option that you want.) If you still would prefer it as a command then here is the code format you want.


EDIT: The code has been updated a bit

code:
Public Function ParseCommand(ByVal sCommand As String, ByVal sCommandArg As String, ByVal oConversationWnd As Object, ByRef sResult As String) As Boolean
      If (StrComp(LCase(sCommand), "/xtest", vbTextCompare) = 0) Then

If Instr(Lcase(sCommandArg), "%cpu") <> 0  then
       
Dim CPUSpeed As Long


' Type Code to get CPUSpeed
' then return the number of megahertz the CPU speed is (here the code will always say 1000 coz i don't know how to get CPU Speed)

CPUSpeed = 1000

        sResult = Replace(sCommandArg,"%cpu", CPUSpeed)

       
End if
End if

        ParseCommand = True
        Exit Function
End Function


This post was edited on 11-06-2003 at 04:23 PM by Jutx.
Hard work pays off in the long run but laziness pays off NOW (H) :banana:
11-06-2003 12:07 AM
Profile PM Find Quote Report
f3nd3r
Junior Member
**


Posts: 20
Reputation: 1
Joined: Jun 2002
O.P. RE: VB Help With /Commands
Ok, I chose to use the command code. Heres what I'm faced with now.  When i choose a variable such as:

   sResult = Replace(sCommandArg,"%cpu", CPUSpeed)

it will work if the user does /xtest %cpu   but it wont work if anything else is in the text..such as:

/xtest %cpu ...thats my CPU speed.

However, if it is a string, and not a variable, it will work fine with other text.. for example see below.

   sResult = Replace(sCommandArg,"%cpu", "cpu speed")

With that someone can type '/xtest look at my %cpu'  and it would result in MSN saying "look at my cpu speed"  instead of just returning nothing like the variable does.

So now i am left confused as to why it doesnt allow extra text if it is a variable, but it does if it is a string.

Any ideas?

I really appreciate your help Jutx
11-06-2003 12:44 PM
Profile PM Web Find Quote Report
Jutx
Junior Member
**

Avatar
Shocking.......

Posts: 98
– / Male / –
Joined: May 2003
RE: VB Help With /Commands
Have you actually got code to get the CPU Speed? because the code i posted will not actually work "off the shelf"  for two reasons.

1) I did not declare the variable CPUSpeed
2) I did not put the actual code to get CPU Speed. (I don't know how)

I'll edit the code in my previous post and declare the variable

This post was edited on 11-06-2003 at 04:36 PM by Jutx.
Hard work pays off in the long run but laziness pays off NOW (H) :banana:
11-06-2003 04:19 PM
Profile PM Find Quote Report
f3nd3r
Junior Member
**


Posts: 20
Reputation: 1
Joined: Jun 2002
O.P. RE: VB Help With /Commands
Yea, i do have the CPU code because it works if i do just:
  /xtest %cpu

but if i add anything else to it like:
  /xtest %cpu ...thats my cpu speed

Then nothing happens
11-06-2003 05:11 PM
Profile PM Web Find Quote Report
Jutx
Junior Member
**

Avatar
Shocking.......

Posts: 98
– / Male / –
Joined: May 2003
RE: VB Help With /Commands
I really cannot understand why it won't work then, everything seems to be fine, unless it is capitalisation.

If so just change:

        sResult = Replace(sCommandArg,"%cpu", CPUSpeed)

into

        sResult = Replace(lcase(sCommandArg),"%cpu", CPUSpeed)
Hard work pays off in the long run but laziness pays off NOW (H) :banana:
11-06-2003 05:20 PM
Profile PM Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On