Shoutbox

Sending a message to the focused window only - 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: Sending a message to the focused window only (/showthread.php?tid=83086)

Sending a message to the focused window only by kaourika on 04-11-2008 at 12:47 AM

Argh, I've wasted hours trying to figure this out alone. I always hate to give in, but I think it's time to ask for help.

In my script, when the user clicks a certain button in an XML window, a message needs to be sent to the active, focused chatwnd.

But, with everything I try coding, it's sending to all open windows instead of just the focused one. =/ Thus far the only methods I've found that will send to a specific wnd involve defining the email of one contact, which isn't flexible enough for my needs.

So, I feel like I'm surely missing something obvious. Any pointers would be very appreciated. Thanks <3


RE: Sending a message to the focused window only by matty on 04-11-2008 at 01:42 AM

Are you looking to open an xml click a button and have it sent it to the chat window that was just opened?

If you are opening the window from the Chat Window (via Menu or Command) you can store the Chat Window object to be later used or you can use the EnumWindows function and try and get the ZOrder of the window and which ever is first will likely be the top chatwindow. It is kinda hard to do what you are asking.


RE: Sending a message to the focused window only by kaourika on 04-11-2008 at 07:36 AM

Thanks for the response, matty. :D

Dang, that's what I was afraid of.

Well, this is essentially how it works:
1. a main menu is opened either from the script menu or a command.
2. BUT... On the main menu, there are several buttons to reach other windows -- for example, the inventory.
3. When one of these buttons is clicked, it destroys the main window and creates the inventory window. I had to do it like this because I couldn't get the child wnds to work for me, and each different window is really complex; I didn't really want to deal with everything cluttered into one massive XML file. =/ And this is the the xml window I'll need to be sending text from. (among with other similar "sub" windows, like the store, the kitchen, and so on.)

So basically, even though the main xml window is reached via the script menu or command, subsequent windows, such as the inventory, are not. D: I suppose it won't be possible, then, to send messages from these?

Also, when you say "will likely be the top window", does likely just mean 'sometimes,' or 'almost always unless there's some freakish bug' ? =P


RE: Sending a message to the focused window only by MeEtc on 04-11-2008 at 07:40 AM

Is it possible to determine when a window is focused? If so, what you could do is store a reference to that window as it gets focused. Then just use that reference when calling your menu fuctions