Shoutbox

Toasts on receivers pc - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Forum: Plug-Ins (/forumdisplay.php?fid=28)
+------ Thread: Toasts on receivers pc (/showthread.php?tid=28874)

Toasts on receivers pc by m0m0 on 07-19-2004 at 10:52 AM

Hi!

I'm trying to write a plugin in VB where i want to display a toast on the receivers pc.

But i dont know how to do this.

I do this in the ParseCommand function:

code:
    ElseIf (StrComp(LCase(sCommand), "/xmsg", vbTextCompare) = 0) Then
        sResult = Chr(nCCNotify) + "showm"
        sResult = sResult & sCommandArg
       
        ParseCommand = True
        Exit Function


And this in the ReceiveNotify function:

code:
If (StrComp(sNotifyCode, "showm", vbTextCompare) = 0) Then
        DisplayToast sText, "myplugin", "", True

        ReceiveNotify = True
        Exit Function
    End If


When i send "/xmsg test" the toast appears at my pc AND at the receivers pc and the message "test" appears at BOTH message windows.

The only thing i want is that the toast appears at the receivers pc, NOT on my own and there shouldnt be displayed any text in the message window.


Can anyone help me to do this??


thx,
m0m0
RE: Toasts on receivers pc by (CyBeRDuDe) on 07-19-2004 at 12:02 PM

Hehe... I don't think that is supposed to happen... :S:S:S... I don't get that.... hmm... I can't see anything wrong with the code you posted.... I hope someone else will help....


RE: Toasts on receivers pc by matty on 07-19-2004 at 04:16 PM

I was having the same problem with my Remote Shutdown Plugin I was designing, the only work around I had was sending the UserEmail (recieved at Initialization) with the message and compare it to the one on the computer if its the same dont do anything but if its different then display the toast. Whats happening is when you type in the command the plugin on your computer gets the RecieveNotify code to because its in the convo window.

code:
Public Function Initialize(ByVal nVersion As Long, ByVal sUserEmail As String, ByVal oMessenger As Object) As Boolean
    Initialize = True
    strUserEmail = sUserEmail
End Function


code:
sResult = Chr(nCCNotify) + "showm" + "Display Toast " + vbCrLf + "Text: " + sCommandArg + vbCrLf + "Email: " + strUserEmail


code:
Public Function ReceiveNotify(ByVal sNotifyCode As String, ByVal sText As String, ByVal sContactName As String, ByVal oConversationWnd As Object, ByRef sTextToSend As String) As Boolean

    If (StrComp(sNotifyCode, "showm", vbTextCompare) = 0) Then
        Dim sptRecievedText() As String
        strSplit sText, sptRecievedText(), Chr(13)
        sptRecievedText(1) = Replace(sptRecievedText(1), "Text: ", "")
        sptRecievedText(2) = Replace(sptRecievedText(2), "Email: ", "")

       If sptRecievedText(2) = strUserEmail Then
            ReceiveNotify = False
            Exit Function
        Else
            DisplayToast sptRecievedText(2), "myplugin", "", True
            ReceiveNotify = True
            Exit Function
        End If
    End If
    ReceiveNotify = False
End Function

Here is a good Split Function I found on PSC (Put This Into A Module
code:
Public strUserEmail As String

Public Function strSplit(ByVal Sin As String, sOut() As String, Optional sDelim As String, Optional nLimit As Long = -1, Optional bCompare As VbCompareMethod = vbBinaryCompare) As Variant
   Dim sRead As String
   If sDelim = "" Then sDelim = " "
   If InStr(Sin, sDelim) = 0 Then
        ReDim sOut(0) As String
        sOut(0) = Sin
        strSplit = sOut
        Exit Function
   End If
   sRead = ReadUntil(Sin, sDelim, bCompare)
   Do
      ReDim Preserve sOut(nC)
      sOut(nC) = sRead
      nC = nC + 1
      If nLimit <> -1 And nC >= nLimit Then Exit Do
      sRead = ReadUntil(Sin, sDelim)
   Loop While sRead <> "~TWA"
   ReDim Preserve sOut(nC)
   sOut(nC) = Sin
   strSplit = sOut
End Function
Public Function ReadUntil(ByRef Sin As String, sDelim As String, Optional bCompare As VbCompareMethod = vbBinaryCompare) As String
Dim nPos As Long
nPos = InStr(1, Sin, sDelim, bCompare)
If nPos > 0 Then
   ReadUntil = Left(Sin, nPos - 1)
   Sin = Mid(Sin, nPos + Len(sDelim))
Else
   ReadUntil = "~TWA"
End If
End Function

RE: Toasts on receivers pc by Millenium_edition on 07-19-2004 at 04:21 PM

why not use sContactName?


RE: Toasts on receivers pc by matty on 07-19-2004 at 04:28 PM

quote:
Originally posted by Millenium_edition
why not use sContactName?
Because if you use sContactName you have to use the Messenger Api to get your NickName and compare them, because Plus! returns your Email and the Contacts Nickname (kinda uncomparable dont you think?)

And we all know what happens with the Messenger API on XP 8-)
RE: Toasts on receivers pc by Millenium_edition on 07-19-2004 at 06:26 PM

ah yes... but then you can loop through the oConversationWnd.Contacts to find it? and even on XP that will work because plus! fixes that :)


RE: Toasts on receivers pc by matty on 07-19-2004 at 06:41 PM

quote:
Originally posted by Millenium_edition
ah yes... but then you can loop through the oConversationWnd.Contacts to find it? and even on XP that will work because plus! fixes that :)
Take your pick, I didn't know about that for the oConversationWnd object. Learn something new every day.
RE: Toasts on receivers pc by m0m0 on 07-19-2004 at 08:26 PM

i tried the one with the email comparison and it worked ... thx ... but the text (
Display Toast
Text: ***
Email: ***
) still appears in the message window at both pcs ... how can i avoid that?

thx


RE: Toasts on receivers pc by Millenium_edition on 07-19-2004 at 08:39 PM

code:
sResult= ""
?
RE: Toasts on receivers pc by m0m0 on 07-19-2004 at 08:46 PM

and where shall i put that in?


RE: Toasts on receivers pc by Millenium_edition on 07-19-2004 at 08:59 PM

in ReceiveNotify


RE: Toasts on receivers pc by m0m0 on 07-19-2004 at 09:09 PM

There is no variable called sResult in ReceiveNotify and if i set the one in ParseCommand to "" the request wouldnt even be sent....


RE: Toasts on receivers pc by Millenium_edition on 07-19-2004 at 09:12 PM

have you tried sTextToSend... it might work?


RE: Toasts on receivers pc by m0m0 on 07-19-2004 at 09:17 PM

the documentation says this:

'//   * sTextToSend: this parameter is optional. You can use it if   //
'//     you want to ask Messenger Plus! to send a new message after  //
'//     this one has been displayed. This WON'T modify the message   //
'//     associated with the notify code, this will simply send a new //
'//     one.   


RE: Toasts on receivers pc by Millenium_edition on 07-19-2004 at 09:21 PM

=/ then there is no way i guess.


RE: Toasts on receivers pc by m0m0 on 07-19-2004 at 09:44 PM

i cant imagine that it isnt possible to do that ... i hope someone can help me


RE: Toasts on receivers pc by matty on 07-19-2004 at 10:35 PM

The way I did it, the Email and Text have to show, there is no way around it, unless you can use M_E's way for the oConversationWnd.Contacts


RE: Toasts on receivers pc by TazDevil on 06-01-2005 at 05:40 PM

i have a q on this subject...

1. if i send a message throught code with (sNotifyCode) to a friend in order to display a toast on his pc, will it open a convo window if there is not one already open...

2. if it doesnot open a new window (no window opens on his behalf, will the RecieveNotify handle the message ?

thank you
(sorry for poping an old thread !!)


RE: Toasts on receivers pc by Mike on 06-01-2005 at 05:55 PM

quote:
Originally posted by TazDevil
1. if i send a message throught code with (sNotifyCode) to a friend in order to display a toast on his pc, will it open a convo window if there is not one already open...
The window will open since you are actually sending a message with some special code so MsgPlus! can know that this is some plugin code before the actual message that isnt visible to the user.
So, a convo window has to open.

quote:
Originally posted by TazDevil
2. if it doesnot open a new window (no window opens on his behalf, will the RecieveNotify handle the message ?
Since a window will have to open, the RecieveNotify will handle the message.

Ofcourse, I could be wrong about the above things...
I'm not the best plugin coder... :P

Offtopic: We are from the same country :)

RE: Toasts on receivers pc by TazDevil on 06-01-2005 at 06:04 PM

well is there any other way to communicate (send the toast) with a contact without opening a convo window

???

(thanks for the quicky :p)