Window Close after Signout |
Author: |
Message: |
Eagle_Erwin
Junior Member
Eagle Erwin
Posts: 17 Reputation: 1
38 / / –
Joined: Aug 2006
|
O.P. Window Close after Signout
I'm trying to make a script that closes the conversation-window when a contact signs out.
The code I have now:
code: function OnEvent_ContactSignout(Email){
var contact=Messenger.MyContacts.GetContact(Email);
var chats = Messenger.CurrentChats;
var e = new Enumerator(contacts);
for(; !e.atEnd(); e.moveNext()){
var chat = e.item();
var contact1=chat.Contacts
if(contact==contact1){
chat.Close();
}
}
}
But, this doesn't work. What is wrong in this script, or what script can I use to close the conversation window of the person that signs out?
|
|
08-20-2006 09:07 PM |
|
|
Spunky
Former Super Mod
Posts: 3658 Reputation: 61
36 / /
Joined: Aug 2006
|
RE: Window Close after Signout
Does chat.Contacts return the email or name of the contact, couldn't tell by quickly glancing at the documentation... It could just that.
Also, it may possibly be that "chat.Close()" should be "chat.Close(0)", as I think it MUST have an exit code.
<Eljay> "Problems encountered: shit blew up"
|
|
08-20-2006 09:42 PM |
|
|
artfuldodga
Full Member
Posts: 178
Joined: Mar 2006
|
RE: Window Close after Signout
I'd like to use this script when its finished .. any way to get rid of that popup 'you are signing out of messenger all conversations will be closed' ?
|
|
08-20-2006 09:48 PM |
|
|
Spunky
Former Super Mod
Posts: 3658 Reputation: 61
36 / /
Joined: Aug 2006
|
RE: Window Close after Signout
I'm guessing that would require some way of hooking the WLM itself... Some sort of SendKeys command maybe, but that would be a bit messy and awkward to do
<Eljay> "Problems encountered: shit blew up"
|
|
08-20-2006 09:50 PM |
|
|
Eagle_Erwin
Junior Member
Eagle Erwin
Posts: 17 Reputation: 1
38 / / –
Joined: Aug 2006
|
O.P. RE: RE: Window Close after Signout
quote: Originally posted by SpunkyLoveMuff
Does chat.Contacts return the email or name of the contact, couldn't tell by quickly glancing at the documentation... It could just that.
Also, it may possibly be that "chat.Close()" should be "chat.Close(0)", as I think it MUST have an exit code.
chat.Contacts returns an enumeration of all contacts active in the chat window. So it returns an object of the type contact.
The use of an exit-code didn't have the right effect, it still doesn't work.
Edit:
I already found an error in this script:
code: function OnEvent_ContactSignout(Email){
var contact=Messenger.MyContacts.GetContact(Email);
var chats = Messenger.CurrentChats;
var e = new Enumerator(chats);
for(; !e.atEnd(); e.moveNext()){
var chat = e.item();
var contact1=chat.Contacts
if(contact==contact1){
chat.Close();
}
}
}
In the declaration of var e "contacts" must be "chats". The problem isn't solved by this change.
This post was edited on 08-20-2006 at 10:05 PM by Eagle_Erwin.
|
|
08-20-2006 10:00 PM |
|
|
Spunky
Former Super Mod
Posts: 3658 Reputation: 61
36 / /
Joined: Aug 2006
|
RE: Window Close after Signout
code: function OnEvent_ContactSignout(Email){
var contact=Messenger.MyContacts.GetContact(Email);
var chats = Messenger.CurrentChats;
var e = new Enumerator(chats);
for(; !e.atEnd(); e.moveNext()){
var chat = e.item();
var contact1=chat.Contacts
if(contact==contact1){
chat.Close();
}
}
}
EDIT - Beat me to it... lol. That didn't fix it?
This post was edited on 08-20-2006 at 10:07 PM by Spunky.
<Eljay> "Problems encountered: shit blew up"
|
|
08-20-2006 10:06 PM |
|
|
Eagle_Erwin
Junior Member
Eagle Erwin
Posts: 17 Reputation: 1
38 / / –
Joined: Aug 2006
|
O.P. RE: Window Close after Signout
Nope, it didn't.
Great minds think alike
|
|
08-20-2006 10:08 PM |
|
|
CookieRevised
Elite Member
Posts: 15517 Reputation: 173
– / /
Joined: Jul 2003
Status: Away
|
RE: Window Close after Signout
quote: Originally posted by Eagle_Erwin
I'm trying to make a script that closes the conversation-window when a contact signs out.
The code I have now:
(...)
But, this doesn't work. What is wrong in this script, or what script can I use to close the conversation window of the person that signs out?
There is too much wrong to list, so here is the fixed script. Things you got wrong are corrected in in red:
code: function OnEvent_ContactSignout(Email) {
var contact = Email;
var chats = Messenger.CurrentChats;
var e = new Enumerator(chats);
for(; !e.atEnd(); e.moveNext()) {
var chat = e.item();
var f = new Enumerator(chat.Contacts);
for(; !f.atEnd(); f.moveNext()) {
var contact1 = f.item();
if (contact == contact1.Email) {
Interop.Call("User32", "SendMessageA", chat.Handle, 0x10, 0, 0)
break;
}
}
}
}
in short: code: function OnEvent_ContactSignout(Email) {
for(var e = new Enumerator(Messenger.CurrentChats); !e.atEnd(); e.moveNext()) {
var chat = e.item();
for(var f = new Enumerator(chat.Contacts); !f.atEnd(); f.moveNext()) {
if (Email == f.item().Email) {
Interop.Call("User32", "SendMessageA", chat.Handle, 0x10, 0, 0);
break;
}
}
}
}
But I also advise not to use this script as-is. 2 major drawbacks:
1) Closing a convo automatically like that will make you often miss messages send by people (even when you implement a delay).
2) Using the logic you used, it will also close conversation with multiple contacts whenever 1 of those contacts signs out. See mickael9's script in the next post for a better logic and a way to fix this.
This post was edited on 08-20-2006 at 10:35 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
|
|
08-20-2006 10:20 PM |
|
|
mickael9
Full Member
Posts: 117 Reputation: 3
33 / /
Joined: Jul 2005
|
RE: Window Close after Signout
quote: Originally posted by Eagle_Erwin
I'm trying to make a script that closes the conversation-window when a contact signs out.
The code I have now:
code: function OnEvent_ContactSignout(Email){
var contact=Messenger.MyContacts.GetContact(Email);
var chats = Messenger.CurrentChats;
var e = new Enumerator(contacts);
for(; !e.atEnd(); e.moveNext()){
var chat = e.item();
var contact1=chat.Contacts
if(contact==contact1){
chat.Close();
}
}
}
But, this doesn't work. What is wrong in this script, or what script can I use to close the conversation window of the person that signs out?
Hi,
this should work :
code: function OnEvent_ContactSignout(sEmail)
{
CloseWindows();
}
function OnEvent_ChatWndContactRemoved(ChatWnd, sEmail)
{
CloseWindows();
}
function CloseWindows()
{
var chats = Messenger.CurrentChats;
var e = new Enumerator(chats);
for(; !e.atEnd(); e.moveNext())
{
var chat = e.item();
var e2 = new Enumerator(chat.Contacts);
var bCanClose = true;
for (; !e2.atEnd(); e2.moveNext())
{
var contact = e2.item();
bCanClose &= (contact.Status != 1);
}
if (bCanClose)
Interop.Call("user32","SendMessageW", chat.Handle, 16, 0, 0);
}
}
It works when :
You are in a conversation with 1 contact and he signs out
You are in a conversation with 5 contacts, 2 signs out and 3 leaves the conversation.
This post was edited on 08-20-2006 at 10:28 PM by mickael9.
|
|
08-20-2006 10:22 PM |
|
|
Spunky
Former Super Mod
Posts: 3658 Reputation: 61
36 / /
Joined: Aug 2006
|
RE: Window Close after Signout
Cookie, you beat me to a couple of the things in there... I was looking through the documentation (like a good little boy) and realised he would need to enumerate chat.Contacts. I also started thinking about the Interop.Call as I wasn't able to find a ChatWnd.Close function
<Eljay> "Problems encountered: shit blew up"
|
|
08-20-2006 10:23 PM |
|
|
Pages: (2):
« First
[ 1 ]
2
»
Last »
|
|