Re: Media Player Classic
Posted: Sun Jun 16, 2013 12:53 am
Never tried MPC-BE as MPC-HC is used by CCCP pack. I will try it and see if it works with MPC-HC or not.abuttino wrote:Any luck on getting this to work with mpc-be?
I'll include the code from a copy of the MediaPlayer Classic that I use for my code.
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1572">
<Folder Name="Media Player Classic" id="25" Expanded="True">
<Folder Name="Main controls">
<Folder Name="Volume Controls">
<Macro Name="Volume Up">
<Event Name="DXusbPCR.Num2" />
<Event Name="DXusbPCR.Up_arrow" />
<Action>
EventGhost.NewJumpIf(XmlIdLink(119), 2, True)
</Action>
<Action>
MediaPlayerClassic.VolumeUp()
</Action>
<Action Name="Python Script">
EventGhost.PythonScript(u'from eg.WinApi.Dynamic import SendMessage\nTBM_GETPOS = 1024\nFind_MPC_Volume_Ctrl=eg.WindowMatcher(u\'mpc-hc.exe\', None, u\'MediaPlayerClassicW\', None, u\'msctls_trackbar32\', 1, True, 0.0, 0)\n\nhwnd = Find_MPC_Volume_Ctrl()\n\nif len(hwnd) > 0:\n if eg.globals.WindowsState == "Fullscreen":\n mon = 1\n top = 900\n else:\n mon = 2\n top = 600\n volume = SendMessage(hwnd[0], TBM_GETPOS, 0, 0)\n osd = "Volume: %i%%"\n if volume == 1 : volume = 0\n eg.plugins.EventGhost.ShowOSD(osd % volume, u\'0;-64;0;0;0;700;0;0;0;238;3;2;1;66;Arial\', (255, 255, 255), (0, 0, 0), 5, (0, top), mon, 3.0, True)\nelse:\n print "Window not found"')
</Action>
<Action>
EventGhost.AutoRepeat(0.5, 0.20000000000000001, 0.029999999999999999, 0.0)
</Action>
</Macro>
<Macro Name="Volume Down">
<Event Name="DXusbPCR.Num8" />
<Event Name="DXusbPCR.Down_arrow" />
<Action>
EventGhost.NewJumpIf(XmlIdLink(119), 2, True)
</Action>
<Action>
MediaPlayerClassic.VolumeDown()
</Action>
<Action Name="Python Script">
EventGhost.PythonScript(u'from eg.WinApi.Dynamic import SendMessage\nTBM_GETPOS = 1024\nFind_MPC_Volume_Ctrl=eg.WindowMatcher(u\'mpc-hc.exe\', None, u\'MediaPlayerClassicW\', None, u\'msctls_trackbar32\', 1, True, 0.0, 0)\n\nhwnd = Find_MPC_Volume_Ctrl()\n\nif len(hwnd) > 0:\n if eg.globals.WindowsState == "Fullscreen":\n mon = 1\n top = 900\n else:\n mon = 2\n top = 600\n volume = SendMessage(hwnd[0], TBM_GETPOS, 0, 0)\n osd = "Volume: %i%%"\n if volume == 1 : volume = 0\n eg.plugins.EventGhost.ShowOSD(osd % volume, u\'0;-64;0;0;0;700;0;0;0;238;3;2;1;66;Arial\', (255, 255, 255), (0, 0, 0), 5, (0, top), mon, 3.0, True)\nelse:\n print "Window not found"')
</Action>
<Action>
EventGhost.AutoRepeat(0.5, 0.20000000000000001, 0.029999999999999999, 0.0)
</Action>
</Macro>
<Macro Name="Volume Mute">
<Action>
MediaPlayerClassic.VolumeMute()
</Action>
</Macro>
</Folder>
<Macro Name="Quit Application" id="44">
<Action>
MediaPlayerClassic.Exit()
</Action>
</Macro>
<Macro Name="Play/Pause">
<Event Name="DXusbPCR.Play/Pause" />
<Action>
MediaPlayerClassic.PlayPause()
</Action>
</Macro>
<Macro Name="Stop">
<Event Name="DXusbPCR.Stop" />
<Action>
MediaPlayerClassic.Stop()
</Action>
</Macro>
<Macro Name="Jump Forward Medium">
<Event Name="DXusbPCR.Page+" />
<Action>
MediaPlayerClassic.JumpForwardMedium()
</Action>
<Action>
EventGhost.AutoRepeat(0.5, 0.20000000000000001, 0.029999999999999999, 0.0)
</Action>
<Action>
EventGhost.FlushEvents()
</Action>
</Macro>
<Macro Name="Jump Backward Medium">
<Event Name="DXusbPCR.Page-" />
<Action>
MediaPlayerClassic.JumpBackwardMedium()
</Action>
<Action>
EventGhost.AutoRepeat(0.5, 0.20000000000000001, 0.029999999999999999, 0.0)
</Action>
<Action>
EventGhost.FlushEvents()
</Action>
</Macro>
<Macro Name="Jump Forward Large">
<Event Name="DXusbPCR.>>" />
<Action>
MediaPlayerClassic.JumpForwardLarge()
</Action>
<Action>
EventGhost.AutoRepeat(0.5, 0.20000000000000001, 0.029999999999999999, 0.0)
</Action>
<Action>
EventGhost.FlushEvents()
</Action>
</Macro>
<Macro Name="Jump Backward Large">
<Event Name="DXusbPCR.<<" />
<Action>
MediaPlayerClassic.JumpBackwardLarge()
</Action>
<Action>
EventGhost.AutoRepeat(0.5, 0.20000000000000001, 0.029999999999999999, 0.0)
</Action>
<Action>
EventGhost.FlushEvents()
</Action>
</Macro>
<Macro Name="Next">
<Event Name="DXusbPCR.>|" />
<Action>
Window.FindWindow(None, None, u'MediaPlayerClassicW', None, None, None, False, 0.0, 0)
</Action>
<Action>
MediaPlayerClassic.UserMessage(u'922')
</Action>
</Macro>
<Macro Name="Previous">
<Event Name="DXusbPCR.|<" />
<Action>
Window.FindWindow(None, None, u'MediaPlayerClassicW', None, None, None, False, 0.0, 0)
</Action>
<Action>
MediaPlayerClassic.UserMessage(u'921')
</Action>
</Macro>
<Macro Name="Frame Step">
<Event Name="DXusbPCR.Num6" />
<Event Name="DXusbPCR.Right_arrow" />
<Action>
Window.FindWindow(None, None, u'MediaPlayerClassicW', None, None, None, False, 0.0, 0)
</Action>
<Action>
MediaPlayerClassic.FrameStep()
</Action>
<Action>
EventGhost.AutoRepeat(0.29999999999999999, 0.10000000000000001, 0.0, 60.0)
</Action>
</Macro>
<Macro Name="Frame Step Back">
<Event Name="DXusbPCR.Num4" />
<Event Name="DXusbPCR.Left_arrow" />
<Action>
Window.FindWindow(None, None, u'MediaPlayerClassicW', None, None, None, False, 0.0, 0)
</Action>
<Action>
MediaPlayerClassic.FrameStepBack()
</Action>
<Action>
EventGhost.AutoRepeat(0.29999999999999999, 0.10000000000000001, 0.0, 60.0)
</Action>
</Macro>
<Macro Name="Go To">
<Action>
MediaPlayerClassic.GoTo()
</Action>
</Macro>
<Macro Name="If button is held down 2.0 sec, go to: Quit Application">
<Event Name="DXusbPCR.Close" />
<Action>
EventGhost.JumpIfLongPress(2.0, XmlIdLink(44))
</Action>
</Macro>
</Folder>
<Folder Name="View modes">
<Folder Name="Display Toggles">
<Macro Name="Toggle Maximize">
<Event Name="DXusbPCR.Num7" />
<Event Name="DXusbPCR.Open" />
<Action>
EventGhost.NewJumpIf(XmlIdLink(119), 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 ShowWindow(result[0], SW_RESTORE)\n eg.plugins.MediaPlayerClassic.ViewNormal()\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 eg.plugins.MediaPlayerClassic.ViewMinimal()\n ShowWindow(result[0], SW_MAXIMIZE)\n #Script Hide Taskbar\n')
</Action>
</Macro>
<Macro Name="Toggle Minimize">
<Event Name="DXusbPCR.Num1" />
<Event Name="DXusbPCR.Tab" />
<Action>
EventGhost.NewJumpIf(XmlIdLink(119), 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>
<Folder Name="Show OSD">
<Macro Name="Display OSD">
<Event Name="DXusbPCR.E-mail" />
<Action>
EventGhost.NewJumpIf(XmlIdLink(119), 2, True)
</Action>
<Action Name="Python Script">
EventGhost.PythonScript(u'import re\n\nmpc = 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 if re.search(".mkv",title,re.I):\n title = title.split(".mkv")[0]\n elif re.search(".mp4",title,re.I):\n title = title.split(".mp4")[0]\n elif re.search(".avi",title,re.I):\n title = title.split(".avi")[0]\n elif re.search(".ogm",title,re.I):\n title = title.split(".ogm") [0]\n else:\n title = title.split(".")[0]\n \nelaps, rem, total = eg.plugins.MediaPlayerClassic.GetTimes()\n#print "elaps, rem, total =",elaps, rem, total\n\nx = 1\n\nwhile x < 4:\n\n if elaps != "00:00:00":\n if eg.globals.WindowsState == "Fullscreen": howManyBars = 120\n if eg.globals.WindowsState != "Fullscreen": howManyBars = 130\n\n secArray = elaps.split(\':\')\n secArrayTotal = total.split(\':\')\n \n secondsTotal = int(secArrayTotal[0])*(3600)+int(secArrayTotal[1])*(60)+int(secArrayTotal[2])\n secondsElapsed = int(secArray[0])*(3600)+int(secArray[1])*(60)+int(secArray[2])\n \n percent = (1.0*secondsElapsed)/(secondsTotal)*100\n percent = int(round(percent))\n bars = (percent * howManyBars)/100\n\n #print "percent =",percent\n #print "bars =",bars\n \n osd = title + "\\n \\n" + "[ " + "|" * bars + " " * (howManyBars - bars) + " ]" + "\\n" + " "*30 + elaps + " / " + total\n\n if eg.globals.WindowsState == "Fullscreen":\n eg.plugins.EventGhost.ShowOSD(osd, u\'0;-50;0;0;0;700;0;0;0;0;3;2;1;49;Arial\', (0, 255, 255), (0, 0, 0), 4, (0, 0), 1, 1.0, False)\n else:\n eg.plugins.EventGhost.ShowOSD(osd, u\'0;-40;0;0;0;700;0;0;0;0;3;2;1;49;Arial\', (0, 255, 255), (0, 0, 0), 4, (0, 0), 2, 1.0, False)\n eg.Wait(0.8)\n #print x\n x += 1')
</Action>
</Macro>
</Folder>
<Folder Name="Windows State">
<Macro Name="Windows State" id="119">
<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] == (1680, 1050, 3600, 2130):\n return "Fullscreen"\n else:\n return showList[placement[1]]\n \neg.globals.WindowsState = GetWindowStatus(hwnd[0])\n\nprint "Windows State = " + eg.globals.WindowsState')
</Action>
</Macro>
</Folder>
<Macro Name="Fullscreen without resolution change">
<Event Name="DXusbPCR.Full Screen" />
<Event Name="PcRemoteController.FullScreen" />
<Action>
MediaPlayerClassic.Pause()
</Action>
<Action>
EventGhost.Wait(1.0)
</Action>
<Action>
Window.FindWindow(None, None, u'MediaPlayerClassicW', None, None, None, False, 0.0, 0)
</Action>
<Action>
Window.BringToFront()
</Action>
<Action>
MediaPlayerClassic.FullscreenWOR()
</Action>
<Action>
EventGhost.Wait(2.0)
</Action>
<Action>
MediaPlayerClassic.Play()
</Action>
</Macro>
<Macro Name="View Minimal">
<Action>
MediaPlayerClassic.ViewMinimal()
</Action>
</Macro>
<Macro Name="View Compact">
<Action>
MediaPlayerClassic.ViewCompact()
</Action>
</Macro>
<Macro Name="View Normal">
<Action>
MediaPlayerClassic.ViewNormal()
</Action>
</Macro>
<Macro Name="Always On Top">
<Action>
MediaPlayerClassic.AlwaysOnTop()
</Action>
</Macro>
</Folder>
<Folder Name="Extended controls">
<Macro Name="Load Subtitle">
<Action>
MediaPlayerClassic.LoadSubTitle()
</Action>
</Macro>
<Macro Name="Properties">
<Action>
MediaPlayerClassic.Properties()
</Action>
</Macro>
<Macro Name="Filters Menu">
<Action>
MediaPlayerClassic.FiltersMenu()
</Action>
</Macro>
<Macro Name="Options">
<Action>
MediaPlayerClassic.Options()
</Action>
</Macro>
<Macro Name="On/Off Subtitle">
<Action>
MediaPlayerClassic.OnOffSubtitle()
</Action>
</Macro>
<Macro Name="Reload Subtitles">
<Action>
MediaPlayerClassic.ReloadSubtitles()
</Action>
</Macro>
</Folder>
<Folder Name="Toggle player controls">
<Macro Name="Toggle Default Subtitle On/Off">
<Event Name="DXusbPCR.WWW" />
<Action>
MediaPlayerClassic.UserMessage(u'2304')
</Action>
<Action>
EventGhost.ShowOSD(u'Toggle Default Subtitles', u'0;-32;0;0;0;700;0;0;0;0;3;2;1;34;Arial', (255, 0, 0), (0, 0, 0), 0, (10, 50), 1, 2.0, False)
</Action>
</Macro>
</Folder>
<Folder Name="On screen explorer">
<Macro Name="Show explorer">
<Event Name="DXusbPCR.MyPC" />
<Action>
EventGhost.NewJumpIf(XmlIdLink(119), 2, True)
</Action>
<Action Enabled="False">
EventGhost.PythonCommand(u'print eg.globals.WindowsState')
</Action>
<Action>
EventGhost.PythonCommand(u'eg.result = eg.globals.WindowsState == "Fullscreen"')
</Action>
<Action>
EventGhost.NewJumpIf(XmlIdLink(193), 1, False)
</Action>
<Action>
EventGhost.NewJumpIf(XmlIdLink(185), 2, False)
</Action>
</Macro>
<Macro Name="Cursor Up">
<Event Name="DXusbPCR.MouseUp" />
<Action>
OSE.MoveUp()
</Action>
</Macro>
<Macro Name="Cursor Down">
<Event Name="DXusbPCR.MouseDown" />
<Action>
OSE.MoveDown()
</Action>
</Macro>
<Macro Name="Page Up">
<Event Name="DXusbPCR.Page+" />
<Action>
OSE.PageUp()
</Action>
</Macro>
<Macro Name="Page Down">
<Event Name="DXusbPCR.Page-" />
<Action>
OSE.PageDown()
</Action>
</Macro>
<Macro Name="Execute">
<Event Name="DXusbPCR.LButton" />
<Action>
OSE.Execute()
</Action>
</Macro>
<Macro Name="Cancel">
<Event Name="DXusbPCR.Desktop" />
<Event Name="DXusbPCR.Close" />
<Action>
OSE.Cancel()
</Action>
</Macro>
<Macro Name="On screen explorer: Show explorer: D:\, [*.*] - Display Tv" id="185">
<Action>
OSE.ShowLastMenu((75, 75, 75), (255, 255, 255), u'0;-49;0;0;0;400;0;0;0;0;3;2;1;50;\uff2d\uff33 \uff30\u30b4\u30b7\u30c3\u30af', u'OSE', u'Open', 1, '', u'*.*', False, (180, 180, 180), (75, 75, 75), True)
</Action>
</Macro>
<Macro Name="Execute Directory">
<Event Name="DXusbPCR.RButton" />
<Action>
OSE.Execute(36, u'', u'')
</Action>
<Action>
EventGhost.PythonCommand(u'eg.path = \'"\' + eg.result + \'"\' + \' /play\' ')
</Action>
<Action>
EventGhost.PythonCommand(u'print eg.path')
</Action>
<Action>
System.Execute(u'C:\\Program Files\\Combined Community Codec Pack\\MPC\\mpc-hc.exe', u'{eg.path}', 0, False, 2, u'')
</Action>
</Macro>
<Macro Name="On screen explorer: Show explorer: D:\, [*.*] - Display Monitor" id="193">
<Action>
OSE.ShowLastMenu((75, 75, 75), (255, 255, 255), u'0;-49;0;0;0;400;0;0;0;0;3;2;1;50;\uff2d\uff33 \uff30\u30b4\u30b7\u30c3\u30af', u'OSE', u'Open', 0, '', u'*.*', False, (180, 180, 180), (75, 75, 75), True)
</Action>
</Macro>
<Macro Name="On screen explorer: Go back">
<Event Name="DXusbPCR.Backspace" />
<Action>
OSE.GoBack()
</Action>
</Macro>
<Macro Name="On screen explorer: Get value: Get Menu item string">
<Action>
OSE.GetValue(0)
</Action>
<Action>
EventGhost.PythonCommand(u'print eg.result')
</Action>
<Action Enabled="False">
Window.SendKeys(u'{F5}', False)
</Action>
</Macro>
</Folder>
<Macro Name="Clear Pending Events">
<Event Name="DXusbPCR.SwitchWindows" />
<Action>
EventGhost.FlushEvents()
</Action>
</Macro>
</Folder>
</EventGhost>
