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.

Wo is hier das Problem?

Allgemeines zum Thema EventGhost
Post Reply
Milbrot
Plugin Developer
Posts: 79
Joined: Wed Mar 29, 2006 11:07 am

Wo is hier das Problem?

Post by Milbrot »

Ich habe da ein Plugin geschrieben das so ausschaut:

Code: Select all





















import eg
from win32gui import FindWindow, SendMessageTimeout
from win32con import SMTO_ABORTIFHUNG, SMTO_NORMAL
import _winreg
from win32api import ShellExecute
import sys


class MsgAction(eg.ActionClass):
    def __call__(self):
        try:
            hWnd = FindWindow("PC_DIMMER Remote Control", "PC_DIMMER Remote Control")
        except:
            eg.PrintError("PC_DIMMER is not running!")
            return None
        try:
            _, result = SendMessageTimeout(
                hWnd,
                32868,
                self.value,
                0,
                SMTO_ABORTIFHUNG|SMTO_NORMAL,
                1500
            )
            return result
        except:
            return None

 

class ExeAction(eg.ActionClass):
    def __call__(self):
        try:
            ShellExecute(0, None, self.plugin.RemoteControlPath, self.value, None, 1)
            return True
        except:
            eg.PrintError("PC_DIMMER not found!")
            return None


MyActionList = (
('Fader Panel', None,
  (
    (MsgAction, 'LevelCh1Up', 'Level Channel 1 Up', None, 229), #LEVEL_CH1_UP
    (MsgAction, 'LevelCh1Down', 'Level Channel 1 Down', None, 230), #LEVEL_CH1_DOWN
    (MsgAction, 'LevelCh2Up', 'Level Channel 2 Up', None, 231), #LEVEL_CH2_UP
    (MsgAction, 'LevelCh2Down', 'Level Channel 2 Down', None, 232), #LEVEL_CH2_DOWN
    (MsgAction, 'LevelCh3Up', 'Level Channel 3 Up', None, 233), #LEVEL_CH3_UP
    (MsgAction, 'LevelCh3Down', 'Level Channel 3 Down', None, 234), #LEVEL_CH3_DOWN
    (MsgAction, 'LevelCh4Up', 'Level Channel 4 Up', None, 235), #LEVEL_CH4_UP
    (MsgAction, 'LevelCh4Down', 'Level Channel 4 Down', None, 236), #LEVEL_CH4_DOWN
    (MsgAction, 'LevelCh5Up', 'Level Channel 5 Up', None, 237), #LEVEL_CH5_UP
    (MsgAction, 'LevelCh5Down', 'Level Channel 5 Down', None, 238), #LEVEL_CH5_DOWN
    (MsgAction, 'LevelCh6Up', 'Level Channel 6 Up', None, 239), #LEVEL_CH6_UP
    (MsgAction, 'LevelCh6Down', 'Level Channel 6 Down', None, 240), #LEVEL_CH6_DOWN
    (MsgAction, 'LevelCh7Up', 'Level Channel 7 Up', None, 241), #LEVEL_CH7_UP
    (MsgAction, 'LevelCh7Down', 'Level Channel 7 Down', None, 242), #LEVEL_CH7_DOWN
    (MsgAction, 'LevelCh8Up', 'Level Channel 8 Up', None, 243), #LEVEL_CH8_UP
    (MsgAction, 'LevelCh8Down', 'Level Channel 8 Down', None, 244), #LEVEL_CH8_DOWN
  )
),
('Light Scene', None,
  (
    (MsgAction, 'LightScene1', 'Light Scene 1', None, 220), #IDC_SCENE1
    (MsgAction, 'LightScene2', 'Light Scene 2', None, 221), #IDC_SCENE2
    (MsgAction, 'LightScene3', 'Light Scene 3', None, 222), #IDC_SCENE3
    (MsgAction, 'LightScene4', 'Light Scene 4', None, 223), #IDC_SCENE4
    (MsgAction, 'LightScene5', 'Light Scene 5', None, 224), #IDC_SCENE5
    (MsgAction, 'LightScene6', 'Light Scene 6', None, 225), #IDC_SCENE6
    (MsgAction, 'AllCh0', 'All Channels @ 0%', None, 226), #IDC_AT_0
    (MsgAction, 'AllCh50', 'All Channels @ 50%', None, 227), #IDC_AT_50
    (MsgAction, 'AllCh100', 'All Channels @ 100%', None, 228), #IDC_AT_100
  )
),
('Functions', None,
  (
    (MsgAction, 'RecordScene', 'Record Scene', None, 219), #IDC_RECORD
    (MsgAction, 'Exit', 'Exit', None, 205), #IDM_CANCEL
    (ExeAction, 'Start', 'Start', None, None)
  )
),
)


def ScanListRecursive(theList, group):
    for part in theList:
        if len(part) == 3:
            # this is a new sub-group
            groupName, groupDescription, groupList = part
            newGroup = group.AddGroup(groupName, groupDescription)
            ScanListRecursive(groupList, newGroup)
        else:
            # this is a new action
            classType, className, actionName, actionDescription, actionValue = part
            class tmpAction(classType):
                name = actionName
                description = actionDescription
                value = actionValue
            tmpAction.__name__ = className
            group.AddAction(tmpAction)


class PC_DIMMER(eg.PluginClass):

    def __init__(self):
        ScanListRecursive(MyActionList, self)

        try:
            key = _winreg.OpenKey(
                _winreg.HKEY_LOCAL_MACHINE,
                "Software\\PHOENIXstudios\\PC_DIMMER Remote Control"
            )
            self.RemoteControlPath, dummy = _winreg.QueryValueEx(key, "AppPath")
        except WindowsError:
            self.PrintError("PC_DIMMER installation path not found!")
            self.RemoteControlPath = "" 
Mein Problem ist nun wenn ich Makros hinzuf├╝ge z.B. Start Exit Record
dann geht das ohne Probleme. Starte ich jedoch EG neu kommt z.B.
die Meldung Can't find action: PC_DIMMER.Record Scene().
Ich hab im Moment keine Idee woran das liegten k├Ânnte. Was ist da nur falsch?
Last edited by Milbrot on Sat Sep 23, 2006 8:30 pm, edited 1 time in total.
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Post by Bitmonster »

Der Klassename von Aktionen darf keinen Leerschritt enthalten.

Also es darf nicht so aussehen:
(MsgAction, 'Light Scene 6', 'Light Scene 6', None, 225), #IDC_SCENE6
sondern so:
(MsgAction, 'LightScene6', 'Light Scene 6', None, 225), #IDC_SCENE6
Milbrot
Plugin Developer
Posts: 79
Joined: Wed Mar 29, 2006 11:07 am

Post by Milbrot »

uuuups hab ich wohl vergessen...

Noch eine Frage was m├╝sste ich machen das ich der SendMessageTimeout Function
f├╝r den FaderPanel Teil einen Wert f├╝r lParam mitgebe?
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Post by Bitmonster »

Statt wParam oder zusätzlich zum wParam?
Milbrot
Plugin Developer
Posts: 79
Joined: Wed Mar 29, 2006 11:07 am

Post by Milbrot »

zusätzlich aber nur für den FaderPanel Teil
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Post by Bitmonster »

Muss leider weg. Bin wahrscheinlich erst Montag wieder da. Dann schau ich mal. Soll das lParam vom User eingestellt werden oder ist es f├╝r jede Aktion fest?
Milbrot
Plugin Developer
Posts: 79
Joined: Wed Mar 29, 2006 11:07 am

Post by Milbrot »

Es k├Ânnte vom User eingestellt werden da der Parameter angibt um wie viel % sich die Lichtintensit├ñt je Schritt ├ñndert.
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Post by Bitmonster »

Hier mal eine Version mit einstallbarem lParam. "min" und "max" in der FaderAction.Configure() musst du noch entsprechend anpassen. Wie ist denn das Verhältnis von lParam zu %-Lichtwechsel? Wäre vielleicht auch denkbar die Up- und Down-Action zusammenzufassen, wenn man den Wert der Veränderung schon einstellen kann.

Code: Select all

import eg
import wx
from win32gui import FindWindow, SendMessageTimeout
from win32con import SMTO_ABORTIFHUNG, SMTO_NORMAL
import _winreg
from win32api import ShellExecute
import sys


class MsgAction(eg.ActionClass):
    def __call__(self):
        try:
            hWnd = FindWindow("PC_DIMMER Remote Control", "PC_DIMMER Remote Control")
        except:
            eg.PrintError("PC_DIMMER is not running!")
            return None
        try:
            _, result = SendMessageTimeout(
                hWnd,
                32868,
                self.value,
                0,
                SMTO_ABORTIFHUNG|SMTO_NORMAL,
                1500
            )
            return result
        except:
            return None

 
class FadeAction(eg.ActionClass):
    
    def __call__(self, lParam):
        try:
            hWnd = FindWindow("PC_DIMMER Remote Control", "PC_DIMMER Remote Control")
        except:
            eg.PrintError("PC_DIMMER is not running!")
            return None
        try:
            _, result = SendMessageTimeout(
                hWnd,
                32868,
                self.value,
                lParam,
                SMTO_ABORTIFHUNG|SMTO_NORMAL,
                1500
            )
            return result
        except:
            return None


    def Configure(self, lParam=0):
        dialog = eg.ConfigurationDialog(self)
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        staticText = wx.StaticText(dialog, -1, "lParam Value:")
        sizer.Add(staticText, 0, wx.ALIGN_CENTER_VERTICAL)
        lParamCtrl = eg.SpinIntCtrl(dialog, min=-32768, max=32767, value=lParam)
        sizer.Add(lParamCtrl)
        dialog.sizer.Add(sizer, 1, wx.EXPAND)
        if dialog.AffirmedShowModal():
            return (
                lParamCtrl.GetValue(),
            )
            
        

class ExeAction(eg.ActionClass):
    def __call__(self):
        try:
            ShellExecute(0, None, self.plugin.RemoteControlPath, self.value, None, 1)
            return True
        except:
            eg.PrintError("PC_DIMMER not found!")
            return None


MyActionList = (
('Fader Panel', None,
  (
    (FadeAction, 'LevelCh1Up', 'Level Channel 1 Up', None, 229), #LEVEL_CH1_UP
    (FadeAction, 'LevelCh1Down', 'Level Channel 1 Down', None, 230), #LEVEL_CH1_DOWN
    (FadeAction, 'LevelCh2Up', 'Level Channel 2 Up', None, 231), #LEVEL_CH2_UP
    (FadeAction, 'LevelCh2Down', 'Level Channel 2 Down', None, 232), #LEVEL_CH2_DOWN
    (FadeAction, 'LevelCh3Up', 'Level Channel 3 Up', None, 233), #LEVEL_CH3_UP
    (FadeAction, 'LevelCh3Down', 'Level Channel 3 Down', None, 234), #LEVEL_CH3_DOWN
    (FadeAction, 'LevelCh4Up', 'Level Channel 4 Up', None, 235), #LEVEL_CH4_UP
    (FadeAction, 'LevelCh4Down', 'Level Channel 4 Down', None, 236), #LEVEL_CH4_DOWN
    (FadeAction, 'LevelCh5Up', 'Level Channel 5 Up', None, 237), #LEVEL_CH5_UP
    (FadeAction, 'LevelCh5Down', 'Level Channel 5 Down', None, 238), #LEVEL_CH5_DOWN
    (FadeAction, 'LevelCh6Up', 'Level Channel 6 Up', None, 239), #LEVEL_CH6_UP
    (FadeAction, 'LevelCh6Down', 'Level Channel 6 Down', None, 240), #LEVEL_CH6_DOWN
    (FadeAction, 'LevelCh7Up', 'Level Channel 7 Up', None, 241), #LEVEL_CH7_UP
    (FadeAction, 'LevelCh7Down', 'Level Channel 7 Down', None, 242), #LEVEL_CH7_DOWN
    (FadeAction, 'LevelCh8Up', 'Level Channel 8 Up', None, 243), #LEVEL_CH8_UP
    (FadeAction, 'LevelCh8Down', 'Level Channel 8 Down', None, 244), #LEVEL_CH8_DOWN
  )
),
('Light Scene', None,
  (
    (MsgAction, 'LightScene1', 'Light Scene 1', None, 220), #IDC_SCENE1
    (MsgAction, 'LightScene2', 'Light Scene 2', None, 221), #IDC_SCENE2
    (MsgAction, 'LightScene3', 'Light Scene 3', None, 222), #IDC_SCENE3
    (MsgAction, 'LightScene4', 'Light Scene 4', None, 223), #IDC_SCENE4
    (MsgAction, 'LightScene5', 'Light Scene 5', None, 224), #IDC_SCENE5
    (MsgAction, 'LightScene6', 'Light Scene 6', None, 225), #IDC_SCENE6
    (MsgAction, 'AllCh0', 'All Channels @ 0%', None, 226), #IDC_AT_0
    (MsgAction, 'AllCh50', 'All Channels @ 50%', None, 227), #IDC_AT_50
    (MsgAction, 'AllCh100', 'All Channels @ 100%', None, 228), #IDC_AT_100
  )
),
('Functions', None,
  (
    (MsgAction, 'RecordScene', 'Record Scene', None, 219), #IDC_RECORD
    (MsgAction, 'Exit', 'Exit', None, 205), #IDM_CANCEL
    (ExeAction, 'Start', 'Start', None, None)
  )
),
)


def ScanListRecursive(theList, group):
    for part in theList:
        if len(part) == 3:
            # this is a new sub-group
            groupName, groupDescription, groupList = part
            newGroup = group.AddGroup(groupName, groupDescription)
            ScanListRecursive(groupList, newGroup)
        else:
            # this is a new action
            classType, className, actionName, actionDescription, actionValue = part
            class tmpAction(classType):
                name = actionName
                description = actionDescription
                value = actionValue
            tmpAction.__name__ = className
            group.AddAction(tmpAction)


class PC_DIMMER(eg.PluginClass):

    def __init__(self):
        ScanListRecursive(MyActionList, self)

        try:
            key = _winreg.OpenKey(
                _winreg.HKEY_LOCAL_MACHINE,
                "Software\\PHOENIXstudios\\PC_DIMMER Remote Control"
            )
            self.RemoteControlPath, dummy = _winreg.QueryValueEx(key, "AppPath")
        except WindowsError:
            self.PrintError("PC_DIMMER installation path not found!")
            self.RemoteControlPath = ""
Last edited by Bitmonster on Sun Sep 24, 2006 7:02 pm, edited 1 time in total.
Milbrot
Plugin Developer
Posts: 79
Joined: Wed Mar 29, 2006 11:07 am

Post by Milbrot »

Das Verhältnis ist gleich der eingegebenen Zahl. Fader hat einen Bereich von 0-255. Wenn die Zahl nun 5 ist sind es also 51 Helligkeitsstufen.
Wenn der User f├╝r up down den gleichen Wert hat is das ok.

Beim hinzuf├╝gen eines Faderbefehls gibts nun eine Fehlermeldung:

Traceback (most recent call last):
File "D:\Programme\EventGhost\eg\MainFrame.py", line 818, in OnMenuNewMacro
MacroItem.CreateNew()
File "D:\Programme\EventGhost\eg\TreeItems\MacroItem.py", line 44, in CreateNew
actionObj = ActionItem.CreateNew()
File "D:\Programme\EventGhost\eg\TreeItems\ActionItem.py", line 216, in CreateNew
if not self.Configure():
File "D:\Programme\EventGhost\eg\TreeItems\ActionItem.py", line 342, in Configure
result = self.action.Configure(*self.args)
File "plugins/PC_DIMMER/__init__.py", line 54, in Configure
sizer = wx.BoxSizer(wx.HORIZONTAL)
NameError: global name 'wx' is not defined
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Post by Bitmonster »

Uhps, am Anfang noch "import wx" einf├╝gen.
Milbrot
Plugin Developer
Posts: 79
Joined: Wed Mar 29, 2006 11:07 am

Post by Milbrot »

Das ist genau richtig so wie es ist! Danke f├╝r die Hilfe.
Post Reply