Configuring "Display Image" to Only Display the Newest File in a Folder

Questions and comments specific to a particular plugin should go here.
Post Reply
bzowk
Posts: 1
Joined: Tue Oct 09, 2018 7:58 pm

Configuring "Display Image" to Only Display the Newest File in a Folder

Post by bzowk » Tue Jan 08, 2019 4:52 pm

Hey Guys -

I'm trying to set up EventGhost to do something fairly simple, but having an issue getting it to do so. I have a webcam configured to automatically upload an image to a folder (local to EventGhost install) whenever it detects motion. It's configured to upload no more than 1 image every 10 seconds. I am trying to set up EventGhost to monitor that folder for new files and once one appears, display it on a monitor for 2 seconds.

I set up "Directory Watcher" and got it working correctly. I then added the "Display Image" macro and have been testing with it. My issue is that you seemingly have to configure it with a static filename. The only solutions I can see for this are:
  • Finding a way to set new filename to variable when created in folder which could then be used in config of "Display Image"
  • Configure EventGhost with or without external scripting so that when an image is uploaded, it is renamed to a static filename, displayed with "Display Image", then deleted
  • Some alternate plugin or script
Although I frequently use PowerShell, unfortunately I'm not experienced with Python which it seems is what EventGhost is designed.

Any suggestions would be appreciated - Thanks!

User avatar
kgschlosser
Site Admin
Posts: 4656
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Configuring "Display Image" to Only Display the Newest File in a Folder

Post by kgschlosser » Wed Jan 09, 2019 12:43 am

who makes the camera??
brand and model
If you like the work I have been doing then feel free to Image

User avatar
topix
Experienced User
Posts: 441
Joined: Sat May 05, 2007 3:43 pm
Location: Germany
Contact:

Re: Configuring "Display Image" to Only Display the Newest File in a Folder

Post by topix » Mon Jan 14, 2019 6:06 pm

If i understand correct, i have a solution for you. Add the following two macros to your config tree:
(click on 'SELCET ALL', press Strg-c, select your config tree and press Strg-v)

Code for the "Watch Directory" macro:

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="WIP">
    <Macro Name="Watch Directory" XML_Guid="{D1673FEF-CACE-4744-A5CA-E2D53BB30D2C}" Expanded="True">
        <Event Name="DirectoryWatcher.Created" XML_Guid="{C63CC252-AEE2-4C97-9D1D-72AF66BDCEE9}" />
        <Action XML_Guid="{A7266822-C811-4AF4-B749-B864C5032E4C}">
            EventGhost.TriggerEvent(u'Webcam.DisplayImage', 0.0, u'{eg.event.payload[0]}', True, False, False)
        </Action>
    </Macro>
</EventGhost>
Code for the "Display Image" macro:

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="WIP">
    <Macro Name="Display Image" XML_Guid="{1A099881-155B-40A2-859A-AC1235648714}" Expanded="True">
        <Event Name="Main.Webcam.DisplayImage" XML_Guid="{4B77CBC4-EA02-4C6E-97B9-E46F0A2CDCDF}" />
        <Action XML_Guid="{DF31B6E9-5D91-4484-BE0A-2678D3E35A19}">
            System.DisplayImage(u'{eg.event.payload}', 2, 1, True, True, 0, True, 0, 3, 0, 0, 0, 640, 360, (130, 130, 130, 255), False, True, True, u'')
        </Action>
    </Macro>
</EventGhost>



Post Reply