Timer in a plug-in - 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: Timer in a plug-in (/showthread.php?tid=54138) Timer in a plug-in by Itsme-HcK on 12-21-2005 at 12:48 PM My plug-in needs to set some things every 30 seconds. Is there a good way to do it, or should I call an external program from my DLL? RE: Timer in a plug-in by (CyBeRDuDe) on 12-21-2005 at 01:22 PM
In VB I guess? RE: Timer in a plug-in by RaceProUK on 12-21-2005 at 02:07 PM If you're working in C++, then let me know, and I'll knock up an example for that. RE: Timer in a plug-in by Itsme-HcK on 12-21-2005 at 10:03 PM
* Itsme-HcK lets raceprouk now. RE: Timer in a plug-in by RaceProUK on 12-22-2005 at 11:11 AM
To start the timer: RE: Timer in a plug-in by Itsme-HcK on 12-22-2005 at 01:45 PM That will make my plug-in run all the time, while it is only supposed to be called once in the <number> minutes... RE: Timer in a plug-in by RaceProUK on 12-22-2005 at 04:12 PM
void CALLBACK TimerProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) RE: Timer in a plug-in by Itsme-HcK on 12-22-2005 at 07:50 PM
Err, read what I said again. RE: Timer in a plug-in by RaceProUK on 12-22-2005 at 08:22 PM If you put KillTimer() in the TimerProc(), the TimerProc() will only be called once. RE: Timer in a plug-in by J-Thread on 12-23-2005 at 12:25 AM
I don't know what you're trying to say... Off course your plugin is running all the time...that's usual for plugins... RE: Timer in a plug-in by CookieRevised on 12-23-2005 at 12:44 AM
quote:Your plugin (or at least a process of your plugin) will indeed always run. There is no way around in (in whatever language) as that is exactly what a timer does; it constantly needs a process to run, the process of the timer (what the timer process calls when it fires is another matter, that process doesn't need to be run all the time)... Calling an external DLL for this is not better. True, you could do that, but even then a process needs to be running all the time. So why call an external process (with all the disadvantgaes of syncronization, or detecting when it needs to end, or whatever) while you can do this from your plugin itself (with the advantage that you have far less troubles, if not none, with syncronizations, etc), and above all, it already runs all time anyways... quote:you parse messages (or whatever you want) in the TimerProc. TimerProc is only fired/called when a timeout occurs. EDIT: damn, J-Thread was first (I always say refresh a thread before replying, but I often forget to do that also) RE: Timer in a plug-in by Itsme-HcK on 12-23-2005 at 01:45 PM
Oh my. RE: RE: Timer in a plug-in by CookieRevised on 12-23-2005 at 03:00 PM
quote:we do... and your question has been answered several times though. quote:The TimerProc is a callback-function, an assyncronical function, just as events are, it is executed when a timeout occurs. If you have programmed something which takes all the idle time (aka processing power) of the CPU so events, callbacks, etc can't be executed, you actually entirly lock out (hang) the program which calls you DLL and maybe even Windows itself and nothing will run anymore, meaning your code is bad to start with. Did you read and fully understand the link raceprouk has given? Timers on MSDN RE: Timer in a plug-in by Itsme-HcK on 12-23-2005 at 03:26 PM Does MsgPlus parse my msg's too, then? RE: Timer in a plug-in by CookieRevised on 12-23-2005 at 04:16 PM
depends on what you actually want and what you mean by "messages". RE: Timer in a plug-in by RaceProUK on 12-23-2005 at 06:01 PM
quote:We do read, as Cookie said, and until now you hadn't explained what you were talking about. In fact, yous till haven't explained everything fully: what's this 'first function'? RE: Timer in a plug-in by Itsme-HcK on 12-23-2005 at 06:45 PM
Gah, ok. RE: Timer in a plug-in by matty on 12-23-2005 at 06:48 PM
quote:I don't know about the rest of you but that makes absolutley no sense to me. Are you trying to say you want a timer on your form to run so that your function is constantly called? RE: Timer in a plug-in by (CyBeRDuDe) on 12-23-2005 at 08:09 PM
What I can understand from the last post of Itsme-Hck: RE: Timer in a plug-in by Itsme-HcK on 12-23-2005 at 08:23 PM
Maybe I should try #winprog. RE: Timer in a plug-in by J-Thread on 12-23-2005 at 09:00 PM
What messages? RE: Timer in a plug-in by ShawnZ on 12-23-2005 at 09:13 PM
quote: 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) RE: Timer in a plug-in by (CyBeRDuDe) on 12-23-2005 at 10:17 PM
quote: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! RE: Timer in a plug-in by Itsme-HcK on 12-24-2005 at 08:57 AM
Gah, but the Windows messages need to be parsed before my function gets called. MsgPlus! would, logically, only parse its own messages, not mine. RE: Timer in a plug-in by RaceProUK on 12-24-2005 at 11:26 AM
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! RE: Timer in a plug-in by Itsme-HcK on 12-24-2005 at 06:03 PM
Then why the hell didn't you just SAY SO? RE: RE: Timer in a plug-in by CookieRevised on 12-24-2005 at 09:00 PM
quote: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: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: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: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... It is clearly explained and shown on the MSDN library help page for timers, linked to by raceprouk. quote:and there is even a full working examples given. RE: Timer in a plug-in by JohnyWalker on 12-27-2005 at 09:32 PM
I created timer function without much problem using the VB.Net sample. RE: Timer in a plug-in by J-Thread on 12-27-2005 at 09:45 PM 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... RE: Timer in a plug-in by CookieRevised on 12-28-2005 at 06:17 AM
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... |