Change the MSN Now Playing Text with ruby

W

Wu Nan

[Note: parts of this message were removed to make it a legal post.]

Hi,

I just write a ruby program to change the MSN Now Playing Text,
however it's not working, could anybody check it for me that why it's not
working.

I also wrote it in VC, and it works well.


Here is the codes:
First VC:


#include "stdafx.h"
#include "windows.h"
#include <string.h>
#include <iostream>


int main(int argc, char* argv[])
{
HWND msnui = NULL;
COPYDATASTRUCT msndata;
WCHAR * utf16buffer=L"\\0Music\\01\\0{Lalalalalalal}\\0\\0\\0\\0\\0<file://0Music//01//0%7BLalalalalalal%7D//0//0//0//0//0>
";
msndata.dwData = 0x547;
msndata.lpData = (void*)utf16buffer;
msndata.cbData = lstrlenW(utf16buffer)*2+2;
while (msnui = FindWindowEx(NULL, msnui, "MsnMsgrUIManager", NULL))
{
SendMessage(msnui, WM_COPYDATA, (WPARAM)NULL,(LPARAM)&msndata);
}
return 0;
}



---------------------------------------------------------------------------------------------------------------------------------------------------------

Then Ruby:

require 'Win32API'
require 'dl/import'
require 'dl/struct'

module Win32
extend DL::Importable

dlload 'user32'

CopyData = struct ["DWORD dwData","DWORD cbData","PVOID lpData",]

WM_COPYDATA = 0x004a

#extern "BOOL SendMessage(HWND, UINT, WPARAM, LPARAM)"
findWindow=Win32API.new("user32.dll", "FindWindow", ['P','P'], 'N')
Result=findWindow.call("MsnMsgrUIManager",0)


str ="\\0Music\\01\\0{test}\\0\\0\\0\\0\\0<file://0Music//01//0%7Btest%7D//0//0//0//0//0>
"
ostr = "\0" * 256
multiByteToWideChar =Win32API.new
('kernel32','MultiByteToWideChar',['L','L','P','L','P','L'],'L')
multiByteToWideChar.Call(0,0,str,-1,ostr,128)


#t=(ostr.strip + "\0").unpack("S*").pack("U*")

cds = CopyData.malloc
cds.dwData = 0x547
cds.cbData = 256
cds.lpData = ostr

SendMessage=Win32API.new("user32.dll", "SendMessage", ['L','L','L','P'],
'L')
SendMessage.Call(Result, 0x004a, 0, cds.to_ptr)

end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top