Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
[SOLVED] Possibility to listen to events within a plugin?
[SOLVED] Possibility to listen to events within a plugin?
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!
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!
Last edited by Sem;colon on Thu Aug 07, 2014 9:38 pm, edited 3 times in total.
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: Possibility to listen to events within a plugin?
Yes, it is of course possible.Sem;colon wrote:Does anyone know if thatÔÇÖs possible and how to do it?
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?
I see, thank you!
How would I do it if I want to use wildcards?
something like:
eg.Bind("Process.Created.*", myFunction)
?
How would I do it if I want to use wildcards?
something like:
eg.Bind("Process.Created.*", myFunction)
?
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: Possibility to listen to events within a plugin?
This should work as you do in your example.Sem;colon wrote:How would I do it if I want to use wildcards?
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?
Are you sure? Because this example didn't work for me as I tried it...Pako wrote:This should work as you do in your example.
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: Possibility to listen to events within a plugin?
I'm sorry, you're right. It can not work.Sem;colon wrote:Are you sure? Because this example didn't work for me as I tried it...
See EventGhostEvent.py, lines 124-127.
Pako
Re: Possibility to listen to events within a plugin?
hmm, any Idea how I can accomplish that?
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: Possibility to listen to events within a plugin?
At the moment I have no idea.
You can refine your intentions?
Pako
You can refine your intentions?
Pako
Re: Possibility to listen to events within a plugin?
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..
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..
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: Possibility to listen to events within a plugin?
Yes, it is may be the right direction.Sem;colon wrote:Pako, I guess you did something similar in the Log redirector, right?
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?
That works!
thank you very much!
thank you very much!
Re: [SOLVED] Possibility to listen to events within a plugin
... 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!
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!
- Attachments
-
- Log.py
- (8.52 KiB) Downloaded 175 times
Last edited by Sem;colon on Fri Aug 08, 2014 4:55 pm, edited 1 time in total.
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: [SOLVED] Possibility to listen to events within a plugin
It appears that the original version is attached.Sem;colon wrote:I attached a modified version ...
Pako
Re: [SOLVED] Possibility to listen to events within a plugin
You're right, looks like a uploaded the wrong file - I corrected it!
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: [SOLVED] Possibility to listen to events within a plugin
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
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
