Page 1 of 1

Directory Watcher Plugin

Posted: Sun Apr 06, 2014 1:20 am
by pushpull
I have been trying to use this plugin to monitor a file. It is a log file for my modem that updates with an upcoming call. EventGhost see the update and it applies an event. The only problem is that the file is located in the Windows folder where there is a firewall log that updates as well. Unfortunately, this also applies the event which I do not wish to happen. How can one isolate this to just the one file that is updated and not the other? This is how the event is displayed in the tracker pane -

DirectoryWatcher.Updated (u'C:\\WINDOWS\\ModemLog_Conexant D850 56K V.9x DFVc Modem.txt',)

So you can see that this event has a specific file associated with it. Yet when it is dragged over to macro I need run it is generic in nature.

Re: Directory Watcher Plugin

Posted: Sun Apr 06, 2014 4:37 pm
by Telorast
You have to add a script where you check the filename, something like this:
if eg.event.payload == u'C:\\WINDOWS\\ModemLog_Conexant D850 56K V.9x DFVc Modem.txt' then:
[your actions]

Re: Directory Watcher Plugin

Posted: Mon Apr 07, 2014 12:55 am
by pushpull
Thanks Telorast. I looked at this a bit. As I am not a scripter I am at a disadvantage. I could not find out how I even get a script into EG. What I have figured out as to what you have written is the following -

if eg.event.payload == u'C:\\WINDOWS\\ModemLog_Conexant D850 56K V.9x DFVc Modem.txt' then:
eg.plugins.MediaMonkey.DiscretePause();

Perhaps this is wrong. I am trying to teach myself this stuff so I hope you bear with me. I have actually found another way around this but I want to understand. This isn't a pressing issue regardless. If I can figure out another way all the better I say. What I do know for me to use the above statement is that it needs to be put into a properly grammatical python script and then brought into EG where I need it. Regardless, I am mulling on it myself. Just wanted to say thanks. I have a lot going on so I squeeze this in where I can.

Re: Directory Watcher Plugin

Posted: Wed Apr 09, 2014 8:35 pm
by Telorast
The script action is at the top of the EventGhost group. Python Command for one line of code and Python Script for more.

The code looks good, the syntax in Python is based a lot on tabs so adding a tab at the start of the second line tells it that line is part of the IF statement. Every following line that also starts with a tab will also be part of it.

Often payloads comes as an array of strings, like this: event (u'payload 1', u'payload 2')
Then you have to look at the one you are interested in, so this would be payload 1: eg.event.payload[0]
But if it isn't an array then that would be the first character of the payload string. Really annoying when you want to call a function from multiple places and some send payloads as strings and others as arrays with only one element...
The event you posted is one of these where you get an array with only one element in it so you'd have to add the [0] at the end of your code.