Shoutbox

Conversation window - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Conversation window (/showthread.php?tid=65185)

Conversation window by tomjbyrne on 08-21-2006 at 08:56 AM

Is there any way I can get the conversation window to automatically open on my desktop (when text is received from someone on my contact list) instead of the object flashing on the task bar


RE: Conversation window by KnRd_WC on 08-21-2006 at 10:36 AM

Hi tomjbyrne !

Try this :

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin,Message,MessageKind) {
     Handle = ChatWnd.Handle;
     Interop.Call("User32.dll","SetForegroundWindow",Handle);
     return Message;
}


;)
RE: Conversation window by tomjbyrne on 08-21-2006 at 10:46 AM

Thanks for the reply,  Appologies, am very new to this, where would this code be entered


RE: Conversation window by KnRd_WC on 08-21-2006 at 10:52 AM

Just for you ! lol

Script : AutoForeground (Messenger Plus! Live must be launched to install this script !)

;)


RE: Conversation window by tomjbyrne on 08-21-2006 at 01:16 PM

A lot to learn I guess..... Any idea why it would work on one PC and not another... all windows closed minimized on my laptop and when a msg is received the window pops up, yet on a desktop it does not.
Rgds


RE: Conversation window by KnRd_WC on 08-21-2006 at 01:34 PM

That's really strange, I've got the same problem. My script works fine on my computer... and with my father's computer, it do not.... :S

I'm gonna see what I can do.... but I'm not sure I can do something !!
---------------------------
EDIT : Problem found !!!

In fact, before putting the window at the foreground, I have to restore this window xD !

code:
Interop.Call("User32.dll","ShowWindow",Handle,9); // 9=SW_RESTORE

Now, this script should work fine !

>>> Download AutoForeground !
(IMPORTANT : Maybe you will have to delete you internet cache, I've got a problem to download the new version with Firefox until I delete my internet cache :S)
---------------------------
Do you think it will be useful for you if I insert commands ??
For exemple : /afon (AutoForeground On)
                   /afoff (AutoForeground Off)
RE: Conversation window by tomjbyrne on 08-21-2006 at 02:44 PM

I owe you one new code works fine, thanks a bunch for your help.
Rgds


RE: Conversation window by KnRd_WC on 08-21-2006 at 03:00 PM

Thanks, there's no problem ;)

Just a last post :

For you tomjbyrne, and those who are interested, I added these commands, which allow you to turn on or off AutoForeground (that's useful, because if you do something important, you don't want to be disturbed with Messenger windows !!)

The 2 commands :/afon (AutoForeground On)
                        /afoff (AutoForeground Off)
(setting will be saved into the registry)

Download : AutoForeground


RE: Conversation window by RaceProUK on 08-21-2006 at 03:43 PM

Have you submitted this to the Scripts DB? I think you should ;)


RE: Conversation window by KnRd_WC on 08-21-2006 at 04:09 PM

Wow, really ?

For me, this is a "little" script... but... it can be useful !
I'm going to submit this script ! Good idea ! Thanks ! ;)


RE: Conversation window by Jiggs on 08-23-2006 at 12:03 PM

cool. i like it. any chance you could add the on and odd option to the plus! menu? "Turn AF ON" when off and "Turn AF OFF" when on

also, is it possible to make it pop into foreground without popping up the taskbar?
i use the enhancer script to stop the taskbar from flashing, but with this script enabled, it does so anyway. no big deal tho.


RE: Conversation window by matty on 08-23-2006 at 12:06 PM

quote:
Originally posted by KnRd_WC
EDIT : Problem found !!!

In fact, before putting the window at the foreground, I have to restore this window xD !

code:
Interop.Call('user32', 'BringWindowToTop', hWnd);
The BringWindowToTop function brings the specified window to the top of the Z order. If the window is a top-level window, it is activated. If the window is a child window, the top-level parent window associated with the child window is activated.
RE: Conversation window by KnRd_WC on 08-23-2006 at 02:08 PM

Thanks, good ideas ;)

ADDED IN THE PLUS! MENU :
   - Turn AF ON } when OFF
   - Turn AF OFF } when ON

>> AutoForeground

quote:
Originally posted by Matty
code:
Interop.Call('user32', 'BringWindowToTop', hWnd);

This function is the same as 'Interop.Call("User32.dll","SetForegroundWindow",hWnd)' and they ONLY works when the window is not minimized !! xD
quote:
Originally posted by KnRd_WC
code:
Interop.Call("User32.dll","ShowWindow",hWnd,9); // 9=SW_RESTORE

But, thanks ;)

quote:
Originally posted by Jiggs

also, is it possible to make it pop into foreground without popping up the taskbar?
i use the enhancer script to stop the taskbar from flashing, but with this script enabled, it does so anyway. no big deal tho.
Sorry, but I don't really understand :S (Hey, I'm French !!! xD)


RE: Conversation window by artfuldodga on 08-23-2006 at 02:20 PM

I like this script, checking it out :) .. wondering how it works with multiple chats..

Edit: Ok I think Tabbed Chat / Chatting with Multiple Contacts.. needs to work a bit better :) if you're typing to somebody, and someone else messages you...  could be a problem :P

How about only popup with the Contact who is typing .. when the window is minimized, because if the window is not minimised... usually you can see that somebody else has messaged you in a tab..

I think it would be better if the script did basially nothing while the conversation windows are in Focus


RE: Conversation window by KnRd_WC on 08-23-2006 at 03:06 PM

Wow yeah !! That's very distubing !! I added a function which check if you have an "active" chat window. I hope that was your request... (Because it's very hard to understand...)

IMPROVED  :
   - Set chat window on foreground when message is received ONLY when there's no other active chat window

>> AutoForeground


RE: Conversation window by artfuldodga on 08-23-2006 at 03:47 PM

I can't try it out at the moment... but heres what I meant:

Contact1 sends you a Message (window minimzed and window pops up when Contact1 starts typing a Message to you)

You look at Contact1's Message, begin to Reply and all of a sudden, Contact2 starts typing a Message to you & now you are typeing in Contact2's Conversation window.

(Perhaps sending the wrong Message to the wrong Contact If you aren't paying much Attention)

So if you fixed that, thats good :)

Edit: Perhaps keep the window focused on the Latest Contact that types you a Message and makes the Window come to the front, and let the User switch between tabs as he/she pleases. And the next time a new Message is sent while the Conversation Window is out of Focus...  Bring the Window to the front with the latest Contact that has started sending you a Message.

* I'm mostly thinking of people using Tabbed Chats here...  I know alot of people use Tabs


RE: Conversation window by KnRd_WC on 08-23-2006 at 04:07 PM

If I understood well your message, that's fixed !

With these lines :

Before :

code:
        Interop.Call("User32.dll","ShowWindow",ChatWnd.Handle,9);        Interop.Call("User32.dll","SetForegroundWindow",ChatWnd.Handle);


After :
code:
HandleActiveWindow=Interop.Call("User32.dll","GetActiveWindow");
        OnForeground=0
        Windows = Messenger.CurrentChats
        e = new Enumerator(Windows)
        for(;!e.atEnd();e.moveNext()) {
            if (e.item().Handle==HandleActiveWindow) {
                OnForeground=1
            }
        }
        if (OnForeground==0&&HandleActiveWindow!=ChatWnd.Handle) {
            Interop.Call("User32.dll","ShowWindow",ChatWnd.Handle,9);
            Interop.Call("User32.dll","SetForegroundWindow",ChatWnd.Handle);
        }

I hope that it is what you want.... :S

I use Tabs too, and I think the Tabs are located in a window attached to the top of chat windows, so, there's no problem with the Tabs.... Now ! (I tested my script with tabs, there's no problem, I think...) :P

The link, one more time... xD

>> AutoForeground 1.1
RE: Conversation window by artfuldodga on 08-23-2006 at 05:29 PM

OK, script works nicely now when you have the Window Open and talking to Multiple Contacts :) it doesn't switch back & forth between who has Messaged you Last, which is good.

Suggestion:

When the Window is Minimized to the system tray, make it so that the Window only Pops up to the Foreground for the Contact that you Minimized the Window on.

ex)

|Contact1|Contact2|Contact3|

- You are talking to Contact2, and you Minimize the Window while you are in Contact2's Tab

- Contact2 Messages you, and the window Pops up (Because he/she was the last Window you had Selected)

- If Contact3 had messaged you, the window would simply Flash.

* How does that sound?
   So far so good though, I like this Script :)


RE: Conversation window by KnRd_WC on 08-23-2006 at 05:47 PM

I think that I understood :D

(Thanks for the schema ;)) lol

But it's very hard to understand you now... I speak English since I got up (here it's 7:50pm), and that's become boring xD

I'm gonna see what I can do for the script ;)
-----------------------------
Edit :

I'm not sure I'm going to include this function in my script :

1) This script set ALL the windows on foreground when message is received (maybe I can add an option to enable this new feature...)
2) In fact, it's very hard (for my knowledges) to get the chat window handle when you click on this window... (when you receive a message, ok, the handle can be caught, but if you click on an other chat window, here's the problem...) :S
I tried with that :

code:
function OnEvent_ChatWndEditKeyDown(ChatWnd,KeyCode,CtrlKeyDown,ShiftKeyDown) {
if (KeyCode==1) {
LastHandle=ChatWnd.Handle;
}
}
Unsuccessfully, because I can't catch the VK_LBUTTON (1) event..... :(

3) Right now, I've got to work on my website :(

But, I'm still looking for a solution, I will contact you again if I found a solution ;)
RE: Conversation window by artfuldodga on 08-24-2006 at 12:39 PM

thanks, looking forward to seeing what you can come up with.


RE: Conversation window by CookieRevised on 08-24-2006 at 05:41 PM

Maybe I completely misunderstood the requests and suggestions and all (and I also didn't looked/tested at the scripts), but you can simply restore a window without bringing it to the foreground. This means that a chat window will be restored: if it is the only window, it will be the first foreground window, if it is not the only chat window it will be restored behind the currently active one.... search the windows api's for this (I don't know them by heart, but I know you can simply do this with one)...

With this, you wont have any problems with windows stealing focus, tabbed chats and what not and you wont need to check if a window is in a tab or not, etc etc.


RE: Conversation window by artfuldodga on 08-24-2006 at 05:46 PM

I don't mind the Convo Window coming to the Foreground :) .. but, I would rather it come to the Foreground, Only if the person I minimized the Window on.... or left Focus of... Messages me back, rather than it switching to the very next person that Messages all the time one after the other.. :) it makes the window pop up way to often! & kind of becomes more of an annoyance.

Some users might want to leave themselves in a Tab where they know there won't be anyone writing a message anytime soon, just so the window doesn't pop up on them :)...  which is better than turning the script off & on


RE: RE: Conversation window by KnRd_WC on 08-24-2006 at 11:17 PM

Do you remember when I said that :

quote:
Originally posted by KnRd_WC
But, I'm still looking for a solution, I will contact you again if I found a solution ;)

And I found a "solution"...
In fact, when you use Tabbed Chats, there is only one window shown in the taskbar, the active chat window. And i tried to work with that, unsuccessfully... :(
And, while I was looking at the list of windows on my computer... I found that : "MessengerPlusLive_TabbedChats". This window has the name of the contact in the active window. So, just compare this window's name with the contact's name....

Here's the script modified (I'm going to include an option to activate or deactivate this feature) :
>> AutoForeground


I hope it works, if not, please, post a message with the bug's description.

>> I know, I use a "crappy" function to detect the window, because if 2 contacts have the same name (not very probable...) ... the window will be choose by chance xD. So, please, I'm only 17 years old, and I'm "new" to MP!L scripting, don't "boo" me, please.... :S

@ CookieRevised : In fact, if you restore a window which is not minimized, nothing will happen... :( ("AutoForeground : Automatically set chat window on foreground when message is received")
But, thank you :)
RE: Conversation window by artfuldodga on 08-25-2006 at 12:15 AM

Seems to work Nicely :) I was just testing it out... it did what I suggested it do, which was Only Popup if you Minimize the window with a Contact who is Actively talking to you. I opened a tab to a Contact that was not talking to me, and Minimized the Window using them and the previous Contact would Message me & the Window would Flash in the tray. Good Job :)

I guess you still have to find a sure fire way to make sure it doesn't mix the Contact nicknames up?

Still testing & seeing if I like it, having it this way so far makes it a lot LESS annoying.


RE: Conversation window by KnRd_WC on 08-25-2006 at 12:26 AM

Thanks ;)

Yeah, I have to find another function.. but it's very very very difficult to find 2 contacts who have the same name... (maybe, for example : "a" and "a", lol)... And it is the only solution I found...

Option added in the menu ! (I tried to make a "good" translation, if not, please say it to me...)
>> AutoForeground

Maybe there's a little bug when somebody talks to you when you're offline, I don't know... I'm on 2 PC to test this script :) I will see...

;)


RE: RE: RE: Conversation window by CookieRevised on 08-25-2006 at 12:29 AM

quote:
Originally posted by KnRd_WC
In fact, when you use Tabbed Chats, there is only one window shown in the taskbar, the active chat window. And i tried to work with that, unsuccessfully... :(
And, while I was looking at the list of windows on my computer... I found that : "MessengerPlusLive_TabbedChats". This window has the name of the contact in the active window.
that hidden window is owner of the chat windows. See script in CookieRevised's reply to Tabbed Chats - wrong contact ;)

aka: Instead of using the FindWindow API, which will most likely return the wrong window when using polygamy!, retrieve the owner window of the tabbed chat windows to get to the (correct) "MessengerPlusLive_TabbedChats"-class window.


---

quote:
Originally posted by KnRd_WC
@ CookieRevised : In fact, if you restore a window which is not minimized, nothing will happen... :( ("AutoForeground : Automatically set chat window on foreground when message is received")
But, thank you :)
you're not using the right api (or apis) then, If you read my post carefully I say that if chats already exist and you are busy in one, the one being restored will be put behind the active one (active one being the one you'er busy in) in the z-order. If you're not busy in a convo, the one being restored will become the top chat window.



RE: Conversation window by KnRd_WC on 08-25-2006 at 12:50 AM

Thanks for the advice ;)

This function ? (That seems to works) :

code:
Interop.Call("User32.dll","FindWindowExW",0,ChatWnd.Handle,"MessengerPlusLive_TabbedChats",0);

RE: Conversation window by artfuldodga on 08-25-2006 at 12:51 AM

Translation for Menu Item & Suggested Menu Layout

AutoForeground > AutoForeground: On / Off
                           > Tabbed Chat Options > Restore | Focus Window: Upon Activity in currenty Selected Tab: On / Off
                           > About > little window to discribe your script :) What the Default setting will do, and what using the Tab Option will do...



* Maybe thats to many Characters to use in the Menu, if anyone else has a Suggestion so that people understand what it does .. say something :P


RE: Conversation window by KnRd_WC on 08-25-2006 at 01:29 AM

Thanks ;)

I tried to make something understandable.... I will need a translator again xD !! Artfuldodga ?? Are you there ??? lol

The link, one more time !!
>> AutoForeground
-----------------------
It's time to sleep in France !! (3:57AM :P) See you later :)


RE: Conversation window by artfuldodga on 08-25-2006 at 02:04 AM

AutoForeground > AF: On / Off
                           > Tabbed Chat Options > Restore upon activity in selected Tab: On / Off
                           > About > discribe script, etc .. as small of a window as possible :)

* use that, it shortens the menus up a bit!

Other than that, I think the script works nicely! .. You should submit it to the Scripts Database & Page

* Is there a way, so that.. say if have a web browser Open and you were typing on a forum, and your Contact Messages you, could the Window be Only brought up behind other Applications you are using? .. I know it kind of Defeats the purpose of bringing the window to the front..  but if you are Entering Bank Account Information :) you might not want to press send, with the Information in a Chat window... Bringing a window to the desktop behind other applications would be Ideal, atleast you could see you have Messages, after you stop what you are doing with other Applicatons (Could be another Option)

* Maybe settings in the script, so that the script will not bring the window into Focus, if a specific Application is being used and is Maxmized itself?

Ex) firefox.exe, iexplore.exe .. etc ? whatever program a person uses alot when they are busy, they could fill in a list in your scripts settings somewhere.

:) ... Just a thought..


RE: Conversation window by KnRd_WC on 08-25-2006 at 02:30 AM

Ok, that's good idea, I'm going to start now, but I will finish tomorrow ;)

To do : - A menu item to set a "Silent" foreground (:P) for all windows.
          - An other menu item to set a "Silent" foreground only when a program entered in a customizable list in running, and only when the program's window is active...

Good ideas ;) Thanks :)


RE: Conversation window by RaceProUK on 08-25-2006 at 10:04 AM

quote:
Originally posted by CookieRevised
but you can simply restore a window without bringing it to the foreground
IIRC, in C++, you provide both SW_RESTORE and SW_NOACTIVATE bitwise-or'd to ShowWindow(). That restores the window, but doesn't activate it, therefore it won't move focus out of the active window.

Edit: I was close. According to MSDN, it's actually SW_SHOWNOACTIVATE.
* RaceProUK checks the value...
It's 4 ;)
quote:
Originally posted by WinUser.h"
#define SW_SHOWNOACTIVATE 4

RE: Conversation window by KnRd_WC on 08-25-2006 at 10:41 AM

Thanks RaceProUK, but in fact, I already tried this function yesterday with a script :

code:
Interop.Call("User32.dll","ShowWindow",ChatWnd.Handle,4);
But this function doesn't worked....

So, I tried this function with an external program,"PureBasic" (:)), I get the handle, And I tried again :
code:
ShowWindow_(Handle,4)
Nothing.....

And I tried with Windows Media Player window.... It worked... :'(
:(:(:(:(

I tried too to include the "program filter", I made an external DLL, which compare the process PID in the list and the active window process PID, easy....  but It don't work either (in fact, it works, but sometimes, and "sometimes" is not a good word in programmation...) :'(:'(:'(:'(

I think that my script is going to stop there....................

Thanks guys, I'm going to submit my script to the script DB, thanks again :)
-----------------
I'm going to make an 'about window' ans submit this script, because a messagebox isn't really beautiful.... xD
-----------------
Done !
>> AutoForeground
(Sorry but I removed the 'Thanks' because the 'about window' was very very big xD.
RE: Conversation window by artfuldodga on 08-25-2006 at 01:04 PM

Nice Job. Hopefully someone can maybe help you with improvments!
you should make a new thread for your script.

[Released] AutoForeground 1.2

:) so people know about it

* maybe cookierevised knows some code so that the window is poped up, but not made the active window.


Bug:

I have the Tab Option enabled for the Script and when a Contact Messages you with the Window Restored & Active... if you are Browsing Quick Icons using
WLM's Icon Button (Can Enable that under Quick Icons)... and that Contact Messages you, AutoForeground trys to bring the Window to the Front :) Resulting in a Crash of WLM.

RE: Conversation window by KnRd_WC on 08-25-2006 at 08:51 PM

Mhhhh strange, no crash for me... I'm going to work on these windows (MP!L quick icons...). Thanks for the info ;) I will work on this script later, I'm on an other project right now (look at my signature :P).

Thanks :)


RE: Conversation window by artfuldodga on 08-25-2006 at 09:08 PM

btw, it was Quick Icons displaying (Custom Emoticons) oh.. and i had to press & hold the Quick Icons Scroll bar while someone was typing to me in order to make it crash.


RE: Conversation window by KnRd_WC on 08-25-2006 at 09:11 PM

BUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUG !!!!!!!!!!!!

lol, I will see what I can do to fix that ;)


RE: Conversation window by KnRd_WC on 08-25-2006 at 09:30 PM

Sorry for double post but.... 'bump' !!!!

I think (hope :P) that's fixed...

>> AutoForeground


RE: Conversation window by artfuldodga on 08-25-2006 at 10:34 PM

Seems Fixed :)


RE: RE: Conversation window by CookieRevised on 08-25-2006 at 10:52 PM

[OFF TOPIC]

quote:
Originally posted by artfuldodga
Nice Job. Hopefully someone can maybe help you with improvments!
you should make a new thread for your script.

[Released] AutoForeground 1.2

:) so people know about it
please don't... this thread is already 99,99% about this script. No need for yet another thread (this goes for many other threads/scripts too: there is no need to make a new thread everytime someone makes a script on request. It will clutter the forum and above all will almost always result in double/cross posts and suggestions and explanations).

People will know about it if it is in the database (especially when a link is provided to this thread for 'more information').
[/OFF TOPIC]




quote:
Originally posted by artfuldodga
* maybe cookierevised knows some code so that the window is poped up, but not made the active window.
See RaceProUK's post and especially the link to the msdn library.
RE: Conversation window by KnRd_WC on 08-25-2006 at 10:57 PM

No, don't worry, I'm not going to make a new thread ;)

1) I don't want
2) I don't want
3) As you said, "this thread is already 99,99% about this script"

I already tried to use "ShowWindow" with SW_SHOWNOACTIVATE (4 ;)), and, in fact, I don't know why, this function works with ALL OTHER windows except the chat window xD. I tried to use this function with an external programming software, and it was the same result, so, that's really strange... :S

Here's a new link, sorry, hosting problems...
>> AutoForeground