OK You lost me with the Main.Tasks| thing. I have no clue what you mean by it.
So this is what I am going to do. below is the XML code for the macros. There is a Jump in it that you will have to redo. the Jump Settings are
If: last action unsuccessful
Jump to: YouTube Not Playing
Unchecked: and return after execution
In the Checking remote button action (Python Script) you will see the following in the file.
Code: Select all
key_mapping = dict(
Replay='{Shift+P}',
Rewind='{Left}',
Play='{Space}',
Pause='{Space}',
Forward='{Right}',
Skip='{Shift+N}',
Mute='{M}',
FullScreen='{F}'
)
This is the event to keystroke mapping. You need to change the mappings to match the suffix of the event that gets triggered for the specific button you want to use.
So if you want to use the Stop button to play the YouTube video then you would change Play='{Space}' to be Stop='{Space}'.
If you want a different/multiple events to be processed by the Remote checking you will have to add the event prefix to the macro. with a .* after it. I highly recommend you do NOT use Main.* as this will parse all events that occur with the prefix of Main. If you need to add multiple events to send the keys then you will have to add a new line to the key mapping for those suffixes with the same keystroke. as you see how i did with Play and Pause
Here is the XML
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="WIP">
<Folder Name="YouTube" XML_Guid="{A1C97D94-D721-4EF7-845A-8FEED458AAB9}" Expanded="True">
<Macro Name="YouTube Remote" XML_Guid="{49AD5019-705F-4989-8D47-BC8939F6C5E7}" Expanded="True">
<Event Name="MCE.*" XML_Guid="{CE02F36F-B29A-49F7-9F1F-5954C789EF7B}" />
<Action Name="Checking remote button" XML_Guid="{6AD38DD3-3A9E-4771-A24E-0494C6280782}">
EventGhost.PythonScript(u"if not hasattr(eg.globals, 'youtube_window'):\n eg.globals.youtube_window = None\n\nkey_mapping = dict(\n Replay='{Shift+P}',\n Rewind='{Left}',\n Play='{Space}',\n Pause='{Space}',\n Forward='{Right}',\n Skip='{Shift+N}',\n Mute='{M}',\n FullScreen='{F}'\n)\n \nif eg.globals.youtube_window is None:\n eg.StopMacro()\n\nbutton = eg.eventString.split('.')[-1]\nif button not in key_mapping:\n eg.StopMacro()\n \neg.result = key_mapping[button]\n\n")
</Action>
<Action Name="Sending remote button to YouTube" XML_Guid="{265698C4-379D-4C0B-89F4-337DC37C600E}">
EventGhost.PythonCommand(u'eg.globals.youtube_window.SendKeystrokes(eg.result)')
</Action>
</Macro>
<Macro Name="Checking if YouTube is playing" XML_Guid="{A07A7A07-D2C7-4EB9-AF03-B46A39D7474C}" Expanded="True">
<Event Name="TaskMonitorPlus.Activated.firefox" XML_Guid="{5F8CE813-127D-4BEF-A3EA-59015EF265AD}" />
<Event Name="TaskMonitorPlus.TitleChanged.firefox" XML_Guid="{5BCAF444-61B3-4B78-8BBE-6DE70876D7C3}" />
<Event Name="TaskMonitorPlus.NewWindow.firefox" XML_Guid="{0CA73ACD-7DAD-40E8-93CD-C30957946250}" />
<Action Name="Checking if YouTube is playing" XML_Guid="{F0CC6812-08D1-425B-A1B8-8AEAFBD495C9}">
EventGhost.PythonScript(u"window = eg.event.payload\n\ntitle = window.title.split('-')\n\nif len(title) >= 2:\n if title[1].strip().lower() != 'youtube':\n eg.result = False\n else:\n eg.result = True\nelse:\n eg.result = False")
</Action>
<Action XML_Guid="{959AF9D3-BC54-46B9-A1B4-B86A703A6EDE}">
EventGhost.NewJumpIf(XmlIdLink(9), 1, False)
</Action>
<Action Name="YouTube is playing" XML_Guid="{82717FBE-C0F9-44D1-AC2B-76DD42AE8F11}">
EventGhost.PythonCommand(u'eg.globals.youtube_window = eg.event.payload')
</Action>
</Macro>
<Macro Name="YouTube Not Playing" id="9" XML_Guid="{A9DEB6E8-4F7E-4B9F-A005-CD3379C7368C}" Expanded="True">
<Event Name="TaskMonitorPlus.ClosedWindow.firefox" XML_Guid="{3D7A4593-EB66-49AB-BCE4-0877B0BB7F22}" />
<Action Name="YouTube is not playing" XML_Guid="{B6CD5788-431F-42CA-AE19-ABDDC6EED515}">
EventGhost.PythonCommand(u'eg.globals.youtube_window = None')
</Action>
</Macro>
</Folder>
</EventGhost>