Page 1 of 2

[SOLVED] Possibility to listen to events within a plugin?

Posted: Thu Jul 24, 2014 9:57 am
by Sem;colon
Hello,

What IÔÇÖm trying to do is to listen for some specific events in the EventGhost log and trigger actions, just like the default macros in EventGhost but from within a plugin.

Does anyone know if thatÔÇÖs possible and how to do it?

Thank you!

Re: Possibility to listen to events within a plugin?

Posted: Thu Jul 24, 2014 10:29 am
by Pako
Sem;colon wrote:Does anyone know if thatÔÇÖs possible and how to do it?
Yes, it is of course possible.
You can look for example at MediaPlayerClassic plugin, how it's done.
Search for keywords eg.Bind and eg.Unbind.
Pay particular attention to the return value of "True" !

Pako

Re: Possibility to listen to events within a plugin?

Posted: Thu Jul 24, 2014 12:59 pm
by Sem;colon
I see, thank you!

How would I do it if I want to use wildcards?

something like:
eg.Bind("Process.Created.*", myFunction)
?

Re: Possibility to listen to events within a plugin?

Posted: Thu Jul 24, 2014 1:34 pm
by Pako
Sem;colon wrote:How would I do it if I want to use wildcards?
This should work as you do in your example.
But be careful, do not forget, that the wildcard can only be used as a prefix or as a second suffix (as you do in your example).

Pako

Re: Possibility to listen to events within a plugin?

Posted: Thu Jul 24, 2014 2:45 pm
by Sem;colon
Pako wrote:This should work as you do in your example.
Are you sure? Because this example didn't work for me as I tried it...

Re: Possibility to listen to events within a plugin?

Posted: Thu Jul 24, 2014 3:44 pm
by Pako
Sem;colon wrote:Are you sure? Because this example didn't work for me as I tried it...
I'm sorry, you're right. It can not work.
See EventGhostEvent.py, lines 124-127.

Pako

Re: Possibility to listen to events within a plugin?

Posted: Thu Jul 24, 2014 5:59 pm
by Sem;colon
hmm, any Idea how I can accomplish that?

Re: Possibility to listen to events within a plugin?

Posted: Fri Jul 25, 2014 5:15 am
by Pako
At the moment I have no idea.
You can refine your intentions?

Pako

Re: Possibility to listen to events within a plugin?

Posted: Fri Jul 25, 2014 1:38 pm
by Sem;colon
Sure,

What I'm trying to do is to write a plugin that forwards events from one Eventghost to another one with the possibility to set a filter e.g. only events with a specific Prefix.

Pako, I guess you did something similar in the Log redirector, right?
I was trying to find how you did it, but it's really hard to find if you don't know exactly what you are looking for..

Re: Possibility to listen to events within a plugin?

Posted: Fri Jul 25, 2014 3:58 pm
by Pako
Sem;colon wrote:Pako, I guess you did something similar in the Log redirector, right?
Yes, it is may be the right direction.
Earlier it was done differently (I think LogRedirector), but when phlox did EventGhost Application Control Plugin, it had to be changed.
The key word is eg.log.AddLogListener and the function, that you need is a WriteLine.
I think it will be good to read topic EventGhost Application Control Plugin.

Pako

Re: Possibility to listen to events within a plugin?

Posted: Sat Jul 26, 2014 12:20 pm
by Sem;colon
That works!
thank you very much! :)

Re: [SOLVED] Possibility to listen to events within a plugin

Posted: Thu Aug 07, 2014 9:11 pm
by Sem;colon
... I have to recall the SOLVED, as I noticed that it's sill not doing what I want it to.

I can get now the "event" like it is displayed in the log but I can't really work with the payload as comes as string along with the other parts of the event.
So at the moment I can only forward the event string, that's not what I wanted..

Anyway, I took a look at the Log class in EventGhost and realised that this is not very difficult to get when just extending that class a bit.
I attached a modified version of that class where I added an "eventListener" in addition to the "logListener".

This could probably be useful to others as well!

Re: [SOLVED] Possibility to listen to events within a plugin

Posted: Fri Aug 08, 2014 4:39 am
by Pako
Sem;colon wrote:I attached a modified version ...
It appears that the original version is attached.

Pako

Re: [SOLVED] Possibility to listen to events within a plugin

Posted: Fri Aug 08, 2014 4:56 pm
by Sem;colon
You're right, looks like a uploaded the wrong file - I corrected it!

Re: [SOLVED] Possibility to listen to events within a plugin

Posted: Sun Aug 10, 2014 5:18 am
by Pako
Hi Sem;colon !
I looked at your solution. I have to admit, I do not get it.
How should it work?
To me it seems that the payload you get exactly the same way as before.

BTW:
Yesterday I was on a family outing. We went early and came back late.
We were in Dresden. We do not have it too far (about 110 Km).

Pako