What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Plug-Ins » Timer in a plug-in

Pages: (3): « First « 1 2 [ 3 ] Last »
Timer in a plug-in
Author: Message:
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
Joined: Jul 2004
RE: Timer in a plug-in
What messages?

Are you trying to say you want to send a message to the other user every 30 seconds or so?

About the active plugin, when you use a timer, you should start that in the sign-in event (see the Messenger API for that) and off course kill it in the sign-out event. Your callback function will be called every 30 seconds, so then  your plugin is active. If you want to send a message to all users you have to find the input box and use API calls (sendchar or something like that) to send the text....

Is this an answer to your question?
12-23-2005 09:00 PM
Profile E-Mail PM Find Quote Report
ShawnZ
Veteran Member
*****

Avatar

Posts: 3146
Reputation: 43
32 / Male / Flag
Joined: Jan 2003
RE: Timer in a plug-in
quote:
Originally posted by Itsme-HcK
Maybe I should try #winprog. :P
Of course, the plug-in runs the whole time, but it is not active.
There is no main function or such, it is only activated when MsgPlus calls a function.
To use Windows timers, you need to be active all the time, and it's not.
So, only if MsgPlus! parses the messages from the DLL, it can be used.
My simple question: Does it?

wtf are you on about...

Your plugin gets one of its functions called by msgplus (from within msn messenger) and then it starts a timer (again in msn messenger) and then that timer gets called (in msn messenger....) and the callback function (inserted into msn messenger) is run (from within msn messenger)

8-)
Spoiler:
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
12-23-2005 09:13 PM
Profile PM Web Find Quote Report
(CyBeRDuDe)
Senior Member
****


Posts: 512
Reputation: 21
38 / Male / –
Joined: Jul 2003
RE: Timer in a plug-in
quote:
Originally posted by Itsme-HcK
Maybe I should try #winprog. :P
Of course, the plug-in runs the whole time, but it is not active.
There is no main function or such, it is only activated when MsgPlus calls a function.
To use Windows timers, you need to be active all the time, and it's not.
So, only if MsgPlus! parses the messages from the DLL, it can be used.
My simple question: Does it?
When using Windows timers/the timer code from raceprouk, your dll/functions/whatever you are on about, doesn't need to active all the time... When you have called the UINT TimerID function, the timer runs! No matter if your dll/form/function is active or not! The timer runs, and runs, and runs! Nothing more, nothing less...
Setting the number of ms in the timer event, adjusts how often the CallBack function is called... If time in ms is 1000, the callback funtion will be called 1 time every second... And still No matter if your dll/form/or whatever is active!
12-23-2005 10:17 PM
Profile E-Mail PM Find Quote Report
Itsme-HcK
Junior Member
**

Avatar
Geek

Posts: 45
33 / Male / –
Joined: Nov 2005
O.P. RE: Timer in a plug-in
Gah, but the Windows messages need to be parsed before my function gets called. MsgPlus! would, logically, only parse its own messages, not mine.
Never mind anyways, you appearantly didn't read MSDN about messages. ;)
I'll ask in #C++ or so. :)
12-24-2005 08:57 AM
Profile E-Mail PM Web Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: Timer in a plug-in
Excuse me, but we do all read MSDN. I myself have written several WndProcs and a message loop or two. Hell, I linked you to MSDN! And the timer code I gave you bypasses all the message processing crap!

If you're worried about a message loop, don't be. So long as you call SetTimer() in the same thread as Initialize(), Messenger's own message loop will handle dispatching the timer messages.

Edit: I know Cookie, which is why I said the same thread as Initialize() :P

This post was edited on 12-30-2005 at 01:18 PM by RaceProUK.
[Image: spartaafk.png]
12-24-2005 11:26 AM
Profile PM Web Find Quote Report
Itsme-HcK
Junior Member
**

Avatar
Geek

Posts: 45
33 / Male / –
Joined: Nov 2005
O.P. RE: Timer in a plug-in
Then why the hell didn't you just SAY SO? :|
Howevers, then that's it. :)
Thank y00, for as far as it did come. :P

This post was edited on 12-24-2005 at 06:10 PM by Itsme-HcK.
12-24-2005 06:03 PM
Profile E-Mail PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: RE: Timer in a plug-in
quote:
Originally posted by raceprouk
If you're worried about a message loop, don't be. So long as you call SetTimer() in the same thread as Initialize(), Messenger's own message loop will handle dispatching the timer messages.
For that it doesn't nessecairly need to be in the Initialize() function though. You can put it in whatever procedure, as long as SetTimer() is executed somewhere within the plugin (and TimerProc() is available to the outside world)...

(eg: if you want to start the timer only when a command is parsed, you only need to put it in the ParseCommand() function).

quote:
Originally posted by Itsme-HcK
Added to this queue are also clicks with the mouse, actions, menu's, the whole crap. You have to parse those messages, so you can handle them. So, when you do that, the timer function will be called, resulting in a call to my function.
You are confusing stuff and making it harder than it is. You do not need to parse any windows messages (unless you're in your own dialog screen or are subclassing or whatever). Windows messages are almost always handled by the owners, in this case that would be Messenger itself. In case for a timer countdown, that is handled by Windows if you use a callback function.

All can be found in the MSDN Library. (Or if you only had tried out Raceprouk's example in his very first reply)

quote:
Originally posted by Itsme-HcK
But, if the user doesn't send messages to buddies for say, 15 minutes, my plug-in isn't called the whole time. So isn't my function.
It is your function, as it is a callback function which you have set as a parameter when you set the timer.

Timer messages are handled by Windows when you use a callback function, as you can read on the MSDN pages, and when they trigger they call that given function in your program back (hence callback function).

quote:
Originally posted by Itsme-HcK
Then why the hell didn't you just SAY SO? :|
Howevers, then that's it. :)
Thank y00, for as far as it did come. :P
tbh, everything was already said from the very first replies, then it got a bit vague (because you didn't say what you meant with "messages" and it is so inlogical that you meant windows messages), but after that, again the people already said all this in their replies... :S

It is clearly explained and shown on the MSDN library help page for timers, linked to by raceprouk.
quote:
An application can process WM_TIMER messages by including a WM_TIMER case statement in the window procedure or by specifying a TimerProc callback function when creating the timer. When you specify a TimerProc callback function, the default window procedure calls the callback function when it processes WM_TIMER.
and there is even a full working examples given.

This post was edited on 12-24-2005 at 09:22 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
12-24-2005 09:00 PM
Profile PM Find Quote Report
JohnyWalker
New Member
*


Posts: 1
Joined: Dec 2005
Cool  RE: Timer in a plug-in
I created timer function without much problem using the VB.Net sample.

Declare a timer object for the class as below
Dim _Timer As System.Timers.Timer

In the Initialize function, add

Try
            _Timer = New System.Timers.Timer(30000)
            AddHandler _Timer.Elapsed, AddressOf OnTimedEvent
            _Timer.Start()
        Catch ex As Exception
            LogError(ex.Message.ToString())
        End Try

        Initialize = True



LogError just writes to a text file

Add the Timer event(callback function)


Public Sub OnTimedEvent(ByVal source As Object, ByVal e As System.Timers.ElapsedEventArgs)
        '_Timer.Stop()
        LogError("Timer Event")
        DisplayToast("Hello World", "Plus Test", "http://www.google.com", True)
    End Sub


It works great. I am getting the "Timer Event" message in the log file every 30 seconds.

Now for my problem, DisplayToast does not work. If I put it in the Initialize function, it works. Can someone please explain ?

Thanks
12-27-2005 09:32 PM
Profile E-Mail PM Find Quote Report
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
Joined: Jul 2004
RE: Timer in a plug-in
Because the timer is (probably) in another thread, and MSG Plus! only accepts logs and toasts from the main thread. You will have to use delegates for it, Jedimark has written something about that in the past here...
12-27-2005 09:45 PM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Timer in a plug-in
Or simply create a window somewhere from one of the main plus! functions (thus this will be in the same thread) and when you create the timer, give the handle of that window to it. You don't need the callback function either...

all explained in MSDN... SetTimer()
.-= A 'frrrrrrrituurrr' for Wacky =-.
12-28-2005 06:17 AM
Profile PM Find Quote Report
Pages: (3): « First « 1 2 [ 3 ] 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