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.

MPC Home custom events shared

If you have a question or need help, this is the place to be.
Post Reply
molitar
Experienced User
Posts: 209
Joined: Fri Sep 11, 2009 6:44 am

MPC Home custom events shared

Post by molitar »

Well several developers helped me out alot with custom configurations for MPC-Home so i am sharing them here for others to use. Hope you enjoyed them like I have thanks especially to Pako and Jinxdone that have helped me out alot with their time and patience.

Custom plugins required to be downloaded for these configurations is the Taskbar created by Pako for my needs :) Thanks again Pako!

Custom OSD that will display on monitor 1 or 2 depending on if you have screen maximized it will display OSD on the second display.
Custom OSD shows Title, Current Playtime Bar, Current play time and End Time of the file being played
Custom Toggle Minimize, Maximize
Custom Maximize that sets taskbar to auto-hide and unhide when not maximized
Custom Volume OSD that displays a volume bar and percentage OSD

Volume OSD

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1387">
    <Folder Name="Volume Controls">
        <Macro Name="Volume Up">
            <Event Name="DXusbPCR.Num2" />
            <Action>
                MediaPlayerClassic.VolumeUp()
            </Action>
            <Action>
                EventGhost.NewJumpIf(XmlIdLink(285), 2, True)
            </Action>
            <Action>
                EventGhost.PythonScript(u'from eg.WinApi.Dynamic import SendMessage\nTBM_GETPOS = 1024\nFind_MPC_Volume_Ctrl=eg.WindowMatcher(u\'mpc-hc.exe\', u\'{*}Media Player Classic{*}\', u\'MediaPlayerClassicW\', u\'\', u\'msctls_trackbar32\', 1, True, 0.0, 0)\nhwnd = Find_MPC_Volume_Ctrl()\n\nM = 2\n\nif len(hwnd) > 0:\n    if eg.globals.WindowsState == "Fullscreen": volume = int(SendMessage(hwnd[0], TBM_GETPOS, 0, 0)/7)\n    if eg.globals.WindowsState != "Fullscreen": volume = int(SendMessage(hwnd[0], TBM_GETPOS, 0, 0)/5)\n    eg.result = volume*M*u\'\\u2588\'\n    volume2 = SendMessage(hwnd[0], TBM_GETPOS, 0, 0)\n    eg.result2 = volume2\nelse:\n    print "Window not found"\n    eg.result = \'\'\n    \nif eg.globals.WindowsState != "Fullscreen":\n    eg.plugins.EventGhost.ShowOSD(u\'Volume: {eg.result} {eg.result2}%\', u\'0;-48;0;0;0;400;0;0;0;238;3;2;1;49;Lucida Console\', (255, 0, 0), (0, 0, 0), 0, (60, 150), 0, 2.0, False)\nelse:\n    eg.plugins.EventGhost.ShowOSD(u\'Volume: {eg.result} {eg.result2}%\', u\'0;-48;0;0;0;400;0;0;0;238;3;2;1;49;Lucida Console\', (255, 0, 0), (0, 0, 0), 0, (60, 150), 1, 2.0, False)\n    ')
            </Action>
            <Action>
                EventGhost.AutoRepeat(0.29999999999999999, 0.29999999999999999, 0.0, 60.0)
            </Action>
        </Macro>
        <Macro Name="Volume Down">
            <Event Name="DXusbPCR.Num8" />
            <Action>
                MediaPlayerClassic.VolumeDown()
            </Action>
            <Action>
                EventGhost.NewJumpIf(XmlIdLink(285), 2, True)
            </Action>
            <Action>
                EventGhost.PythonScript(u'from eg.WinApi.Dynamic import SendMessage\nTBM_GETPOS = 1024\nFind_MPC_Volume_Ctrl=eg.WindowMatcher(u\'mpc-hc.exe\', u\'{*}Media Player Classic{*}\', u\'MediaPlayerClassicW\', u\'\', u\'msctls_trackbar32\', 1, True, 0.0, 0)\nhwnd = Find_MPC_Volume_Ctrl()\n\nM = 2\n\nif len(hwnd) > 0:\n    if eg.globals.WindowsState == "Fullscreen": volume = int(SendMessage(hwnd[0], TBM_GETPOS, 0, 0)/7)\n    if eg.globals.WindowsState != "Fullscreen": volume = int(SendMessage(hwnd[0], TBM_GETPOS, 0, 0)/5)\n    eg.result = volume*M*u\'\\u2588\'\n    volume2 = SendMessage(hwnd[0], TBM_GETPOS, 0, 0)\n    eg.result2 = volume2\nelse:\n    print "Window not found"\n    eg.result = \'\'\n    \nif eg.globals.WindowsState != "Fullscreen":\n    eg.plugins.EventGhost.ShowOSD(u\'Volume: {eg.result} {eg.result2}%\', u\'0;-48;0;0;0;400;0;0;0;238;3;2;1;49;Lucida Console\', (255, 0, 0), (0, 0, 0), 0, (60, 150), 0, 2.0, False)\nelse:\n    eg.plugins.EventGhost.ShowOSD(u\'Volume: {eg.result} {eg.result2}%\', u\'0;-48;0;0;0;400;0;0;0;238;3;2;1;49;Lucida Console\', (255, 0, 0), (0, 0, 0), 0, (60, 150), 1, 2.0, False)\n    ')
            </Action>
            <Action>
                EventGhost.AutoRepeat(0.29999999999999999, 0.29999999999999999, 0.0, 60.0)
            </Action>
        </Macro>
        <Macro Name="Volume Mute">
            <Action>
                MediaPlayerClassic.VolumeMute()
            </Action>
        </Macro>
    </Folder>
</EventGhost>
Display Toggles

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1387">
    <Folder Name="Display Toggles">
        <Macro Name="Toggle Maximize" Expanded="True">
            <Event Name="DXusbPCR.Num9" />
            <Action>
                EventGhost.NewJumpIf(XmlIdLink(285), 2, True)
            </Action>
            <Action>
                Window.FindWindow(None, None, u'MediaPlayerClassicW', None, None, None, False, 0.0, 0)
            </Action>
            <Action>
                EventGhost.PythonScript(u'from eg.WinApi.Dynamic import GetWindowLong, ShowWindow, SW_RESTORE, SW_MAXIMIZE, SW_MINIMIZE\nfrom win32gui import SetWindowPos\nfrom ctypes import windll\n\n# Check that we have a window to try to maximize/restore\n# Use Find Window action before this script!\nif eg.globals.WindowsState != "Fullscreen":\n    if len(result) > 0:\n        # Check if WS_MAXIMIZE bit is set\n        if(GetWindowLong(result[0], -16) & 0x01000000):\n            eg.plugins.EventGhost.ShowOSD(\'Maximized \' + eg.WinApi.GetWindowText(eg.result[0]), None, (255, 255, 255), (0, 0, 0), 0, (0, 0), 0, 3.0, None)\n            eg.plugins.MediaPlayerClassic.ViewNormal()\n            ShowWindow(result[0], SW_RESTORE)\n            #Script Unhide Taskbar\n            eg.plugins.Taskbar.SetAutohideOff()\n        else:\n            eg.plugins.EventGhost.ShowOSD(\'Maximized \' + eg.WinApi.GetWindowText(eg.result[0]), None, (255, 255, 255), (0, 0, 0), 0, (0, 0), 0, 3.0, None)\n            eg.plugins.Taskbar.SetAutohideOn()\n            ShowWindow(result[0], SW_MAXIMIZE)\n            eg.plugins.MediaPlayerClassic.ViewMinimal()\n            #Script Hide Taskbar\n')
            </Action>
        </Macro>
        <Macro Name="Toggle Minimize">
            <Event Name="DXusbPCR.Num7" />
            <Action>
                EventGhost.NewJumpIf(XmlIdLink(285), 2, True)
            </Action>
            <Action>
                Window.FindWindow(None, None, u'MediaPlayerClassicW', None, None, None, False, 0.0, 0)
            </Action>
            <Action>
                EventGhost.PythonScript(u'from eg.WinApi.Dynamic import GetWindowLong, ShowWindow, SW_RESTORE, SW_MAXIMIZE, SW_MINIMIZE\n   \n# Check that we have a window to try to minimize/restore\n# Use Find Window action before this script!\nif eg.globals.WindowsState != "Fullscreen":\n    if len(result) > 0:\n    # Check if WS_MINIMIZE bit is set\n        if(GetWindowLong(result[0], -16) & 0x20000000):\n            eg.plugins.EventGhost.ShowOSD(\'Minimized \' + eg.WinApi.GetWindowText(eg.result[0]), None, (255, 255, 255), (0, 0, 0), 0, (0, 0), 0, 3.0, None)\n            ShowWindow(result[0], SW_RESTORE)\n        else:\n            eg.plugins.EventGhost.ShowOSD(\'Maximized \' + eg.WinApi.GetWindowText(eg.result[0]), None, (255, 255, 255), (0, 0, 0), 0, (0, 0), 0, 3.0, None)\n            ShowWindow(result[0], SW_MINIMIZE)')
            </Action>
        </Macro>
        <Macro Name="Python Script">
            <Action>
                EventGhost.PythonScript(u'from win32gui import SetWindowPos\nfrom ctypes import windll\n\n#Script Hide Taskbar\nTOGGLE_HIDEWINDOW = 0x80\nhandleTaskBar = windll.user32.FindWindowA("Shell_TrayWnd", "")\nSetWindowPos(handleTaskBar, 0, 0, 0, 0, 0, TOGGLE_HIDEWINDOW)\n\n#Script Unhide Taskbar\nTOGGLE_UNHIDEWINDOW = 0x40\nhandleTaskBar = windll.user32.FindWindowA("Shell_TrayWnd", "")\nSetWindowPos(handleTaskBar, 0, 0, 0, 0, 0, TOGGLE_UNHIDEWINDOW)')
            </Action>
        </Macro>
    </Folder>
</EventGhost>
Show OSD

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1387">
    <Folder Name="Show OSD" Expanded="True">
        <Macro Name="Display OSD">
            <Event Name="DXusbPCR.Num3" />
            <Action>
                EventGhost.NewJumpIf(XmlIdLink(285), 2, True)
            </Action>
            <Action>
                EventGhost.PythonScript(u'mpc = eg.WindowMatcher(u\'mpc-hc.exe\', None, u\'MediaPlayerClassicW\', None, None, None, True, 0.0, 0)\nhWnd = mpc()\n\nif len(hWnd) > 0:\n    from eg.WinApi import GetWindowText\n    title = GetWindowText(hWnd[0])\n    eg.result = title.split(".mkv ")[0]  \n\nFind_MPC_Time=eg.WindowMatcher(u\'mpc-hc.exe\', u\'{*}Media Player Classic{*}\', u\'MediaPlayerClassicW\', None, u\'Static\', 2, True, 0.0, 0)\nhwnd = Find_MPC_Time()\n\nif len(hwnd) > 0:\n    if eg.globals.WindowsState == "Fullscreen": howManyBars = 60\n    if eg.globals.WindowsState != "Fullscreen": howManyBars = 80\n\n    timeE,timeR = eg.WinApi.GetWindowText(hwnd[0]).split(\' / \')\n    secArray = timeE.split(\':\')\n    secArrayTotal = timeR.split(\':\')\n    secondsTotal = int(secArrayTotal[0])*(60)+int(secArrayTotal[1])\n    secondsElapsed = int(secArray[0])*(60)+int(secArray[1])\n    percent = (secondsElapsed*howManyBars)/secondsTotal\n    osd = eg.result + "\\n \\n" + "[" + "|"*(percent) + " "*(howManyBars-percent) + "]" + "\\n" + " "*30 + timeE + " / " + timeR\n    \n    if eg.globals.WindowsState != "Fullscreen":\n        eg.plugins.EventGhost.ShowOSD(osd, u\'0;-64;0;0;0;700;0;0;0;0;3;2;1;34;Arial\', (0, 255, 255), (0, 0, 0), 4, (0, 0), 0, 1.0, False)\n    else:\n        eg.plugins.EventGhost.ShowOSD(osd, u\'0;-64;0;0;0;700;0;0;0;0;3;2;1;34;Arial\', (0, 255, 255), (0, 0, 0), 4, (0, 0), 1, 1.0, False)\n    mpc = eg.WindowMatcher(u\'mpc-hc.exe\', None, u\'MediaPlayerClassicW\', None, None, None, True, 0.0, 0)\nhWnd = mpc()\n\n\n')
            </Action>
        </Macro>
    </Folder>
</EventGhost>
Windows State (Required for Display Toggle and Show OSD)

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1387">
    <Folder Name="Windows State" Expanded="True">
        <Macro Name="Windows State" id="285">
            <Action>
                Window.FindWindow(None, None, u'MediaPlayerClassicW', None, None, None, False, 0.0, 0)
            </Action>
            <Action>
                EventGhost.PythonScript(u'from win32gui import GetWindowPlacement\n\n#SW_SHOWNORMAL = 1\n#SW_SHOWMINIMIZED = 2\n#SW_SHOWMAXIMIZED = 3\n\nFindWin = eg.WindowMatcher(None, None, u\'MediaPlayerClassicW\' , None, None, None, True, 0.0, 0)\nhwnd = FindWin()\n\ndef GetWindowStatus(hwnd):\n    showList  = (None, "Normal", "Minimized", "Maximized")\n    placement = GetWindowPlacement(hwnd)\n    #unrem the below line to display the placement values that you need for the if placement[4] line\n    #print placement\n   \n    if placement[4] == (1671, 1050, 2951, 1770):\n        return "Fullscreen"\n    else:\n        return showList[placement[1]]\n\neg.globals.WindowsState = GetWindowStatus(hwnd[0])\nprint "Windows State = " + eg.globals.WindowsState')
            </Action>
        </Macro>
    </Folder>
</EventGhost>
molitar
Experienced User
Posts: 209
Joined: Fri Sep 11, 2009 6:44 am

Re: MPC Home custom events shared

Post by molitar »

Show OSE (requires the OSE plugin)

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1387">
    <Macro Name="Show explorer">
        <Event Name="DXusbPCR.MyPC" />
        <Action>
            EventGhost.NewJumpIf(XmlIdLink(238), 2, True)
        </Action>
        <Action>
            EventGhost.PythonCommand(u'eg.result = eg.globals.WindowsState == "Fullscreen"')
        </Action>
        <Action>
            EventGhost.NewJumpIf(XmlIdLink(585), 0, False)
        </Action>
        <Action>
            EventGhost.NewJumpIf(XmlIdLink(583), 2, False)
        </Action>
    </Macro>
</EventGhost>



<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1387">
    <Macro Name="On screen explorer: Show explorer: D:\, [*.*] - Display 1" id="583">
        <Action>
            OSE.ShowMenu((0, 0, 0), (255, 255, 255), u'0;-55;0;0;0;400;0;0;0;0;0;0;0;0;MS Shell Dlg 2', u'OSE', u'Open', 0, u'D:\\', u'*.*', True)
        </Action>
    </Macro>
</EventGhost>



<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1387">
    <Macro Name="On screen explorer: Show explorer: D:\, [*.*] - Display 2" id="585">
        <Action>
            OSE.ShowMenu((0, 0, 0), (255, 255, 255), u'0;-55;0;0;0;400;0;0;0;0;0;0;0;0;MS Shell Dlg 2', u'OSE', u'Open', 1, u'D:\\', u'*.*', True)
        </Action>
    </Macro>
</EventGhost>
Post Reply