Shoutbox

Away Message - Help or Suggestions Please - 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)
+----- Forum: Plug-Ins (/forumdisplay.php?fid=28)
+------ Thread: Away Message - Help or Suggestions Please (/showthread.php?tid=46022)

Away Message - Help or Suggestions Please by XM4ST3RX on 06-09-2005 at 11:05 AM

Hi,

I'm currently developing a plug-in and its almost complete, yet im at the part which hurts most :P, the plus! part... i have least knowledge in plus api etc at the moment.

My plugin allows users to add process files and an away message for each of them.

Example:
Process: hl.exe
AwayMsg: Sorry i may not reply, im currently playing Counter-Strike!!


Im currently having problems being able to send the "/away [AwayMsg]" command... any ideas?



Kind Regards,
XM4ST3RX


RE: Away Message - Help or Suggestions Please by Mnjul on 06-09-2005 at 11:20 AM

This idea may work. If you need actual codes, just post :p

This involves using Messenger API. Consult Messenger API help for related functions and how to add reference to Messenger API in C++ or Visual Basic. (Messenger API is included in Patchou's plug-in development zipfile)

This following applies for C++.

  1. Retrieve IMessenger3 interface from iMessengerObj in Plus!'s plug-in Initialize() function.
  2. When the event is fired, use IMessenger3's InstantMessage method and open a conversation window to a random contact (note: if the contact is not on your allow list, this will fail.).
  3. Use the ppMWindow in InstantMessage: Get ppMWindow's hWnd (ppMWindow's a IDispatch which you can use to retrieve IMessengerWindow, and then use get_HWND method), and use SetForegroundWindow to make it the foreground window.
  4. Now, use SendInput or keybd_event or even SendMessage to emulate keyboard input of "/away [message]". Don't forget to send Enter input.
  5. Close ppMWindow using its Close method.

And this is for VB.
  1. Get a MessengerAPI.Messenger from oMessenger in Plus!'s plug-in Initialize() function.
  2. When the event is fired, use MessengerAPI.Messenger's InstantMessage method and open a conversation window to a random contact (note: if the contact is not on your allow list, this will fail.).
  3. Use the the return value (a MessengerAPI.MessengerWindow) of InstantMessage: Get its HWnd property, and use SetForegroundWindow API to make it the foreground window.
  4. Now, use SendKeys or even SendMessage API to emulate keyboard input of "/away [message]". Don't forget to send Enter input.
  5. Close the conversation window using its Close method.

A little bit complicated, but that's what I can think of for now. Just give it a try if you want ;)
RE: Away Message - Help or Suggestions Please by XM4ST3RX on 06-09-2005 at 11:21 AM

Hi,

im using Visual Basic, and yeah if you could post code to help me out that would be great (Y)


Kind Regards,
XM4ST3RX


RE: Away Message - Help or Suggestions Please by Millenium_edition on 06-09-2005 at 11:22 AM

you could use tags, like (!XPROCESS), (!XWINDOW), but i'm not sure wether plus parses the tags when the away-message is set or when it is sent.


RE: Away Message - Help or Suggestions Please by XM4ST3RX on 06-09-2005 at 11:25 AM

Hi,

quote:
Originally posted by Millenium_edition
you could use tags, like (!XPROCESS), (!XWINDOW), but i'm not sure wether plus parses the tags when the away-message is set or when it is sent.

I need to be able to just send this info direct, i.e. from a command button on a form etc


Kind Regards,
XM4ST3RX

RE: Away Message - Help or Suggestions Please by Mnjul on 06-09-2005 at 11:33 AM

XM4ST3RX, I've updated my post. :)

My idea is very rough and just post if you need more help ;)


RE: Away Message - Help or Suggestions Please by XM4ST3RX on 06-09-2005 at 11:35 AM

Hi,

im very new with the plugin side of things... could you collaborate more on the step 1 please, "Get a MessengerAPI.Messenger from oMessenger in Plus!'s plug-in Initialize() function." :P, Thanks (Y).


Kind Regards,
XM4ST3RX


RE: Away Message - Help or Suggestions Please by Mnjul on 06-09-2005 at 11:48 AM

First of all, you need to do this:

quote:
Originally from MessengerAPI Helpfile
To add the Messenger type libraries to a Visual Basic project:

In Visual Basic, create a new project or open an existing one. (This is required to display all menus.)
On the Project menu, click References.
In the References dialog box, check Messenger API Type Library in the list, and then click OK.



After this is done, you can declare a global variable like
code:
Public MessengerInstance As MessengerAPI.Messenger


Then, in Plus! plug-in Initiailize function, use:
code:
Public Function Initialize(ByVal nVersion As Long, ByVal sUserEmail As String, ByVal oMessenger As Object) As Boolean
    Set MessengerInstance = oMessenger 'This retrieves the Messenger object from Plus!
    'If any, add your custom Initiailize() codes
    Initiailize = True
End Function

If you want, you can add Set MessengerInstance = Nothing before setting it to oMessenger. But this is not obligatory.

That's what I mean in step 1 ;)
RE: Away Message - Help or Suggestions Please by XM4ST3RX on 06-09-2005 at 11:56 AM

Hi,

I love you! LoL, everything is going swell so far... just need to know how i can randomly choose a contact when using the InstantMessage method :P


Kind Regards,
XM4ST3RX


RE: Away Message - Help or Suggestions Please by Mnjul on 06-09-2005 at 12:13 PM

(Please be sure you have MessengerAPI help or you may not be going to understand what I'm talking about :P)

Well, since you've got the Messenger object, you can use its MyContacts property, which is a MessengerContacts object and is a collection of contacts in the user's contact list. It has a method called Item(Index) which returns a MessengerContact. This object can be used in Messenger object's InstantMessage method.

So it may go like...

code:
Dim Counter As Long
Dim Contacts As MessengerAPI.IMessengerContacts
Dim Contact As MessengerAPI.IMessengerContact

Set Contacts = MessengerInstance.MyContacts

For Counter = 1 To Contacts.Count '(*)

   Set Contact = Contacts.Item(Counter)

   If Contact.Blocked = False Then

      'From here use MessengerInstance's InstantMessage method in step 2, and go on

      Exit For 'We can exit the loop because a "valid" contact has been found

   End If

Next 'It's up to you if you prefer "Next Counter" :p

(*)Note I forgot Item method's "Index" is 0-based or 1-based...Please try on your own. If it's 0-based, the For statmenet should change to For Counter = 0 To Contacts.Count - 1

You may want to do some check (to see if any window has been created in the loop) after the For loop. :)
RE: Away Message - Help or Suggestions Please by XM4ST3RX on 06-09-2005 at 12:17 PM

Hi,

Error with "MessengerAPI.MessengerContacts"... user-type not defined.

Also when i used the MessengerInstance.InstantMessage("Contact@hotmail.com"), the convo didnt open... the MessengerInstance object is all set correctly

edit: i fixed the first MessengerAPI.MessengerContacts by changing it to MessengerAPI.IMessengerContacts.

Kind Regards,
XM4ST3RX


RE: Away Message - Help or Suggestions Please by Mnjul on 06-09-2005 at 12:23 PM

quote:
Originally posted by XM4ST3RX
Error with "MessengerAPI.MessengerContacts"... user-type not defined.
OH my gosh, it should be MessengerAPI.IMessengerContacts.

As for the convo-not-open problem, I'll need to take some look... perhaps you can try using MessengerAPI.IMessengerContact as the parameter vContact? :)
RE: Away Message - Help or Suggestions Please by XM4ST3RX on 06-09-2005 at 12:32 PM

Hi,

Do you have any idea that when i use MessengerAPI., all the functions are there twice... so when i try and use one, i get an "Ambiguous name detected" error?


Kind Regards,
XM4ST3RX


RE: Away Message - Help or Suggestions Please by Mnjul on 06-09-2005 at 12:39 PM

That's strange... I don't know what's going on :( Make sure your Reference is set correctly. Restart Visual Basic may help too ...:)


RE: Away Message - Help or Suggestions Please by XM4ST3RX on 06-09-2005 at 12:43 PM

Hi,

Ive got the open convo working, and sorted most of it out... just trying to get this loop correct to open a contact which isnt blocked etc....

are you sure the user doesnt need to be on contact list, as i made it open a contact with "ok@hotmail.com", which i dont have on my list... and i could type "/away blah", and it worked?


Kind Regards,
XM4ST3RX


RE: Away Message - Help or Suggestions Please by Mnjul on 06-09-2005 at 12:48 PM

I'm sorry that I didn't make it clear: when I said "random contact", I meant a random contact from the user's contact list. :)

Well, if "All others" is in "Allow list" in "Tools\Options -> Privacy", then, a random contact, such as ok@hotmail.com is OK too. :) The reason why you need a contact in Allow List is that, only when you are talking to someone on your allow list, the "Enter your message here" textbox is enabled and can accept keyboard input.

P.s. there might be a way to retrieve the actual "Allow List" rather than the user's Contact List, but I don't know how :(


RE: Away Message - Help or Suggestions Please by XM4ST3RX on 06-09-2005 at 12:54 PM

Hi,

ok, thanks for your help you've been really helpful! (Y)
Thanks!!


Kind Regards,
XM4ST3RX


RE: Away Message - Help or Suggestions Please by Yousef on 06-09-2005 at 02:34 PM

wouldn't it be better to just use SetNewName("name... {status}"), instead of opening the convo window etc?


RE: Away Message - Help or Suggestions Please by Mnjul on 06-09-2005 at 02:38 PM

quote:
Originally posted by Juzzi
wouldn't it be better to just use SetNewName("name... {status}"), instead of opening the convo window etc?
XM4ST3RX wants to set Away Messages (for auto responding), not the name suffix tag... :)
RE: RE: Away Message - Help or Suggestions Please by Yousef on 06-09-2005 at 02:42 PM

quote:
Originally posted by Mnjul
quote:
Originally posted by Juzzi
wouldn't it be better to just use SetNewName("name... {status}"), instead of opening the convo window etc?
XM4ST3RX wants to set Away Messages (for auto responding), not the name suffix tag... :)

Ah alright, I'm sorry :)
Where does MsgPlus store this info? In the registry? There must be some option that doesn't involve opening/closing windows :)
Edit: Of course not, I'm mixing all Plus! features up, lol. I thought about the user-comeback message, which is, again, something completely differrent :p