I am using a macro to check what monitor the display is on first either secondary or primary monitor.
Code: Select all
from win32gui import GetWindowPlacement
#SW_SHOWNORMAL = 1
#SW_SHOWMINIMIZED = 2
#SW_SHOWMAXIMIZED = 3
FindWin = eg.WindowMatcher(None, None, u'MediaPlayerClassicW' , None, None, None, True, 0.0, 0)
hwnd = FindWin()
def GetWindowStatus(hwnd):
showList = (None, "Normal", "Minimized", "Maximized")
placement = GetWindowPlacement(hwnd)
#unrem the below line to display the placement values that you need for the if placement[4] line
print placement
if placement[4] == (1680, 1050, 2960, 1770):
return "Fullscreen"
else:
return showList[placement[1]]
eg.globals.WindowsState = GetWindowStatus(hwnd[0])
print "Windows State = " + eg.globals.WindowsState
Once I know what monitor I am than using the above script to display volume level for Media Player Classic. But because of the way Windows 7 works it assigns my HDTV as Monitor one which is at 720p (1280 x 720) and the primary monitor is running at 1680 x 1050. When the MPC is at full screen resolution I have it switch to the HDTV monitor 1 so the above script was the best way for me to determine my fullscreen is enabled or not. Once I have my fullscreen variable I than show the volume for MPC Home.
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1544">
<Folder Name="Volume Controls" Expanded="True">
<Macro Name="Volume Up">
<Event Name="DXusbPCR.Num2" />
<Event Name="PcRemoteController.Up" />
<Action>
EventGhost.NewJumpIf(XmlIdLink(252), 2, True)
</Action>
<Action Name="Python Script Bar Method" Enabled="False">
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\nM = 2\n\nif len(hwnd) > 0:\n if eg.globals.WindowsState <> "Fullscreen":\n factor = 5\n mon = 1\n else:\n factor = 5\n mon = 0\n volume = SendMessage(hwnd[0], TBM_GETPOS, 0, 0)\n bar = volume * M/factor * u\'\\u2588\'\n if volume == 1 : volume = 0\n eg.plugins.EventGhost.ShowOSD(u\'Volume: %s %i%%\' % (bar, volume), u\'0;-36;0;0;0;400;0;0;0;238;3;2;1;49;Lucida Console\', (255, 0, 0), (0, 0, 0), 0, (60, 150), mon, 2.0, False)\nelse:\n print "Window not found"')
</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 = 0\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="PcRemoteController.Down" />
<Action>
EventGhost.NewJumpIf(XmlIdLink(252), 2, True)
</Action>
<Action Name="Python Script Bar Method" Enabled="False">
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\nM = 2\n\nif len(hwnd) > 0:\n if eg.globals.WindowsState <> "Fullscreen":\n factor = 5\n mon = 1\n else:\n factor = 5\n mon = 0\n volume = SendMessage(hwnd[0], TBM_GETPOS, 0, 0)\n bar = volume * M/factor * u\'\\u2588\'\n if volume == 1 : volume = 0\n eg.plugins.EventGhost.ShowOSD(u\'Volume: %s %i%%\' % (bar, volume), u\'0;-36;0;0;0;400;0;0;0;238;3;2;1;49;Lucida Console\', (255, 0, 0), (0, 0, 0), 0, (60, 150), mon, 2.0, False)\nelse:\n print "Window not found"')
</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 = 0\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>
</EventGhost>
But the major requirement would be to have the display set from top not bottom of the screen. Right now I have to manually guesstimate to get it as close to say around 100 pixels from the top of the screen. That is the reason I am using top in the one place value because I did not know how to do the value from the top of the screen and not the bottom. Too bad MPC does not have a way to get full screen status easily but the code you helped me with is still going strong just have to print new values if used on a different video card or screen resolution.