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.

SendMessage: Grundsatzfrage zur Vorgehensweise

Allgemeines zum Thema EventGhost
Post Reply
Nuts
Posts: 26
Joined: Tue Oct 07, 2008 11:32 am

SendMessage: Grundsatzfrage zur Vorgehensweise

Post by Nuts »

Hey,

ich suche gerade nach eine M├Âglichkeit Eventghost mit einem selbst geschriebenen Programm kommunizieren zu lassen.
Über den Befehl Sendmessage & WM_Command sollte das hinzukriegen sein, nur es gibt noch ein paar Verständnisschwierigkeiten. :(

Grundsätzlich habe ich es so verstanden (ich nehme an die Eventghostumsetzung ist entsprechend?):
wParam (Dword-Wert) setzt sich zusammen aus dem low-word -> ID des Controls, dass die Message erzeugt (hier Eventghost?) und dem high-word -> die entsprechende Nachricht.
Im Befehl wird der einzugebene Wert sich wohl nur auf die Nachricht beziehen, spricht das high-word darstellen?

lParam m├╝sste das handle des Controls angeben, dass die Nachricht abschickt. Hier also wieder Eventghost? Wird das ben├Âtigt um ggf. Fremdprogramme antworten zu lassen, kann man aber doch eigentlich weglassen?

Was ich vermisse, ist eine Angabe an welches Fenster die Nachricht geschickt werden soll. Derzeit erhalte ich nur Infos, wenn mein Prog. im Vordergrund ist. Ist nat├╝rlich nicht so sch├Ân :(

Bleibt also die Frage, wie man definiert an wen die Nachricht gehen soll.
Der n├ñchste Schritt w├ñre ein Eventghost-Plugin, k├Ânnt ihr mir ein einfaches Plugin nennen, dass die Sendmessage API verwendet?

Gruß Nuts

P.S. Wenn ich die Sache falsch angehe wäre ein Schubs in die richtige Richtung wünschenswert. :wink:
Milbrot
Plugin Developer
Posts: 79
Joined: Wed Mar 29, 2006 11:07 am

Re: SendMessage: Grundsatzfrage zur Vorgehensweise

Post by Milbrot »

Schau dir mal das MediaPlayerClassic Plugin an dort wird Sendmessage verwendet.

Gruß Milbrot
Nuts
Posts: 26
Joined: Tue Oct 07, 2008 11:32 am

Re: SendMessage: Grundsatzfrage zur Vorgehensweise

Post by Nuts »

Hey,
danke f├╝r die Antwort.

Uiui die Syntax ist schon seltsam wenn man Autoit gew├Âhnt ist. :shock:
Habe mal etwas im MediaPlayerClassic Plugin gew├╝hlt und folgende Zeilen gefunden

Code: Select all

class ActionPrototype(eg.ActionClass):
    
    def __call__(self):
        try:
            hWnd = FindWindow("MediaPlayerClassicW")
            return SendMessageTimeout(hWnd, WM_COMMAND, self.value, 0)
        except:
            raise self.Exceptions.ProgramNotRunning
Im Eventghost eigenen Befehl Sendmessage gibt es keine M├Âglichkeit das Empfangsfenster (hwnd) zu hinterlegen?

Gruß Nuts
Milbrot
Plugin Developer
Posts: 79
Joined: Wed Mar 29, 2006 11:07 am

Re: SendMessage: Grundsatzfrage zur Vorgehensweise

Post by Milbrot »

Du brauchst noch FindWindow. Hier mal ein Beispiel f├╝r die Play Funktion des MediaPlayerClassic als xml Datei f├╝r EG.

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Name="Konfigurations-Baum" Expanded="True" Version="1030" Guid="{ED7EEA1D-DFFA-4E4D-847D-330239105CD2}" Time="1252160212.34">
    <Autostart Name="Autostart" Expanded="True" />
    <Folder Name="Media Player Classic" Expanded="True">
        <Macro Name="Play" Expanded="True">
            <Action>
                Window.FindWindow(u'mplayerc.exe', None, None, None, None, None, False, 0.0, 0)
            </Action>
            <Action>
                Window.SendMessage(273, 887, 0, 0)
            </Action>
        </Macro>
    </Folder>
</EventGhost>
Nuts
Posts: 26
Joined: Tue Oct 07, 2008 11:32 am

Re: SendMessage: Grundsatzfrage zur Vorgehensweise

Post by Nuts »

Aha - damit lässt sich doch arbeiten :)

Edit \
Ok das haut hin, der Befehl wird sauber erkannt. :D
Vielen Dank!

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Name="Konfigurations-Baum" Expanded="True" Version="1194" Guid="{6B84A18B-CE32-42D2-90CD-8FD2F45E83A1}" Time="1252163379.3">
    <Autostart Name="Autostart" Expanded="True">
        <Plugin File="Keyboard" Identifier="Keyboard">
            gAIpLg==
        </Plugin>
    </Autostart>
    <Folder Name="Media Player Classic" Expanded="True">
        <Macro Name="Play" Expanded="True">
            <Event Name="Keyboard.Y" />
            <Action>
                Window.FindWindow(None, u'Nuts', None, None, None, None, False, 0.0, 0)
            </Action>
            <Action>
                Window.SendMessage(273, 887, 0, 0)
            </Action>
        </Macro>
    </Folder>
</EventGhost>
Vielleicht hat jemand Lust ein kurzes PluginBeispiel f├╝r diese Befehle zu Posten? Python schafft mich irgendwie :(
Last edited by Nuts on Tue Sep 08, 2009 12:28 pm, edited 1 time in total.
Nuts
Posts: 26
Joined: Tue Oct 07, 2008 11:32 am

Re: SendMessage: Grundsatzfrage zur Vorgehensweise

Post by Nuts »

Hey

mit dem Plugin klappts leider noch nicht so richtig.
Habe das MPC Plugin umgebaut auf:

Code: Select all


eg.RegisterPlugin(
    name = "Nuts",
    author = "Nuts",
    version = "1.0.",
    kind = "program",
    createMacrosOnAdd = True,
)

ACTIONS = (
(eg.ActionGroup, 'GroupMainControls', 'Main controls', None, (
    ('Exit', 'Quit Application', None, 100),
    ('PlayPause', 'Play/Pause', None, 110),
    ('Play', 'Play', None, 120),
)),
)

from eg.WinApi import FindWindow, SendMessageTimeout, WM_COMMAND


class ActionPrototype(eg.ActionClass):
    
    def __call__(self):
        try:
            hWnd = FindWindow("Nuts")
            return SendMessageTimeout(hWnd, WM_COMMAND, self.value, 0)
        except:
            raise self.Exceptions.ProgramNotRunning
    


class Nuts(eg.PluginClass):

    def __init__(self):
        self.AddActionsFromList(ACTIONS, ActionPrototype)
Jetzt wird, sobald ich ein Makro aufrufen will, als Fehlermeldung ausgegeben: "Programm ist nicht gestartet"
In welcher Zeile wird das denn ├╝berhaupt gepr├╝ft?
Das Fenstertitel meines Prog. heisst "Nuts" und der Prozess nuts.exe
Milbrot
Plugin Developer
Posts: 79
Joined: Wed Mar 29, 2006 11:07 am

Re: SendMessage: Grundsatzfrage zur Vorgehensweise

Post by Milbrot »

FindWindow l├Âst diese Meldung aus. Das Fenster deines Programmes wird anscheinend nicht gefunden.
Nuts
Posts: 26
Joined: Tue Oct 07, 2008 11:32 am

Re: SendMessage: Grundsatzfrage zur Vorgehensweise

Post by Nuts »

Hm also da liegt der Hund begraben. Ist schon seltsam:

Im Plugin:

Code: Select all

class ActionPrototype(eg.ActionClass):
    
    def __call__(self):
        try:
            hWnd = FindWindow(None, u'nuts', None, None, None, None, False, 0.0, 0)
            return SendMessageTimeout(hWnd, WM_COMMAND, self.value, 0)
        except:
            raise self.Exceptions.ProgramNotRunning
Aus der .xml von Eventghost mit hinzugef├╝gtem Befehl Findwindo & Sendmassage

Code: Select all

            <Action>
                Window.FindWindow(None, u'nuts', None, None, None, None, False, 0.0, 0)
            </Action>
            <Action>
                Window.SendMessage(273, 887, 0, 0)
Als Einzelbefehl klappts und die Events werden in meinem Prog. auch abgefangen.
Im Plugin wird weiterhin darauf verwiesen, dass das Programm nicht gestartet ist.
Nuts
Posts: 26
Joined: Tue Oct 07, 2008 11:32 am

Re: SendMessage: Grundsatzfrage zur Vorgehensweise

Post by Nuts »

Bin leider noch nicht weitergekommen. :(

Als Befehl wird das Fenster gefunden, als Plugin nicht. :?

edit\ Habe mal das Autoit Testprogramm angehängt (Source & exe).
You do not have the required permissions to view the files attached to this post.
Milbrot
Plugin Developer
Posts: 79
Joined: Wed Mar 29, 2006 11:07 am

Re: SendMessage: Grundsatzfrage zur Vorgehensweise

Post by Milbrot »

Schau mal ob es so funktioniert.

Code: Select all

eg.RegisterPlugin(
    name = "Nuts",
    author = "Nuts",
    version = "1.0.",
    kind = "program",
    createMacrosOnAdd = True,
)

ACTIONS = (
(eg.ActionGroup, 'GroupMainControls', 'Main controls', None, (
    ('Exit', 'Quit Application', None, 100),
    ('PlayPause', 'Play/Pause', None, 110),
    ('Play', 'Play', None, 120),
)),
)

from eg.WinApi import FindWindow, SendMessageTimeout, WM_COMMAND


class ActionPrototype(eg.ActionClass):
    
    def __call__(self):
        try:
            hWnd = FindWindow("AutoIt v3 GUI", "nuts")
            return SendMessageTimeout(hWnd, WM_COMMAND, self.value, 0)
        except:
            raise self.Exceptions.ProgramNotRunning
    


class Nuts(eg.PluginClass):

    def __init__(self):
        self.AddActionsFromList(ACTIONS, ActionPrototype)
Nuts
Posts: 26
Joined: Tue Oct 07, 2008 11:32 am

Re: SendMessage: Grundsatzfrage zur Vorgehensweise

Post by Nuts »

Danke, funktioniert. :)
Post Reply