What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Add items to chatwindow

Pages: (2): « First [ 1 ] 2 » Last »
Add items to chatwindow
Author: Message:
PaulE
Junior Member
**


Posts: 28
Joined: Jul 2006
O.P. Add items to chatwindow
Hey,

Can you add buttons to a chatwindow, and make them clickable?
I have made a system, but now my commands are /o_add [email] and /o_del [email], and i want to made buttons to add/delete. Like this:

[Image: vbnm9.gif]

I hope this can be done in Messenger Plus! Live.

PaulE :)

This post was edited on 01-14-2007 at 05:26 PM by PaulE.
01-14-2007 05:25 PM
Profile PM Find Quote Report
Ezra
Veteran Member
*****

Avatar
Forgiveness is between them and God

Posts: 1960
Reputation: 31
37 / Male / Flag
Joined: Mar 2003
RE: Add items to chatwindow
It is possible to do, but it can be tricky, the best way is to make a Plus! window and make it a child of the chatwindow. Place the window on the place where you want the buttons to be and the window should look like it's a part of the chatwindow, while it's not :P

Take a look at the script TimeZone, he did it, only without the buttons.
[Image: 1-0.png]
             
01-14-2007 05:46 PM
Profile PM Web Find Quote Report
PaulE
Junior Member
**


Posts: 28
Joined: Jul 2006
O.P. RE: Add items to chatwindow
I have looked into the source, but i dont understand what i do need to make the buttons. There is a lot of source you know.. :P

EDIT:
// Zo te zien ben je nederlands? :P

This post was edited on 01-14-2007 at 06:07 PM by PaulE.
01-14-2007 06:04 PM
Profile PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: Add items to chatwindow
Well,...
  1. First of all you need to make a window with a WindowTmpl (ChildTmpl don't work and DialogTmpl looks ugly) which has your two buttons. Then, you can eventually remove the borders. (look in the documentation)
  2. Now, you need to create your window but don't show it yet.
    code:
    var PlusWnd = MsgPlus.CreateWnd("Windows.xml", "MyWnd", 2); //The 2 prevents it from being visible when it's created
  3. Here's the big trick: you have to set the chat window as the parent of the window:
    code:
    var Result = Interop.Call("User32.dll", "SetParent", PlusWnd.Handle, ChatWnd.Handle); //Make sure ChatWnd is valid. Result can be used to check if the function succeeded.
  4. Set the width and height of the window
    code:
    var Result = Interop.Call("User32.dll", "SetWindowPos", PlusWnd.Handle, 0, 0, 0, 100, 50, 18); //100 is the width, 50 is the height
  5. Position your window in the chat window. We'll place it 250 pixels from the bottom and 120 pixels from the right. Therefore, we first need the size of the chat window.
    code:
    var RECT = Interop.Allocate(16);
    var Result = Interop.Call("User32", "GetWindowRect", ChatWnd.Handle * 1, RECT);
    var CurWidth = RECT.ReadDWORD(8) - RECT.ReadDWORD(0);
    var CurHeight = RECT.ReadDWORD(12) - RECT.ReadDWORD(4);

    var x = CurWidth - 120;
    var y = CurHeight - 250;
    var Result = Interop.Call("User32.dll", "SetWindowPos", PlusWnd.Handle, 0, x, y, 0, 0, 17);
  6. Now, make it visible! :D
    code:
    PlusWnd.Visible = true
The problem is that when you resize the window, our window will disappear. Therefore, you need to add a timer which repositions the timer every x seconds, somewhere between 100 to 500 milliseconds should do. In other words: add a timer event which repeats step 5 every 100 milliseconds. ;)

All credits go to Timezone by Shondoit!


[OFFTOPIC]Ik ben ook Nederlandstalig (Vlaams) hoor! :tongue:[/OFFTOPIC]
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
01-14-2007 07:02 PM
Profile E-Mail PM Web Find Quote Report
PaulE
Junior Member
**


Posts: 28
Joined: Jul 2006
O.P. RE: Add items to chatwindow
quote:
Originally posted by Mattike
...
Haha, bedankt, dit ziet er een stuk simpeler uit dan dat van TimeZone :). Ik werk zelf niet veel hiermee, dus dan wordt ik graag een handje geholpen :) Ik zal is kijken hoever ik hiermee kom! Bedankt! :)
(Moet ik stap 2 uitvoeren als iemand zich aanmeld ofzo? :P)
01-14-2007 07:06 PM
Profile PM Find Quote Report
Ezra
Veteran Member
*****

Avatar
Forgiveness is between them and God

Posts: 1960
Reputation: 31
37 / Male / Flag
Joined: Mar 2003
RE: Add items to chatwindow
Step 2 should be done when a ChatWindow is created. You can find the details of these Events in the Scripting Documentation

quote:
Originally posted by Dutch Translation

Je moet stap 2 doen als er een ChatWindow gemaakt word. In de Script Documentatie kan je alles vinden over deze Events.
[Image: 1-0.png]
             
01-14-2007 07:25 PM
Profile PM Web Find Quote Report
PaulE
Junior Member
**


Posts: 28
Joined: Jul 2006
O.P. RE: RE: Add items to chatwindow
quote:
Originally posted by Ezra
Step 2 should be done when a ChatWindow is created. You can find the details of these Events in the Scripting Documentation

quote:
Originally posted by Dutch Translation

Je moet stap 2 doen als er een ChatWindow gemaakt word. In de Script Documentatie kan je alles vinden over deze Events.

Hehe, that english i do understand ;)
01-14-2007 07:27 PM
Profile PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: Add items to chatwindow
quote:
Originally posted by PaulE
quote:
Originally posted by Mattike
...
Haha, bedankt, dit ziet er een stuk simpeler uit dan dat van TimeZone :). Ik werk zelf niet veel hiermee, dus dan wordt ik graag een handje geholpen :) Ik zal is kijken hoever ik hiermee kom! Bedankt! :)
(Moet ik stap 2 uitvoeren als iemand zich aanmeld ofzo? :P)
First of all, if you want to talk Dutch, leave an English version too. :P
quote:
Originally posted by PaulE
quote:
Originally posted by Mattike
...
Heh, thanks, this looks a lot more simple than the one from TimeZone :). I don't work a lot with this myself, so I like to get some help :) I'll see how far I get with this! Thanks!
(Do I have to execute step 2 when someone signs in or what? :P)

In fact, you should store all your PlusWnds and ChatWnds in an array. So, on top of your script you place:
code:
var ChatWnds = new Array();
var PlusWnds = new Array();
And in your step 2, you should add:
code:
ChatWnds[ChatWnd.Handle] = ChatWnd;
PlusWnds[ChatWnd.Handle] = PlusWnd;
When you don't do that, you can't make a timer!

The whole code block should be executed when a chat window is created, so in the OnEvent_ChatWndCreated. There, you also have ChatWnd as parameter!
code:
function OnEvent_ChatWndCreated(ChatWnd) {
   //Here the code
}
You should also check if the script is started while the user is already signed in and has some conversations opened. Therefore, you need an OnEvent_Initialize and check if the user is signed in. If so, you should loop through all opened conversations and execute the code for every window.
code:
function OnEvent_Initialize(MessengerStart) {
   if(Messenger.MyStatus > 0) { //Checks if the user is signed in
     for(var e = new Enumerator(Messenger.CurrentChats); !e.atEnd(); e.moveNext()) {
       var ChatWnd = e.item();
       //Here the code
     }
   }
}
And when a chat window is destroyed, you should remove the ChatWnd and PlusWnd from the arrays.
code:
function OnEvent_ChatWndDestroyed(ChatWnd) {
  var PlusWnd = PlusWnds[ChatWnd.Handle];
  if(PlusWnd != undefined) {
    PlusWnd.Close(0);
  }
  delete ChatWnds[ChatWnd.Handle];
  delete PlusWnds[ChatWnd.Handle];
}

NOTE: I hope you're aware of the problems you can get when you place your buttons there? You can hide the display pictures, you can have a dynamic picture,... and those things aren't easy to work around!

This post was edited on 01-14-2007 at 07:30 PM by Matti.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
01-14-2007 07:28 PM
Profile E-Mail PM Web Find Quote Report
PaulE
Junior Member
**


Posts: 28
Joined: Jul 2006
O.P. RE: Add items to chatwindow
Hehe i will see where i will place them. Normally my chatwindow is always the same size, and DsiplayPicture is always visible :) Thnx :D

EDIT
I have made some code of what you guys said, but i get an error:
quote:
> Script is gestopt.
> Script wordt gestart.
> Script is succesvol gestart.
> Functieaanroep: "OnEvent_Initialize"
> Functieaanroep: "OnEvent_ChatWndDestroyed"
> Functieaanroep: "OnEvent_ChatWndCreated"
> Fout gedetecteerd in lijn 29: Deze eigenschap of methode wordt niet ondersteund door dit object.
  (Code: -2146827850)
> Fout gedetecteerd in "OnEvent_ChatWndCreated".
  (Code: -2147352567)
> Functieaanroep: "OnEvent_ChatWndSendMessage"

So, the script starts, buy when i create a ChatWnd i get an error on line 29:
code:
    Result = Interop.Call("User32", "GetWindowRect", ChatWnds[ChatWnd.Handle] * 1, RECT);

This is my code:
code:
var ChatWnds = new Array();
var PlusWnds = new Array();

function OnEvent_Initialize(MessengerStart) {

    if(Messenger.MyStatus > 0) {

        for(var e = new Enumerator(Messenger.CurrentChats); !e.atEnd(); e.moveNext()) {

            var ChatWnd = e.item();
            ChatWnds[ChatWnd.Handle] = ChatWnd;
            PlusWnds[ChatWnd.Handle] = MsgPlus.CreateWnd("Buttons.xml", "Buttons", 2);

        }

    }

}

function Onevent_ChatWndCreated(ChatWnd) {

    ChatWnds[ChatWnd.Handle] = ChatWnd;
    PlusWnds[ChatWnd.Handle] = MsgPlus.CreateWnd("Buttons.xml", "Buttons", 2);

    var Result = Interop.Call("User32.dll", "SetParent", PlusWnds[ChatWnd.Handle], ChatWnds[ChatWnd.Handle]);
    Result = Interop.Call("User32.dll", "SetWindowPos", PlusWnds[ChatWnd.Handle], 0, 0, 0, 100, 50, 18);

    var RECT = Interop.Allocate(16);
    Result = Interop.Call("User32", "GetWindowRect", ChatWnds[ChatWnd.Handle] * 1, RECT);
    var CurWidth = RECT.ReadDWORD(8) - RECT.ReadDWORD(0);
    var CurHeight = RECT.ReadDWORD(12) - RECT.ReadDWORD(4);

    var x = CurWidth - 120;
    var y = CurHeight - 250;
    Result = Interop.Call("User32.dll", "SetWindowPos", PlusWnds[ChatWnd.Handle], 0, x, y, 0, 0, 17);

    PlusWnds[ChatWnd.Handle].Visible = true;

}

function OnEvent_ChatWndDestroyed(ChatWnd) {

    var PlusWnd = PlusWnds[ChatWnd.Handle];

    if(PlusWnd != undefined) {
        PlusWnd.Close(0);
    }

    delete ChatWnds[ChatWnd.Handle];
    delete PlusWnds[ChatWnd.Handle];

}

What is the problem? :P

Edit
I added the source as attachment, because this code tags dont works good :P

.txt File Attachment: ChatWnd Handle.txt (2.8 KB)
This file has been downloaded 292 time(s).

This post was edited on 01-14-2007 at 08:02 PM by PaulE.
01-14-2007 07:53 PM
Profile PM Find Quote Report
deAd
Scripting Contest Winner
*****

Avatar

Posts: 1060
Reputation: 28
– / Male / Flag
Joined: Jan 2006
RE: RE: Add items to chatwindow
quote:
Originally posted by PaulESo, the script starts, buy when i create a ChatWnd i get an error on line 29:
code:
    Result = Interop.Call("User32", "GetWindowRect", ChatWnds[ChatWnd.Handle] * 1, RECT);

I didn't read the whole code, but you'll want to just pass ChatWnd.Handle to the GetWindowRect function.
01-14-2007 08:17 PM
Profile PM Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On