Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Api Messenger o algo parecido (https://www.clubdelphi.com/foros/showthread.php?t=69904)

ColdFusion 16-09-2010 22:26:46

Api Messenger o algo parecido
 
hola a todos veran..
me encontre por ahi la manera de mostrar lo que esuchas en el MSN, tengo el codigo..

pero me puse a pensar si se puede mostrar lo que esucho habra alguna manera en la que pueda cambiar el mensaje personal con el mismo codigo..

este es el codigo:
Código:

unit msnNowPlaying;

interface

uses
 windows;

const
  WM_NCPAINT                            =          $0085;
  WM_SYSCOMMAND                          =          $0112;
  WM_USER                                =          $0400;
  WM_CLOSE                              =          $0010;
  WM_DROPFILES                          =          $0233;
  WM_ACTIVATE                            =          $0006;
  WM_COPYDATA                            =          $004A;
  WM_THREADSEARCHDIR_END                =          WM_USER+2;
  WM_USERSHOW                            =          WM_USER+3;
  WM_THREAD_PRIVCHAT_END                =          wm_user+15;
  WM_PRIVCHAT_SHOWTRANVIEW              =          wm_user+19;
  WM_USER_QUIT                          =          WM_USER+43;
  WM_PREVIEW_START                      =          WM_USER+143;
  WM_PRIVATECHAT_EVENT                  =          WM_USER+144;
  WM_THREADSHARE_END                    =          WM_USER+147;
  WM_THREADCHATSERVER_END                =          WM_USER+148;
  WM_THREADCHATCLIENT_END                =          WM_USER+149;
  WM_ERASEBKGND                          =          $0014;

  SC_MYMAXIMIZE = WM_USER+200;
  SC_MYMINIMIZE = WM_USER+201;
  SC_MYCLOSE    = WM_USER+202;
  SC_MYRESTORE  = WM_USER+203;
 
 procedure UpdateMsn(strTitle,strArtist,strAlbum:string; enabled:boolean = true); overload;
 procedure UpdateMsn(strIn:string; radioName:string); overload;
 procedure UpdateMsn(mp3:string); overload;
 function StripMsnIllegalChars(strIn:string):string;

 var
 stringBuffer:array [0..127] of WideChar;

implementation

uses
 sysutils;


procedure UpdateMsn(mp3:string);
begin
    UpdateMsn(mp3,'','');

end;

procedure UpdateMsn(strIn:string; radioName:string);
var
ind:integer;
artist,title:string;
begin


strIn:=StripMsnIllegalChars(strIn);
radioName:=StripMsnIllegalChars(radioName);

 ind:=pos(' - ',strIn);

 if ind>0 then begin
  artist:=Trim(copy(strIn,1,ind-1));
  title:=Trim(copy(strIn,ind+3,length(strIn)));

  if length(title)=0 then begin
  title:=copy(radioName,1,30);
  end;
 
  UpdateMsn(title,artist,'');
 end else begin
  if strIn='' then UpdateMsn(radioName,'','')
    else UpdateMsn(strIn,'','');
 end;
 
end;

function StripMsnIllegalChars(strIn:string):string;
begin
result:=strIn;

while (pos('\0',result)>0) do
 result:=copy(result,1,pos('\0',result)-1) +
        copy(result,pos('\0',result)+2,length(result));

while (pos('http://',lowercase(result))>0) do
 result:=copy(result,1,pos('http://',lowercase(result))-1)+
        copy(result,pos('http://',lowercase(result))+7,length(result));

end;

procedure UpdateMsn(strTitle,strArtist,strAlbum:string; enabled:boolean = true);
var
 handleMSN:THandle;
 structCopy:TCopyDataStruct;

begin

 // Flush the array.
 FillChar(stringBuffer,SizeOf(stringBuffer),#0);

 strTitle:=Trim(copy(strTitle,1,90));
  strArtist:=Trim(copy(strArtist,1,90));
  stralbum:=Trim(copy(strAlbum,1,90));
 // The first Music can be changed to Games, Office, or Empty.
  if ((length(strTitle)>0) and (length(strArtist)>0) and (length(strAlbum)>0)) then
  StringToWideChar('\0Empty\0'+inttostr(integer(enabled))+'\0'+'{1} - {2} - {0}'+'\0'+strTitle+'\0'+strArtist+'\0'+strAlbum+'\0'+'WMContentID'+#0,@stringBuffer[0],128)
  else
 if ((length(strTitle)>0) and (length(strArtist)>0)) then begin
  StringToWideChar('\0Games\0'+inttostr(integer(enabled))+'\0'+'{1} - {0}'+'\0'+strTitle+'\0'+strArtist+'\0'+'WMContentID'+#0,@stringBuffer[0],128);
 end else begin
    if length(strTitle)>0 then begin
      StringToWideChar('\0Games\0'+inttostr(integer(enabled))+'\0'+'{0} {1}'+'\0'+strTitle+'\0\0WMContentID'+#0,@stringBuffer[0],128);
    end else
    if length(strArtist)>0 then begin
      StringToWideChar('\0Games\0'+inttostr(integer(enabled))+'\0'+'{1} {0}'+'\0\0'+strArtist+'\0WMContentID'+#0,@stringBuffer[0],128);
    end else begin
      if enabled then exit;
      StringToWideChar('\0Games\0'+inttostr(integer(enabled))+'\0'+'{1} {0}'+'\0\0\0WMContentID'+#0,@stringBuffer[0],128);
    end;
  end;

 // Set up the structure to hold the WM_COPYDATA and set the values.
 FillChar(structCopy,SizeOf(TCopyDataStruct),#0);
 with structCopy do
 begin
  cbData:=SizeOf(stringBuffer);
  dwData:=$547;
  lpData:=@stringBuffer[0];
 end;

 // Iterate through (for poloygamy) the MSN windows sending WM_COPYDATA to each
 handleMSN:=FindWindowEx(0,0,'MsnMsgrUIManager',nil);
 while handleMSN <> 0 do
 begin
  SendMessage(handleMSN,WM_COPYDATA,0,Integer(@structCopy));

  handleMSN:=FindWindowEx(0,handleMSN,'MsnMsgrUIManager',nil);
 end;
end;

end.

gracias!!


La franja horaria es GMT +2. Ahora son las 23:42:23.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi