Code archives/Miscellaneous/MSN Messenger Music/Game Hint API
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
Simply supply the text you want to be set, and then any optional icon preference. This will default to the music icon, but you can specify a game icon (if you wanted to show that the user was playing your game) or an MS Office logo icon, using the following constants:Const MSNICON_MUSIC:Int = 0 'Text will become a song link. Const MSNICON_OFFICE:Int = 1 Const MSNICON_GAMES:Int = 2 On platforms other than Windows, this function will just return False. Also, if Messenger isn't running the function should also return False. Finally, the user will have to have 'Show What I'm Listening To' checked in their MSN preferences for the text to show. | |||||
SuperStrict
'Save this as a BMX file and import it into your source code.
'e.g. SetMessengerInfo("My Song Name - My Artist")
Public
Const MSNICON_MUSIC:Int = 0 'Text will become a song link.
Const MSNICON_OFFICE:Int = 1
Const MSNICON_GAMES:Int = 2
Function SetMessengerInfo:Int( pText$, pType:Int = MSNICON_MUSIC )
?Win32
Local tmpTypeString:String = "Music"
Local tmpEnable:String = "1"
If Not pText Then tmpEnable = "0"
Select pType
Case MSNICON_MUSIC';tmpTypeString = "Music"
Case MSNICON_OFFICE;tmpTypeString = "Office"
Case MSNICON_GAMES;tmpTypeString = "Games"
EndSelect
Local tmpString$ = "\0" + tmpTypeString + "\0"+tmpEnable+"\0{0}\0"+pText+"\0\0\0"
Local msnmsgstruct:Short Ptr = tmpString.ToWString()
Local msnuihwnd:Int = FindWindowW("MsnMsgrUIManager", Null)
If Not msnuihwnd Then Return False
Local tmpCopyDataStruct:COPYDATASTRUCT = New COPYDATASTRUCT
tmpCopyDataStruct.dwData = $547
tmpCopyDataStruct.cbData = (tmpString.length+1)*2
tmpCopyDataStruct.lpData = Int Ptr(msnmsgstruct)
Local tmpResult:Int = SendMessageW( msnuihwnd, WM_COPYDATA, Null, Int Byte Ptr tmpCopyDataStruct )
MemFree msnmsgstruct
Return tmpResult
?
EndFunction
Private
Extern "win32"
Function FindWindowW:Int( lpClassName$w, lpWindowName$w )
Function SendMessageW:Int( hWnd:Int, MSG:Int, wParam:Int, lParam:Int )
EndExtern
Type COPYDATASTRUCT
Field dwData:Int
Field cbData:Int
Field lpData:Byte Ptr
EndType
Const WM_COPYDATA:Int = $004A
Public |
Comments
| ||
Global str:String = ""
Global EndProg:Int = 0
Global slen:Int = 8
Global icon:Int = 0
Global incr:Int = 1
Global speed:Int = 4000
CreateThread(Inp, Null)
While EndProg = 0
If str
SetMessengerInfo(str[0..slen], icon)
For local i:Int = 1 to incr
Local c:String = Chr(str[0])
str = str[1..str.length]
str:+c
Next
Delay(speed)
EndIf
Wend
SetMessengerInfo("", 0)
Function Inp:Object(entry:Object)
While Not EndProg
Local i:String = Input(">")
If i.ToLower() = "end" or i.ToLower() = "quit"
EndProg = 1
ElseIf i.Split(" ")[0] = "setlen"
slen = Int(i.Split(" ")[1])
ElseIf i.Split(" ")[0] = "seticon"
icon = Int(i.Split(" ")[1])
ElseIf i.Split(" ")[0] = "setincr"
incr = Int(i.Split(" ")[1])
ElseIf i.Split(" ")[0] = "setspeed"
speed = Int(i.Split(" ")[1])
Else
str = i
EndIf
Wend
EndFunction
Awesome |
| ||
| Thats very cool! |
Code Archives Forum