Page 1 of 1

EventGhost and the Windows COM

Posted: Sat Mar 24, 2012 10:12 pm
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.

Re: eg module in other python interpreter (apache mod_python

Posted: Sun Mar 25, 2012 6:33 am
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

EventGhost and the Windows COM

Posted: Wed Mar 28, 2012 9:46 pm
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.

Re: EventGhost and the Windows DOM

Posted: Sat Mar 31, 2012 3:24 pm
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? :)

Re: EventGhost and the Windows COM

Posted: Sun Jun 10, 2012 5:02 pm
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});
            }

        }
    }
}

Re: EventGhost and the Windows COM

Posted: Sun Jun 10, 2012 5:05 pm
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.