EventGhost and the Windows COM

Do you have questions about writing plugins or scripts in Python? Meet the coders here.

EventGhost and the Windows COM

Postby EventGhost4ever » Sat Mar 24, 2012 10:12 pm

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.
EventGhost4ever
 
Posts: 11
Joined: Fri Oct 28, 2011 6:37 pm

Re: eg module in other python interpreter (apache mod_python

Postby Pako » Sun Mar 25, 2012 6:33 am

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
User avatar
Pako
Plugin Developer
 
Posts: 1283
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic

EventGhost and the Windows COM

Postby EventGhost4ever » Wed Mar 28, 2012 9:46 pm

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.
EventGhost4ever
 
Posts: 11
Joined: Fri Oct 28, 2011 6:37 pm

Re: EventGhost and the Windows DOM

Postby Livin » Sat Mar 31, 2012 3:24 pm

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
User avatar
Livin
Experienced User
 
Posts: 749
Joined: Wed Oct 08, 2008 4:56 am

Re: EventGhost and the Windows COM

Postby EventGhost4ever » Sun Jun 10, 2012 5:02 pm

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

Postby EventGhost4ever » Sun Jun 10, 2012 5:05 pm

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.
EventGhost4ever
 
Posts: 11
Joined: Fri Oct 28, 2011 6:37 pm


Return to Coding Corner

Who is online

Users browsing this forum: No registered users and 1 guest