Sign in to follow this  
Followers 0
Jex

MSN (WLM) Personal Message Changer

6 posts in this topic

#1 ·  Posted (edited)

If active window in that program list then showing that window title in MSN Personal Message otherwise showing your selected text or clock.

Posted Image

#NoTrayIcon
#include <GuiConstants.au3>
#include <GuiListBox.au3>
#include <File.au3>
#Include <Constants.au3>

Dim $Myini = "List.ini", $Showtext, $Found = False, $Timer, $Sec = 1

HotKeySet("+!t", "Title")

Opt("TrayMenuMode", 1)

$Status = TrayCreateItem("Hide window")
TrayCreateItem("")
$Exit = TrayCreateItem("Exit")

TraySetState()

$Form = GUICreate("FLEXY", 388, 271, 277, 314)
$List = GUICtrlCreateList("", 200, 8, 169, 240)
$Btn_Title = GUICtrlCreateButton("Add current active window title", 16, 16, 171, 25, 0)
$Btn_Add = GUICtrlCreateButton("Add manual title name", 16, 48, 171, 25, 0)
$Btn_Edit = GUICtrlCreateButton("Edit selected title from list", 16, 80, 171, 25, 0)
$Btn_Delete = GUICtrlCreateButton("Remove selected title from list", 16, 112, 171, 25, 0)
$Btn_Save = GUICtrlCreateButton("Save listbox", 16, 144, 171, 25, 0)
$Btn_Hotkeys = GUICtrlCreateButton("Show hotkeys", 16, 176, 83, 25, 0)
$Btn_Exit = GUICtrlCreateButton("Exit", 104, 176, 81, 25, 0)
$Radio1 = GUICtrlCreateRadio("Show clock", 104, 216, 81, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Radio2 = GUICtrlCreateRadio("Show text", 16, 216, 73, 17)
$Radio3 = GUICtrlCreateRadio("Don't show anything", 16, 240, 129, 17)

Load()

GUISetState()
While 1
    $Begin = TimerInit()
    $msg = GUIGetMsg()
    Select
        Case $msg = $Btn_Title
            Title()
        Case $msg = $Btn_Add
            Add()
        Case $msg = $Btn_Edit
            Edit()
        Case $msg = $Btn_Delete
            Delete()
        Case $msg = $Btn_Save
            Save()
        Case $msg = $Btn_Hotkeys
            MsgBox("", "", "Shift + Alt + T = Add current active window title")
        Case $msg = $Radio2
            $Showtext = InputBox(" ", "Text ?", $Showtext)
        Case $msg = $GUI_EVENT_MINIMIZE
            GUISetState(@SW_HIDE)
            TrayItemSetText($Status, "Show window")
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
            $save = MsgBox(36, "", "You wanna save settings?")
            If $save = 6 Then Save()
            Exit
    EndSelect
    $msg = TrayGetMsg()
    Select
        Case $msg = $Status
            If TrayItemGetText($Status) = "Hide window" Then
                GUISetState(@SW_HIDE)
                TrayItemSetText($Status, "Show window")
            ElseIf TrayItemGetText($Status) = "Show window" Then
                GUISetState(@SW_SHOW)
                GUISetState(@SW_RESTORE)
                TrayItemSetText($Status, "Hide window")
            EndIf
        Case $msg = $Exit
            Exit
    EndSelect
    _Timer($Begin,10,"Check")
WEnd

Func _Timer($Var,$Sec,$Func)
    $TimerDiff = TimerDiff($Var)
    $Timer += $TimerDiff / 1000
    If $Timer > $Sec Then
        $Timer = 0
        Call($Func)
    EndIf
EndFunc

Func Title()
    $Item = WinGetTitle("")
    _GUICtrlListBox_AddString($List, $Item)
EndFunc   ;==>Title

Func Add()
    $Item = InputBox(" ", "Title name ?")
    If @error <> 1 And $Item <> "" Then
        _GUICtrlListBox_AddString($List, $Item)
    EndIf
EndFunc   ;==>Add

Func Save()
    $Count = _GUICtrlListBox_GetCount($List)
    FileDelete($Myini)
    For $Items = 0 To $Count - 1
        IniWrite($Myini, "List", $Items, _GUICtrlListBox_GetText($List, $Items))
    Next
EndFunc   ;==>Save

Func Load()
    $Items = _FileCountLines($Myini) - 2
    For $Index = 0 To $Items
        $Initem = IniRead($Myini, "List", $Index, "")
        _GUICtrlListBox_AddString($List, $Initem)
    Next
EndFunc   ;==>Load

Func Edit()
    $Index = _GUICtrlListBox_GetCaretIndex($List)
    $Text = _GUICtrlListBox_GetText($List, $Index)
    $Edit = InputBox(" ", "Edit title name :", $Text)
    If @error <> 1 And $Edit <> "" Then
        _GUICtrlListBox_ReplaceString($List, $Index, $Edit)
    EndIf
EndFunc   ;==>Edit

Func Delete()
    $Index = _GUICtrlListBox_GetCaretIndex($List)
    _GUICtrlListBox_DeleteString($List, $Index)
EndFunc   ;==>Delete

Func Check()
    $Count = _GUICtrlListBox_GetCount($List)
    $Title = WinGetTitle("")
    For $Items = 0 To $Count - 1
        If _GUICtrlListBox_GetText($List, $Items) = $Title Then
            ChangeMSNMessage(1, True, $Title)
            $Found = True
            ExitLoop
        EndIf
    Next
    If $Found = False Then
        If GUICtrlRead($Radio1) = $GUI_CHECKED Then
            ChangeMSNMessage(2, True, @HOUR & ":" & @MIN)
        ElseIf GUICtrlRead($Radio2) = $GUI_CHECKED Then
            ChangeMSNMessage(2, True, $Showtext)
        Else
            ChangeMSNMessage(2, False, "")
        EndIf
    EndIf
    $Found = False
EndFunc   ;==>Check

Func ChangeMSNMessage($iType, $bEnable, $szText)
    Local Const $szFormat = "CoePSX\\0%s\\0%d\\0{0}\\0%s\\0\\0\\0\\0\\0"
    Local Const $WM_COPYDATA = 0x4A
    Local $szType
    Local $szMessage
    Local $iSize
    Local $pMem
    Local $stCopyData
    Local $hWindow

    ;; Format the message ;;
    Switch ($iType)
        Case 1
            $szType = "Games"
        Case 2
            $szType = "Office"
        Case Else
            $szType = "Music"
    EndSwitch
    $szMessage = StringFormat($szFormat, $szType, $bEnable, $szText)
    
    ;; Create a unicode string ;;
    $iSize = StringLen($szMessage) + 1
    $pMem = DllStructCreate("ushort[" & $iSize & "]")
    For $i = 0 To $iSize
        DllStructSetData($pMem, 1, Asc(StringMid($szMessage, $i, 1)), $i)
    Next
    DllStructSetData($pMem, 1, 0, $iSize)
    
    ;; Create the COPYDATASTRUCT ;;
    $stCopyData = DllStructCreate("uint;uint;ptr")
    DllStructSetData($stCopyData, 1, 0x547) ;dwData = MSN magic number
    DllStructSetData($stCopyData, 2, ($iSize * 2)) ;cbData = Size of the message
    DllStructSetData($stCopyData, 3, DllStructGetPtr($pMem)) ;lpData = Pointer to the message
    
    ;; Send the WM_COPYDATA message ;;
    $hWindow = DllCall("user32", "hwnd", "FindWindowExA", "int", 0, "int", 0, "str", "MsnMsgrUIManager", "int", 0)
    While ($hWindow[0])
        DllCall("user32", "int", "SendMessageA", "hwnd", $hWindow[0], "int", $WM_COPYDATA, "int", 0, "ptr", DllStructGetPtr($stCopyData))
        $hWindow = DllCall("user32", "hwnd", "FindWindowExA", "int", 0, "hwnd", $hWindow[0], "str", "MsnMsgrUIManager", "int", 0)
    WEnd
    
    ;; Cleanup ;;
    $pMem = 0
    $stCopyData = 0
EndFunc   ;==>ChangeMSNMessage

List.ini (Example) :

0=Counter-Strike Source

1=Day of Defeat Source

2=FLEXY

3=Portal

4=Team Fortress 2

5=World of Warcraft

Edited by Jex

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Hmm looks nice, but it's not working for me, my status doesn't change at all. I manually added some programs (like Notepad, AutoIt Help etc.), but it doesn't change my status actually.

Anyone got it working?

(ps I got v.8.1 of WLM)

Edited by Noobster24

Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.

Share this post


Link to post
Share on other sites

Hmm looks nice, but it's not working for me, my status doesn't change at all. I manually added some programs (like Notepad, AutoIt Help etc.), but it doesn't change my status actually.

Anyone got it working?

(ps I got v.8.1 of WLM)

OK now you're posting twice ^^

You might take a look at your settings of WLM...

You have to activate the checkbox on the first page of your settings "Song-Information of WMP"

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Share this post


Link to post
Share on other sites

Hi,

thanks for the reply, I will try again.


Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0