What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Skype & Live Messenger » Change Now Playing From Visual Basic .NET

Change Now Playing From Visual Basic .NET
Author: Message:
andrewdodd13
Senior Member
****

Avatar
Oh so retro

Posts: 870
Reputation: 16
34 / Male / Flag
Joined: Jan 2005
O.P. Change Now Playing From Visual Basic .NET
I've tried this code in VS 2003 and 2005, and VB 2008. It doesn't work in any of them.

Source: http://forums.fanatic.net.nz/lofiversion/index.php/t11311.html

code:
Imports System.Runtime.InteropServices

Module mdlMain
    Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd As Integer, _
        ByVal hWndChild As Integer, ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal Hwnd As Integer, ByVal wMsg As Integer, _
        ByVal wParam As Integer, ByVal lParam As Integer) As Integer

    Private Const WM_COPYDATA As Short = &H4AS

    Private Structure COPYDATASTRUCT
        Dim dwData As Long
        Dim cbData As Long
        Dim lpData As Long
    End Structure

    Public Function VarPtr(ByVal o As Object) As Integer
        Dim GC As System.Runtime.InteropServices.GCHandle = System.Runtime.InteropServices.GCHandle.Alloc(o, System.Runtime.InteropServices.GCHandleType.Pinned)
        Dim ret As Integer = GC.AddrOfPinnedObject.ToInt32

        GC.Free()
        Return ret
    End Function

    Public Sub SetMSNNowPlaying(ByVal sTitle As String, ByVal sArtist As String)
        Dim sOutput As String = "\0Music\01\0" + sTitle + " - " + sArtist + "\0\0\0\0\0" + vbNullChar
        Dim udtData As COPYDATASTRUCT
        Dim iMessengerHWnd As Long = 0

        udtData.dwData = &H547S
        udtData.lpData = VarPtr(sOutput)
        udtData.cbData = Len(sOutput) * 2

        Do
            iMessengerHWnd = FindWindowEx(0, iMessengerHWnd, "MsnMsgrUIManager", vbNullString)
            If iMessengerHWnd > 0 Then
                SendMessage(iMessengerHWnd, WM_COPYDATA, 0, VarPtr(udtData))
            End If
        Loop Until iMessengerHWnd = 0
    End Sub
End Module

Using Debug statements, I can see that the Messenger Window is found, and that the SendMessage function is returning 0 - which I assume means it went okay. But nothing happens to my PSM. Whats up with that?

Also, for further debugging - the sOuput string EXACTLY matches that passed by -dt-'s Now Playing Script, as does the hWnd of the Window. So I would imagine that the cock up is to do with the implementation of VarPtr. Anyone any ideas?
[Image: AndrewsStyle.png]
11-22-2007 02:59 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Change Now Playing From Visual Basic .NET - by andrewdodd13 on 11-22-2007 at 02:59 PM
RE: Change Now Playing From Visual Basic .NET - by SuNcO on 11-23-2007 at 04:12 AM
RE: Change Now Playing From Visual Basic .NET - by ShawnZ on 11-23-2007 at 06:02 AM
RE: Change Now Playing From Visual Basic .NET - by andrewdodd13 on 11-23-2007 at 06:07 PM
RE: Change Now Playing From Visual Basic .NET - by SuNcO on 11-23-2007 at 06:27 PM
RE: Change Now Playing From Visual Basic .NET - by andrewdodd13 on 11-23-2007 at 06:34 PM
RE: Change Now Playing From Visual Basic .NET - by SuNcO on 11-23-2007 at 07:29 PM
RE: RE: Change Now Playing From Visual Basic .NET - by andrewdodd13 on 11-23-2007 at 07:52 PM


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