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.

Multitap support in MCE & VMC

If you have a question or need help, this is the place to be.
Post Reply
psikey
Posts: 8
Joined: Tue Nov 27, 2007 1:20 pm

Multitap support in MCE & VMC

Post by psikey »

Hello

Only recently made aware of this program after buying a new X10 remote off ebay. Have previously used Girder with MCE2005 & an X10 remote but have moved up to Vista so thought I'd have a look into EventGhost before considering a Girder upgrade.

Anyway, got the general idea on how to use and looks easier than Girder but I have one specific requirement & wondered if its come up before.

Unlike with a genuine infrared MCE remote where pressing the numeric keys toggles through the range of codes i.e. 2,a,b,c..... etc. the x10 remote doesn't so with multi-tap a would just get 2 2 2 rather than b for example.

In vista media center (& xp mce) you can use the multitap to jump to artist or enter information in search boxes etc.

With Girder 3 I managed to figure this out after much research & trial & error and wondered if you guys can point me in the right direction to do the same with EventGhost.
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: Multitap support in MCE & VMC

Post by Bitmonster »

Well, this is just a 5 min hack, but it basically does what you want.

Place this PythonScript into your Autostart macro and let it execute:

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1196">
    <Action>
        EventGhost.PythonScript(u'TIMEOUT = 1.0 # timout in seconds\n\nLAYOUT = (\n    "0 ",\n    "1",\n    "2abc",\n    "3def",\n    "4ghi",\n    "5jkl",\n    "6mno",\n    "7pqrs",\n    "8tuv",\n    "9xyz",\n)\n\nfrom threading import Timer\n\nclass Multitapper:\n    \n    def __init__(self):\n        self.x = None\n        self.y = None\n        self.timer = Timer(0.0, self.OnTimeOut)\n    \n    \n    def OnKey(self, y):\n        self.timer.cancel()\n        if y == self.y:\n            self.x = (self.x + 1) % len(LAYOUT[y])\n        else:\n            if self.y is not None:\n                eg.TriggerEvent("Multitapper", LAYOUT[self.y][self.x])\n            self.x = 0\n        self.y = y\n        c = LAYOUT[y][self.x]\n        self.timer = Timer(1.0, self.OnTimeOut, c)\n        self.timer.start()\n        return c\n        \n        \n    def OnTimeOut(self, value):\n        self.y = None\n        eg.TriggerEvent("Multitapper", value)\n\n\neg.globals.Multitapper = Multitapper()')
    </Action>
</EventGhost>
And then you can use this group to work on the keys:

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1196">
    <Folder Name="Multitapper" Expanded="True">
        <Macro Name="Multitapper.OnKey(0)">
            <Event Name="Num0">
            </Event>
            <Action>
                EventGhost.PythonCommand(u'Multitapper.OnKey(0)')
            </Action>
            <Action>
                EventGhost.NewJumpIf(XmlIdLink(2004), 2, True)
            </Action>
        </Macro>
        <Macro Name="Multitapper.OnKey(1)">
            <Event Name="Num1">
            </Event>
            <Action>
                EventGhost.PythonCommand(u'Multitapper.OnKey(1)')
            </Action>
            <Action>
                EventGhost.NewJumpIf(XmlIdLink(2004), 2, True)
            </Action>
        </Macro>
        <Macro Name="Multitapper.OnKey(2)">
            <Event Name="Num2">
            </Event>
            <Action>
                EventGhost.PythonCommand(u'Multitapper.OnKey(2)')
            </Action>
            <Action>
                EventGhost.NewJumpIf(XmlIdLink(2004), 2, True)
            </Action>
        </Macro>
        <Macro Name="Multitapper.OnKey(3)">
            <Event Name="Num3">
            </Event>
            <Action>
                EventGhost.PythonCommand(u'Multitapper.OnKey(3)')
            </Action>
            <Action>
                EventGhost.NewJumpIf(XmlIdLink(2004), 2, True)
            </Action>
        </Macro>
        <Macro Name="Multitapper.OnKey(4)">
            <Event Name="Num4">
            </Event>
            <Action>
                EventGhost.PythonCommand(u'Multitapper.OnKey(4)')
            </Action>
            <Action>
                EventGhost.NewJumpIf(XmlIdLink(2004), 2, True)
            </Action>
        </Macro>
        <Macro Name="Multitapper.OnKey(5)">
            <Event Name="Num5">
            </Event>
            <Action>
                EventGhost.PythonCommand(u'Multitapper.OnKey(5)')
            </Action>
            <Action>
                EventGhost.NewJumpIf(XmlIdLink(2004), 2, True)
            </Action>
        </Macro>
        <Macro Name="Multitapper.OnKey(6)">
            <Event Name="Num6">
            </Event>
            <Action>
                EventGhost.PythonCommand(u'Multitapper.OnKey(6)')
            </Action>
            <Action>
                EventGhost.NewJumpIf(XmlIdLink(2004), 2, True)
            </Action>
        </Macro>
        <Macro Name="Multitapper.OnKey(7)">
            <Event Name="Num7">
            </Event>
            <Action>
                EventGhost.PythonCommand(u'Multitapper.OnKey(7)')
            </Action>
            <Action>
                EventGhost.NewJumpIf(XmlIdLink(2004), 2, True)
            </Action>
        </Macro>
        <Macro Name="Multitapper.OnKey(8)">
            <Event Name="Num8">
            </Event>
            <Action>
                EventGhost.PythonCommand(u'Multitapper.OnKey(8)')
            </Action>
            <Action>
                EventGhost.NewJumpIf(XmlIdLink(2004), 2, True)
            </Action>
        </Macro>
        <Macro Name="Multitapper.OnKey(9)">
            <Event Name="Num9">
            </Event>
            <Action>
                EventGhost.PythonCommand(u'Multitapper.OnKey(9)')
            </Action>
            <Action>
                EventGhost.NewJumpIf(XmlIdLink(2004), 2, True)
            </Action>
        </Macro>
        <Macro Name="Emulate Keystrokes: {eg.event.payload}">
            <Event Name="Main.Multitapper">
            </Event>
            <Action>
                Window.SendKeys(u'{eg.event.payload}', False)
            </Action>
            <Action>
                EventGhost.ShowOSD(u'', None, (255, 255, 255), (0, 0, 0), 0, (0, 0), 0, 3.0)
            </Action>
        </Macro>
        <Macro Name="Show OSD: {eg.result}" id="2004">
            <Action>
                EventGhost.ShowOSD(u'{eg.result}', None, (255, 255, 255), (0, 0, 0), 0, (0, 0), 0, 3.0)
            </Action>
        </Macro>
    </Folder>
</EventGhost>
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
psikey
Posts: 8
Joined: Tue Nov 27, 2007 1:20 pm

Re: Multitap support in MCE & VMC

Post by psikey »

:shock:

What a quick reply :D

Only just started trying the program today. Whats the best way to get this info into EventGhost?

I've put a Python Script action in the Autostart section then just pasted the text into the box. Is that OK as it shows on 6 lines or do I need to reformt it.

Whats the way to get the xml file in as I loose my other actions if I just open it.

Sorry for the novice questions.

PS the script creates error messages, is this normal?
psikey
Posts: 8
Joined: Tue Nov 27, 2007 1:20 pm

Re: Multitap support in MCE & VMC

Post by psikey »

OK

Managed to get the folder in by pasting the text into my saved xml file.

When EventGhost runs with the script & folder two new errors show on the LHS

Error compiling script.
Traceback (most recent call last):
SyntaxError: invalid syntax (0, line 1)

Then loads plugins
Then shows script again and errors:
Traceback (most recent call last):
AttributeError: Compile instance has no attribute 'code'

Looks like pasting in the script text is no good. I'll try some other things. If you get chance, please tell me what I did wrong.
psikey
Posts: 8
Joined: Tue Nov 27, 2007 1:20 pm

Re: Multitap support in MCE & VMC

Post by psikey »

Managed to get the script to run without errors by deleting the \n (assume its new line code or something) and just pasting the <Action> part into the startup xml file.


Is this correct?

Now if I just assign a number key (say the 1 key) to multiplier.onkey(1) it Shows NONE in the top corner and:

Multitapper.OnKey(1)
Error in Action: "Multitapper.OnKey(1)"
Jump to "Show OSD: {eg.result}" and return
Show OSD: {eg.result}

Any advice appreciated. I'm trying all this at work so don't have access to my remote at the moment but would imagine it should work on any key press associated with multitapper.onkey(1).
CollinR
Experienced User
Posts: 265
Joined: Tue Sep 05, 2006 7:16 am
Location: Oklahoma
Contact:

Re: Multitap support in MCE & VMC

Post by CollinR »

Just copy and paste that stuff directly into the left pane of EventGhost. EventGhost is smart enough to know you want that XML added to the current XML config file. It's awesome!
psikey
Posts: 8
Joined: Tue Nov 27, 2007 1:20 pm

Re: Multitap support in MCE & VMC

Post by psikey »

CollinR wrote:Just copy and paste that stuff directly into the left pane of EventGhost. EventGhost is smart enough to know you want that XML added to the current XML config file. It's awesome!
:D

Thanks, worked a treat (but its RHS not LHS, facing screen anyway :wink: )

I'll see if it works now then.

.
.
.
EDIT: Well its working using the keypad number keys by showing correct entry in top corner. Just need to see how it works with remote and MCE/VMC tonight when I get home.

Really appreciate the help. Wouldn't have had a clue on how to do that myself.


Just another question.

The X10 remote I bought came with a driver that lets it operate MCE/VMC and if I press the "DISC" button while in media center it jumps to the Videos section as expected. Outside of MCE/VMC at the desktop I've just discovered the "DISC" button opens & closes PowerDVD as a toggle.

Would this functionality be part of the driver? If so, is there a way to stop this or will it interfere with the events I create in EventGhost or will EventGhost replace these existing button functions if I create them.

Maybe this Multitapper should become part of the next update. Can't believe I'm the first person to mention that x10 remotes (maybe others?) doesn't provide basic alpha-numeric keypad function in MCE2005 or VMC. The standard infr-red media remote I used previously did.

Looks like EventGhost is going to replace Girder for me & I'll make a donation when I have it doing everthing I need. Basic usage is easier than with Girder but how do I learn about creating custom scripts & plugins or do you need to be a good/experienced programmer to do that kind of stuff.
psikey
Posts: 8
Joined: Tue Nov 27, 2007 1:20 pm

Re: Multitap support in MCE & VMC

Post by psikey »

After some advice again.

I've currently got a dual boot of MCE2005 & Vista64 Premium.

The multitapper tried to work in both but a get the initial key press showing in Media Center in addition to the Multimapper one.

i.e. if I want a "b" I press the 2 key 3 times but instead of getting the "b" I get 2-2-2-b (Media Player sees all 3 key presses then multitapper adds a b on the end).

In MCE2005 I had an XP X10 remote driver that came with an old PC designed for Cyberlink Power Cinema and if I use this driver instead of the standard X10 driver that came with the remote it works without showing the initial presses.

I managed to find an alternative X10 driver on the web for Vista but that still works as stated above. I ultimately want to solely use Vista I appreciate any advice on solving this problem in Vista.

Thanks
simonp
Posts: 3
Joined: Tue Dec 04, 2007 3:24 am

Re: Multitap support in MCE & VMC

Post by simonp »

What an awesome piece of software, I am currently trying to get my teeth in to it.

I have tried to use the above mentioned code in EG but have the following problem.

Lets use key 2 as an example:

1 - I add numpad.2 key as the trigger for this - all works 100% - If I tap numpad.2 only once i get keyboard.2 in reply. All OK. If I tap it twice I get the keyboard.a in reply. All OK.

2 - Unfortunately my remote number keys only output keyboard.2 (NOT numpad.2). If I add keyboard.2 as the trigger action and only push the 2 key once then EG waits a second to see if the key is pushed again and then outputs keyboard.2. This causes the macro to trigger again and I am stuck in a loop untill I push the 2 key again.

I have tried to look at the code and adjust the script to output numpad.2 but I actually have no idea how.

Can this be done? How?

Thanks
Simon
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: Multitap support in MCE & VMC

Post by Bitmonster »

Edit the script this way:

Code: Select all

TIMEOUT = 1.0 # timout in seconds

LAYOUT = (
    ("{Numpad0}", ),
    ("{Numpad1}", ),
    ("{Numpad2}", "a", "b", "c"),
    ("{Numpad3}", "d", "e", "f"),
    ("{Numpad4}", "g", "h", "i"),
    ("{Numpad5}", "j", "k", "l"),
    ("{Numpad6}", "m", "n", "o"),
    ("{Numpad7}", "p", "q", "r", "s"),
    ("{Numpad8}", "t", "u", "v"),
    ("{Numpad9}", "w", "x", "y", "z"),
)


from threading import Timer

class Multitapper:
    
    def __init__(self):
        self.x = None
        self.y = None
        self.timer = Timer(0.0, self.OnTimeOut)
    
    
    def OnKey(self, y):
        self.timer.cancel()
        if y == self.y:
            self.x = (self.x + 1) % len(LAYOUT[y])
        else:
            if self.y is not None:
                eg.TriggerEvent("Multitapper", LAYOUT[self.y][self.x])
            self.x = 0
        self.y = y
        c = LAYOUT[y][self.x]
        self.timer = Timer(1.0, self.OnTimeOut, [c])
        self.timer.start()
        return c
        
        
    def OnTimeOut(self, value):
        self.y = None
        eg.TriggerEvent("Multitapper", value)


eg.globals.Multitapper = Multitapper()
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
simonp
Posts: 3
Joined: Tue Dec 04, 2007 3:24 am

Re: Multitap support in MCE & VMC

Post by simonp »

Bitmonster,

Thanks, that works 100%. I was trying to modify the 'LAYOUT' section but I was unsure of the formatting.
I kept getting just the { in return. I did not know about the brackets().

Regards
Simon.
Post Reply