Jump to content

MSN/Live Personal Message Cycler


BananaFredSoft
 Share

Recommended Posts

This is a program that uses CoePSX's Messenger Personal Message changer and makes it so that you can cycle through messages randomly in Windows Live or MSN Messenger, or in order. You can set the interval between switches, save the message list, and more. Enjoy!

#include <GUIConstants.au3>
#include <Array.au3>
#include <GUIListView.au3>
#include <File.au3>

$conts = _ArrayCreate(0)
$file = _ArrayCreate(0)
$SwitchDelay = IniRead(@ScriptDir & "\BananaMessageSwitcherDate.data", "Options", "SwitchInterval", 3)
$On = 0
$Random = 0

Opt("TrayAutoPause", 0)
Opt("TrayMenuMode",1)
$tr_show = TrayCreateItem("Show")
$tr_exit = TrayCreateItem("Exit")

If bitor(IniRead(@ScriptDir & "\BananaMessageSwitcherDate.data", "Options", "First", 1) = 1, IniRead(@ScriptDir & "\BananaMessageSwitcherDate.data", "Options", "Show", 1) = 1) Then
    If MsgBox(4, "Note", "For the message switcher to work, you must have Show What I'm Listening To turned on. To do this, click on the arrow next to your status and click on the Show What I'm Listening To menu item so it is checked." & @CRLF & "Show this message again?") = 6 Then
        IniWrite(@ScriptDir & "\BananaMessageSwitcherDate.data", "Options", "Show", 1)
    Else
        IniWrite(@ScriptDir & "\BananaMessageSwitcherDate.data", "Options", "Show", 0)
    EndIf
    IniWrite(@ScriptDir & "\BananaMessageSwitcherDate.data", "Options", "First", 0)
EndIf

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("BananaMessageSwitcher", 520, 362, 193, 115)
$ListView1 = GUICtrlCreateListView("Text", 8, 32, 329, 321)
_GUICtrlListView_SetColumnWidth($ListView1, 0, 320)
$Input1 = GUICtrlCreateInput("", 8, 8, 273, 21)
$Add = GUICtrlCreateButton("Add", 288, 8, 49, 17, 0)
$Delete = GUICtrlCreateButton("Delete", 344, 32, 169, 25, 0)
$Hide = GUICtrlCreateButton("Hide", 344, 64, 169, 25, 0)
$Exit = GUICtrlCreateButton("Exit", 344, 96, 169, 25, 0)
$Options = GUICtrlCreateButton("Options", 344, 128, 169, 25, 0)
$set = GUICtrlCreateLabel("Off", 344, 128 + 50)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$timer = TimerInit()
$currentnum = 1

If FileExists(@ScriptDir & "\BananaMessageSwitcherData2.data") Then
    If MsgBox(4, "Load Previous Message List", "Would you like to load the previous message list?") = 6 Then
        _FileReadToArray(@ScriptDir & "\BananaMessageSwitcherData2.data", $file)
        If IsArray($file) Then
            For $i = 1 To $file[0]
                $b = GUICtrlCreateListViewItem($file[$i], $ListView1)
                _ArrayAdd($conts, $B)
                $conts[0] += 1
            Next
        EndIf
    EndIf
EndIf

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUISetState(@SW_HIDE)
            TrayTip("Info", "Right-click on tray icon for more options.", 5)
        Case $Add
            Add()
        Case $Delete
            _ArrayDelete($conts, _ArraySearch($conts, GUICtrlRead($ListView1)))
            $conts[0]-=1
            GUICtrlDelete(GUICtrlRead($ListView1))
        Case $Exit
            ExitF()
        Case $Hide
            GUISetState(@SW_HIDE)
            TrayTip("Info", "Right-click on tray icon for more options.", 5)
        Case $Options
            #Region ### START Koda GUI section ### Form=
            $Form2 = GUICreate("Options", 234, 91, 193, 115)
            $Checkbox1 = GUICtrlCreateCheckbox("Switcher is On", 8, 8, 97, 17)
            $Label1 = GUICtrlCreateLabel("Seconds between switches:", 8, 32, 137, 17)
            $snum = GUICtrlCreateInput($SwitchDelay, 152, 32, 49, 21)
            $Checkbox2 = GUICtrlCreateCheckbox("Randomize Switching", 8, 64, 129, 17)
            GUISetState(@SW_SHOW)
            #EndRegion ### END Koda GUI section ###

            While 1
                $nMsg = GUIGetMsg()
                Switch $nMsg
                    Case $GUI_EVENT_CLOSE
                        If MsgBox(4, "Save Changes", "Would you like to save changes to the Options?") = 6 Then
                            If StringIsAlNum(GUICtrlRead($snum)) Then
                                If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then
                                    $On = 1
                                    GUICtrlSetData($set, "On")
                                Else
                                    $On = 0
                                    GUICtrlSetData($set, "Of")
                                EndIf
                                If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then
                                    $Random = 1
                                Else
                                    $Random = 0
                                EndIf
                                IniWrite(@ScriptDir & "\BananaMessageSwitcherDate.data", "Options", "SwitchInterval", GUICtrlRead($snum))
                                $SwitchDelay = GUICtrlRead($snum)
                                GUIDelete($Form2)
                                GUISwitch($Form1)
                                ExitLoop
                            Else
                                MsgBox(0, "Options Error", "The Seconds Between Switches value is not a number.")
                            EndIf
                        Else
                            GUIDelete($Form2)
                            GUISwitch($Form1)
                            ExitLoop
                        EndIf
                EndSwitch
            WEnd
    EndSwitch
    If TrayGetMsg() = $tr_show Then
        GUISetState(@SW_SHOW)
    ElseIf TrayGetMsg() = $tr_exit Then
        ExitF()
    EndIf
    If BitAND(TimerDiff($timer) / 1000 > $SwitchDelay, $On = 1) Then
        If $Random Then
            $currentnum = Random(1, $conts[0], 1)
        Else
            If $currentnum = $conts[0] Then
                $currentnum = 1
            Else
                $currentnum += 1
            EndIf
        EndIf
        ChangeMSNMessage(0, True, StringTrimRight(GUICtrlRead($conts[$currentnum]), 1))
        $timer = TimerInit()
    EndIf
WEnd


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

Func Add()
    $b = GUICtrlCreateListViewItem(GUICtrlRead($Input1), $ListView1)
    _ArrayAdd($conts, $B)
    $conts[0] += 1
EndFunc

Func ExitF()
    If MsgBox(4, "Save Message List?", "Would you like to save the message list?") = 6 Then
        FileDelete(@ScriptDir & "\BananaMessageSwitcherData2.data")
        For $i = 1 To $conts[0]
            FileWrite(@ScriptDir & "\BananaMessageSwitcherData2.data", StringTrimRight(GUICtrlRead($conts[$i]), 1) & @CRLF)
        Next
    EndIf
    MsgBox(0, "Goodbye", "Thanks for using BananaMessageSwitcher! Visit us at bananafredsoft.com!")
    Exit
EndFunc
Edited by BananaFredSoft
Link to comment
Share on other sites

  • Moderators

Bump.

Did you try downloading UPX and put it in the right folder(s)? http://upx.sourceforge.net/

Or reinstalling AutoIt for that matter?

In other words... What did you do to try and rectify the issue?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Did you try downloading UPX and put it in the right folder(s)? http://upx.sourceforge.net/

Or reinstalling AutoIt for that matter?

In other words... What did you do to try and rectify the issue?

Why did you move this to General Help and Support? It is an example script. I'm sorry if I confused you by saying that I couldn't compile it, I'll take that off the post. I didn't do much about the UPX thing, I'll mess around with it.

Edited by BananaFredSoft
Link to comment
Share on other sites

  • Moderators

Why did you move this to General Help and Support? It is an example script. I'm sorry if I confused you by saying that I couldn't compile it, I'll take that off the post. I didn't do much about the UPX thing, I'll mess around with it.

I assumed with the UPX thing you were requiring assistance.

Then with the bump you were as well.

No need to bump your own threads in the example forum... if people like it, or need it, they'll find it and comment.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Nice :)

I build something with the same functionality, but with much more options.

I store a txt file with the sentences on my server, every 30 minutes the program checks for an update.

Try it @ www.get-me.to/msn-automessage

(msn-automessage is only available in dutch)

If there is anyone who like to translate it to another language, then mail me and i will send you the source.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...