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.

EventGhost and the Windows COM

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
EventGhost4ever
Posts: 11
Joined: Fri Oct 28, 2011 6:37 pm

EventGhost and the Windows COM

Post by EventGhost4ever »

Is there are possibility with the python interpreter of the apache webserver (mod_python) to access the eg module?
I want to create a webpage and if you click one button, the python interpreter of the apache webserver should call the method eg.TriggerEvent("Name").
I cannot find how an other python interpreter can access the eg module.

In advance thanks,
Stefan

Edit:
I have this topic renamed (old name: eg module in other python interpreter (apache mod_python)) , because I think, that the new name fits better to the topic.
Last edited by EventGhost4ever on Sun Jun 10, 2012 5:02 pm, edited 2 times in total.
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: eg module in other python interpreter (apache mod_python

Post by Pako »

I think that it is almost impossible or very, very difficult.
But if you only need to send event, it is also unnecessary.
You can do this in many ways. For example, as follows:

Code: Select all

from win32com.client import Dispatch
eg = Dispatch("EventGhost")
eg.TriggerEvent(u"EventFromMyApplication")
eg.TriggerEvent(u"EventWithPayload", 12345, "AnotherPrefix")
Pako
EventGhost4ever
Posts: 11
Joined: Fri Oct 28, 2011 6:37 pm

EventGhost and the Windows COM

Post by EventGhost4ever »

Thanks Pako for this great solution.
I have read, that the win32com.client uses the ComponentsObjectModel (COM) of Windows.
Does anyone know / have experience, how I can use EventGhost with C# or Java with help of the Windows COM.
Last edited by EventGhost4ever on Sun Jun 10, 2012 5:03 pm, edited 1 time in total.
User avatar
Livin
Experienced User
Posts: 792
Joined: Wed Oct 08, 2008 4:56 am

Re: EventGhost and the Windows DOM

Post by Livin »

EventGhost4ever wrote:Thanks Pako for this great solution.
I have read, that the win32com.client uses the ComponentsObjectModel (DOM) of Windows.
Does anyone know / have experience, how I can use EventGhost with C# or Java with help of the Windows DOM.
I saw you mentioned building a web page, I suspect you want to bypass the EG Webserver?

So, what are you planning to build from it? :)
setup... XBMC, W7MC for DVR & Live OTA TV, JRMC for multi-zone audio, EG, MiCasaVerde Vera3, USB-UIRT IR receiver, Harmony remote, 5.2 home theater system
EventGhost4ever
Posts: 11
Joined: Fri Oct 28, 2011 6:37 pm

Re: EventGhost and the Windows COM

Post by EventGhost4ever »

I have coded the C# version to control EventGhost through the COM.

Code: Select all

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Reflection;
using System.Diagnostics;
using System.Runtime.InteropServices.ComTypes;


namespace EventGhost
{
    class Program
    {
        static void Main(string[] args)
        {
            doAction("Action");
        }

        public static void doAction(String Action)
        {
            Type typeEventGhost = null;
            object EventGhost = null;

            typeEventGhost = Type.GetTypeFromProgID("EventGhost");
            EventGhost = Activator.CreateInstance(typeEventGhost);

            if (EventGhost != null)
            {
                typeEventGhost.InvokeMember("TriggerEvent", BindingFlags.Public | BindingFlags.InvokeMethod,
                null, EventGhost, new String[1] {Action});
            }

        }
    }
}
Last edited by EventGhost4ever on Sun Jun 10, 2012 5:08 pm, edited 1 time in total.
EventGhost4ever
Posts: 11
Joined: Fri Oct 28, 2011 6:37 pm

Re: EventGhost and the Windows COM

Post by EventGhost4ever »

For Java, it is the best if you use Jthyon and control it from your Java program to use the Windows COM to control EventGhost.
Post Reply