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 = "" 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?