Techniques: controlling multiple programs

If you have a question or need help, this is the place to be.
User avatar
WharfRat
Experienced User
Posts: 159
Joined: Wed Dec 25, 2013 11:56 am

Techniques: controlling multiple programs

Post by WharfRat » Thu Jan 02, 2014 1:15 pm

Techniques: controlling multiple programs

I started this forum topic to explain something from a question in another forum topic (viewtopic.php?f=9&t=5927).

Hopefully, more experienced users can improve on these techniques, or describe other ones in a similar format.

:!: EDIT : updated 13 Feb 2014

Originally, this topic used the PHX01RN remote control in the example techniques.
All references to that remote control have now been removed, and a generic instance of the Desktop Remote is used instead.
Anyone can use the examples immediately now, since no modification is necessary.

Naturally, the Desktop Remote cannot simulate the mouse emulation mode perfectly.

As a convenience, you can download the EventGhost XML configuration files for these techniques here:
t_cmp_20140213.zip
all 4 techniques and a readme.txt
(10.61 KiB) Downloaded 227 times
Last edited by WharfRat on Sun Feb 16, 2014 8:01 am, edited 4 times in total.
EventGhost 0.4.1.r1640
PHX01RN plugin v3.0.1
Windows XP 32bit (v5.1 Build 2600 Service Pack 2)
Windows7 64bit (v6.1 Build 7601 Service Pack 1)

User avatar
WharfRat
Experienced User
Posts: 159
Joined: Wed Dec 25, 2013 11:56 am

Re: Techniques: controlling multiple programs

Post by WharfRat » Thu Jan 02, 2014 1:22 pm

Every new EventGhost user experiences this.
You have managed to get your remote control to work with your favorite program.
Now you want to control more than one program.

But you discover a problem.
If you press the Stop button, which program should perform the Stop Action?

The solution to this problem is often referred to as a 'context folder'.
A 'context folder' is a folder, in the configuration tree, in which only one item is active at a time.
You use an 'exclusive enable' to activate a particular item in a 'context folder'.
When something is 'exclusivly enabled' then everything else in that 'context folder' is disabled.
Disabled items do not receive any events.
(I sometimes refer to modes instead of contexts)

There are a few different ways to accomplish this.
I will show you three techniques, and a variation for one of those techniques.
The variation can be applied to the other two techniques as well.

These examples are quite simple, and do not depend on any particular setup.
(Caveat: this is true for Windows XP 32bit and Windows 7 64bit, so far)

They have 5 different contexts:
  • none
    system
    mouse
    Notepad
    Calculator
The none context is useful, because it can generate events in the Log without doing anything.
The system context is for non-specific tasks, like ejecting CDs/DVDs, Alt+Tab, shutting down the computer, etc.
The mouse, Notepad and Calculator contexts are obviously specific tasks.

The system context reacts to the Info button.
The mouse context reacts to the direction buttons, and the L and R buttons.
The Notepad context reacts to the Power button.
The Calculator context reacts to the Power button.

So our problem is, which program (Notepad or Calculator) should react to the Power button?

As a bonus, the examples show how to start and stop a program using just one button, i.e. Power.
(I usually assign a screen magnifier program to the Power button for the mouse context)

You can either download the ZIP file, or Select All and Copy and then Paste each example into Notepad and save it as an XML file somewhere.
After that, open the example configurations in EventGhost.
Keep EventGhost open on the desktop so you can see what happens.

To see what is happening, expand and/or collapse the configuration tree as follows:
t_cmp_tree.png
configuration tree
t_cmp_tree.png (10.91 KiB) Viewed 6681 times
After you have seen what is happening, you can expand the configuration tree further to see how it happens.
The 'not important' folder is used for the Desktop Remote and the Log, so you can ignore it.

All of the examples use an Init Macro to set the initial context.
Last edited by WharfRat on Sun Feb 16, 2014 8:04 am, edited 3 times in total.
EventGhost 0.4.1.r1640
PHX01RN plugin v3.0.1
Windows XP 32bit (v5.1 Build 2600 Service Pack 2)
Windows7 64bit (v6.1 Build 7601 Service Pack 1)

User avatar
WharfRat
Experienced User
Posts: 159
Joined: Wed Dec 25, 2013 11:56 am

Re: Techniques: controlling multiple programs

Post by WharfRat » Thu Jan 02, 2014 1:38 pm

Technique 1 : a button for each context

This is usually what eveyone does first.
(t_cmp_1.xml)

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1640" Guid="{1A091E46-3F6E-4A9D-B180-5B02BBFCD4B3}" Time="1392181826.36">
    <Autostart Name="Autostart" Expanded="True">
        <Plugin Identifier="DesktopRemote" Guid="{5DFFBD61-7582-4D6F-8EA9-9CB36284C9CF}" File="DesktopRemote">
            gAIpLg==
        </Plugin>
    </Autostart>
    <Folder Name="not important">
        <Folder Name="generic remote">
            <Macro Name="show">
                <Event Name="Main.OnInit" />
                <Action>
                    DesktopRemote.CreateNew(40, 40, 3, 3, 4, (108, 108, 108), (255, 255, 255), (78, 78, 78), u'0;-13;0;0;0;700;0;0;0;0;3;2;1;34;Arial', u'remote', 1, True, True, True)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'width': 183, 'label': u'increase width of remote', 'event': u'', 'height': 5})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 0, 0), 'label': u'\xa1', 'event': u'generic.Power', 'fontInfo': u'0;-19;0;0;0;400;0;0;0;2;3;2;1;2;Wingdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (0, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.Function', 'label': u'Fn'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(25)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Wingdings 2', 'event': u'generic.Documents', 'label': u'/'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Music', 'label': u'\xaf'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;2;Wingdings', 'event': u'generic.Pictures', 'label': u'J'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Videos', 'label': u'\xb9'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(5)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u':', 'event': u'generic.Cancel', 'fontInfo': u'0;-16;0;0;0;700;0;0;0;2;3;2;1;18;Wingdings 3'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'0', 'event': u'generic.Minimize', 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'1', 'event': u'generic.Maximize', 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'i', 'event': u'generic.Info', 'fontInfo': u'0;-13;0;0;0;700;0;0;0;0;3;2;1;34;Arial'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(15)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-13;0;0;0;700;0;0;0;0;3;2;1;34;Arial', 'event': u'generic.LeftClick', 'label': u'L'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-13;0;0;0;700;0;0;0;0;3;2;1;34;Arial', 'event': u'generic.RightClick', 'label': u'R'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'width': 18, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-13;0;0;0;400;0;0;0;2;3;2;1;18;Wingdings 3', 'event': u'generic.Up', 'label': u'\xe3'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'width': 19, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-13;0;0;0;400;0;0;0;2;3;2;1;18;Wingdings 3', 'event': u'generic.Left', 'label': u'\xe1'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-16;0;0;0;700;0;0;0;2;3;2;1;18;Wingdings 3', 'event': u'generic.OK', 'label': u'8'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-13;0;0;0;400;0;0;0;2;3;2;1;18;Wingdings 3', 'event': u'generic.Right', 'label': u'\xe2'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'width': 18, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-13;0;0;0;400;0;0;0;2;3;2;1;18;Wingdings 3', 'event': u'generic.Down', 'label': u'\xe4'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'width': 19, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(15)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'<', 'event': u'generic.Stop', 'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'4', 'event': u'generic.Play', 'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'=', 'foregroundColour': (255, 0, 0), 'event': u'generic.Record', 'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u';', 'event': u'generic.Pause', 'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'9', 'event': u'generic.Previous', 'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'7', 'event': u'generic.Rewind', 'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'8', 'event': u'generic.FastForward', 'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u':', 'event': u'generic.Next', 'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'X', 'event': u'generic.Mute', 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.1', 'label': u'1'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.2', 'label': u'2'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.3', 'label': u'3'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Increase', 'label': u'5'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.4', 'label': u'4'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.5', 'label': u'5'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.6', 'label': u'6'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Decrease', 'label': u'6'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.7', 'label': u'7'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.8', 'label': u'8'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.9', 'label': u'9'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-16;0;0;0;700;0;0;0;0;3;2;1;34;Arial', 'event': u'generic.Plus', 'label': u'+'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'label': u'\xd4', 'foregroundColour': (0, 0, 0), 'event': u'generic.Star', 'fontInfo': u'0;-16;0;0;0;700;0;0;0;2;3;2;1;18;Wingdings 2'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.0', 'label': u'0'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'label': u'#', 'foregroundColour': (0, 0, 0), 'event': u'generic.Hash', 'fontInfo': u'0;-16;0;0;0;700;0;0;0;0;3;2;1;34;Arial'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-19;0;0;0;700;0;0;0;0;3;2;1;34;Arial', 'event': u'generic.Minus', 'label': u'-'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.Show(10, 10, True)
                </Action>
                <Action>
                    EventGhost.TriggerEvent(u'check_for_remote', 0.0)
                </Action>
            </Macro>
        </Folder>
        <Folder Name="log pane">
            <Macro Name="check for remote">
                <Event Name="Main.check_for_remote" />
                <Action>
                    Window.FindWindow(None, u'remote', u'wxWindowClassNR', None, None, 1, False, 0.0, 2)
                </Action>
                <Action>
                    EventGhost.NewJumpIf(XmlIdLink(90), 1, False)
                </Action>
                <Action>
                    EventGhost.TriggerEvent(u'setup_log_pane', 0.0)
                </Action>
            </Macro>
            <Macro Name="wait for remote" id="90">
                <Action>
                    EventGhost.Wait(0.25)
                </Action>
                <Action>
                    EventGhost.TriggerEvent(u'check_for_remote', 0.0)
                </Action>
            </Macro>
            <Macro Name="setup log pane">
                <Event Name="Main.setup_log_pane" />
                <Action>
                    EventGhost.PythonScript(u'eg.Wait(0.5)\neg.log.ctrl.data.clear()\neg.Wait(0.25)\nprint "Technique 1"\nprint ""\nprint "select the mode with these buttons:"\nprint "   Function (blue Fn)"\nprint "   Documents"\nprint "   Music"\nprint "   Pictures"\nprint "   Videos"\nprint ""\nprint "system mode buttons:"\nprint "   Info (black i)"\nprint ""\nprint "mouse mode buttons:"\nprint "   L R up down left right"\nprint ""\nprint "Notepad mode buttons:"\nprint "   Power (red O)"\nprint ""\nprint "Calculator mode buttons:"\nprint "   Power (red O)"\nprint ""')
                </Action>
            </Macro>
        </Folder>
    </Folder>
    <Macro Name="Init" Expanded="True">
        <Event Name="Main.OnInit" />
        <Action>
            EventGhost.EnableExclusive(XmlIdLink(101))
        </Action>
    </Macro>
    <Folder Name="modes" Expanded="True">
        <Folder Name="select" Expanded="True">
            <Macro Name="select none">
                <Event Name="DesktopRemote.generic.Function" />
                <Action>
                    EventGhost.ShowOSD(u'none', u'0;-128;0;0;0;700;0;0;0;255;1;2;1;49;Terminal', (0, 255, 0), (0, 128, 0), 6, (0, 0), 0, 3.0, False)
                </Action>
                <Action>
                    EventGhost.EnableExclusive(XmlIdLink(101))
                </Action>
            </Macro>
            <Macro Name="select system">
                <Event Name="DesktopRemote.generic.Documents" />
                <Action>
                    EventGhost.ShowOSD(u'system', u'0;-128;0;0;0;700;0;0;0;255;1;2;1;49;Terminal', (0, 255, 0), (0, 128, 0), 6, (0, 0), 0, 3.0, False)
                </Action>
                <Action>
                    EventGhost.EnableExclusive(XmlIdLink(102))
                </Action>
            </Macro>
            <Macro Name="select mouse">
                <Event Name="DesktopRemote.generic.Music" />
                <Action>
                    EventGhost.ShowOSD(u'mouse', u'0;-128;0;0;0;700;0;0;0;255;1;2;1;49;Terminal', (0, 255, 0), (0, 128, 0), 6, (0, 0), 0, 3.0, False)
                </Action>
                <Action>
                    EventGhost.EnableExclusive(XmlIdLink(107))
                </Action>
            </Macro>
            <Macro Name="select Notepad">
                <Event Name="DesktopRemote.generic.Pictures" />
                <Action>
                    EventGhost.ShowOSD(u'Notepad', u'0;-128;0;0;0;700;0;0;0;255;1;2;1;49;Terminal', (0, 255, 0), (0, 128, 0), 6, (0, 0), 0, 3.0, False)
                </Action>
                <Action>
                    EventGhost.EnableExclusive(XmlIdLink(126))
                </Action>
            </Macro>
            <Macro Name="select Calculator">
                <Event Name="DesktopRemote.generic.Videos" />
                <Action>
                    EventGhost.ShowOSD(u'Calculator', u'0;-128;0;0;0;700;0;0;0;255;1;2;1;49;Terminal', (0, 255, 0), (0, 128, 0), 6, (0, 0), 0, 3.0, False)
                </Action>
                <Action>
                    EventGhost.EnableExclusive(XmlIdLink(139))
                </Action>
            </Macro>
        </Folder>
        <Folder Name="mode" Expanded="True">
            <Folder Name="mode none" id="101" />
            <Folder Name="mode system" id="102" Enabled="False">
                <Macro Name="time">
                    <Event Name="DesktopRemote.generic.Info" />
                    <Action>
                        EventGhost.PythonScript(u"import time\nt = time.localtime()\neg.result = '% 2i' %t.tm_hour + ':' + '%02i' %t.tm_min")
                    </Action>
                    <Action>
                        EventGhost.ShowOSD(u'{eg.result}', u'0;-128;0;0;0;700;0;0;0;255;1;2;1;49;Terminal', (0, 255, 0), (0, 128, 0), 0, (80, 40), 0, 3.0, False)
                    </Action>
                </Macro>
            </Folder>
            <Folder Name="mode mouse" id="107" Enabled="False">
                <Macro Name="Mouse Move Up">
                    <Event Name="DesktopRemote.generic.Up" />
                    <Action>
                        Mouse.GoDirection(0)
                    </Action>
                </Macro>
                <Macro Name="Mouse Move Down">
                    <Event Name="DesktopRemote.generic.Down" />
                    <Action>
                        Mouse.GoDirection(u'180')
                    </Action>
                </Macro>
                <Macro Name="Mouse Move Left">
                    <Event Name="DesktopRemote.generic.Left" />
                    <Action>
                        Mouse.GoDirection(270)
                    </Action>
                </Macro>
                <Macro Name="Mouse Move Right">
                    <Event Name="DesktopRemote.generic.Right" />
                    <Action>
                        Mouse.GoDirection(90)
                    </Action>
                </Macro>
                <Macro Name="Left Mouse Button">
                    <Event Name="DesktopRemote.generic.LeftClick" />
                    <Action>
                        Mouse.LeftButton()
                    </Action>
                </Macro>
                <Macro Name="Right Mouse Button">
                    <Event Name="DesktopRemote.generic.RightClick" />
                    <Action>
                        Mouse.RightButton()
                    </Action>
                </Macro>
            </Folder>
            <Folder Name="mode Notepad" id="126" Enabled="False">
                <Folder Name="power">
                    <Macro Name="power">
                        <Event Name="DesktopRemote.generic.Power" />
                        <Action>
                            Window.FindWindow(u'notepad.exe', None, None, None, None, None, False, 0.0, 2)
                        </Action>
                        <Action>
                            EventGhost.NewJumpIf(XmlIdLink(133), 1, False)
                        </Action>
                        <Action>
                            EventGhost.NewJumpIf(XmlIdLink(135), 2, False)
                        </Action>
                    </Macro>
                    <Macro Name="start program" id="133">
                        <Action>
                            System.Execute(u'C:\\WINDOWS\\NOTEPAD.EXE', u'', 0, False, 2, u'', False)
                        </Action>
                    </Macro>
                    <Macro Name="stop program" id="135">
                        <Action>
                            Window.FindWindow(u'notepad.exe', None, None, None, None, None, False, 0.0, 2)
                        </Action>
                        <Action>
                            Window.BringToFront()
                        </Action>
                        <Action>
                            Window.Close()
                        </Action>
                    </Macro>
                </Folder>
            </Folder>
            <Folder Name="mode Calculator" id="139" Enabled="False">
                <Folder Name="power">
                    <Macro Name="power">
                        <Event Name="DesktopRemote.generic.Power" />
                        <Action>
                            Window.FindWindow(u'calc.exe', None, None, None, None, None, False, 0.0, 2)
                        </Action>
                        <Action>
                            EventGhost.NewJumpIf(XmlIdLink(146), 1, False)
                        </Action>
                        <Action>
                            EventGhost.NewJumpIf(XmlIdLink(148), 2, False)
                        </Action>
                    </Macro>
                    <Macro Name="start program" id="146">
                        <Action>
                            System.Execute(u'C:\\WINDOWS\\system32\\calc.exe', u'', 0, False, 2, u'', False)
                        </Action>
                    </Macro>
                    <Macro Name="stop program" id="148">
                        <Action>
                            Window.FindWindow(u'calc.exe', None, None, None, None, None, False, 0.0, 2)
                        </Action>
                        <Action>
                            Window.BringToFront()
                        </Action>
                        <Action>
                            Window.Close()
                        </Action>
                    </Macro>
                </Folder>
            </Folder>
        </Folder>
    </Folder>
</EventGhost>
Change the context with the Function, Documents, Music, Pictures and Videos buttons.
Try the other context-specific buttons (Info, Up, Down, Left, Right, L, R, and Power) as well.
Note how the Power button has different contexts for the Notepad and Calculator modes.

In this case, mode is the context folder.
Only one item in the context folder is enabled at any moment.
The context selection commands (for the Function, Documents, etc. buttons) are not in a context folder.
The select folder contains the commands which change the context.

Expand the configuration tree to see how it works.
Also use Configure Item to see any additional settings that may be used.

Opinion: It is easy to implement, but you will run out of buttons if you have a lot of contexts.
Last edited by WharfRat on Wed Feb 12, 2014 8:39 pm, edited 3 times in total.
EventGhost 0.4.1.r1640
PHX01RN plugin v3.0.1
Windows XP 32bit (v5.1 Build 2600 Service Pack 2)
Windows7 64bit (v6.1 Build 7601 Service Pack 1)

User avatar
WharfRat
Experienced User
Posts: 159
Joined: Wed Dec 25, 2013 11:56 am

Re: Techniques: controlling multiple programs

Post by WharfRat » Thu Jan 02, 2014 1:46 pm

Technique 2 : a menu for contexts

This is what eveyone usually does next.
(t_cmp_2.xml)

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1640" Guid="{88791E36-9CD4-436F-8E1F-D81FE22FB7BD}" Time="1392181867.38">
    <Autostart Name="Autostart" Expanded="True">
        <Plugin Identifier="DesktopRemote" Guid="{5DFFBD61-7582-4D6F-8EA9-9CB36284C9CF}" File="DesktopRemote">
            gAIpLg==
        </Plugin>
        <Plugin Identifier="OSM" Guid="{FCF3C7A7-FBC1-444D-B768-9477521946DC}" File="OSM">
            gAIpLg==
        </Plugin>
    </Autostart>
    <Folder Name="not important">
        <Folder Name="generic remote">
            <Macro Name="show">
                <Event Name="Main.OnInit" />
                <Action>
                    DesktopRemote.CreateNew(40, 40, 3, 3, 4, (108, 108, 108), (255, 255, 255), (78, 78, 78), u'0;-13;0;0;0;700;0;0;0;0;3;2;1;34;Arial', u'remote', 1, True, True, True)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'width': 183, 'label': u'increase width of remote', 'event': u'', 'height': 5})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 0, 0), 'label': u'\xa1', 'event': u'generic.Power', 'fontInfo': u'0;-19;0;0;0;400;0;0;0;2;3;2;1;2;Wingdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (0, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.Function', 'label': u'Fn'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(25)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Wingdings 2', 'event': u'generic.Documents', 'label': u'/'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Music', 'label': u'\xaf'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;2;Wingdings', 'event': u'generic.Pictures', 'label': u'J'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Videos', 'label': u'\xb9'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(5)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u':', 'event': u'generic.Cancel', 'fontInfo': u'0;-16;0;0;0;700;0;0;0;2;3;2;1;18;Wingdings 3'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'0', 'event': u'generic.Minimize', 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'1', 'event': u'generic.Maximize', 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'i', 'event': u'generic.Info', 'fontInfo': u'0;-13;0;0;0;700;0;0;0;0;3;2;1;34;Arial'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(15)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-13;0;0;0;700;0;0;0;0;3;2;1;34;Arial', 'event': u'generic.LeftClick', 'label': u'L'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-13;0;0;0;700;0;0;0;0;3;2;1;34;Arial', 'event': u'generic.RightClick', 'label': u'R'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'width': 18, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-13;0;0;0;400;0;0;0;2;3;2;1;18;Wingdings 3', 'event': u'generic.Up', 'label': u'\xe3'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'width': 19, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-13;0;0;0;400;0;0;0;2;3;2;1;18;Wingdings 3', 'event': u'generic.Left', 'label': u'\xe1'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-16;0;0;0;700;0;0;0;2;3;2;1;18;Wingdings 3', 'event': u'generic.OK', 'label': u'8'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-13;0;0;0;400;0;0;0;2;3;2;1;18;Wingdings 3', 'event': u'generic.Right', 'label': u'\xe2'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'width': 18, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-13;0;0;0;400;0;0;0;2;3;2;1;18;Wingdings 3', 'event': u'generic.Down', 'label': u'\xe4'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'width': 19, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(15)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'<', 'event': u'generic.Stop', 'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'4', 'event': u'generic.Play', 'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'=', 'foregroundColour': (255, 0, 0), 'event': u'generic.Record', 'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u';', 'event': u'generic.Pause', 'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'9', 'event': u'generic.Previous', 'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'7', 'event': u'generic.Rewind', 'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'8', 'event': u'generic.FastForward', 'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u':', 'event': u'generic.Next', 'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'X', 'event': u'generic.Mute', 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.1', 'label': u'1'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.2', 'label': u'2'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.3', 'label': u'3'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Increase', 'label': u'5'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.4', 'label': u'4'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.5', 'label': u'5'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.6', 'label': u'6'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Decrease', 'label': u'6'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.7', 'label': u'7'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.8', 'label': u'8'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.9', 'label': u'9'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-16;0;0;0;700;0;0;0;0;3;2;1;34;Arial', 'event': u'generic.Plus', 'label': u'+'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'label': u'\xd4', 'foregroundColour': (0, 0, 0), 'event': u'generic.Star', 'fontInfo': u'0;-16;0;0;0;700;0;0;0;2;3;2;1;18;Wingdings 2'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.0', 'label': u'0'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'label': u'#', 'foregroundColour': (0, 0, 0), 'event': u'generic.Hash', 'fontInfo': u'0;-16;0;0;0;700;0;0;0;0;3;2;1;34;Arial'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-19;0;0;0;700;0;0;0;0;3;2;1;34;Arial', 'event': u'generic.Minus', 'label': u'-'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.Show(10, 10, True)
                </Action>
                <Action>
                    EventGhost.TriggerEvent(u'check_for_remote', 0.0)
                </Action>
            </Macro>
        </Folder>
        <Folder Name="log pane">
            <Macro Name="check for remote">
                <Event Name="Main.check_for_remote" />
                <Action>
                    Window.FindWindow(None, u'remote', u'wxWindowClassNR', None, None, 1, False, 0.0, 2)
                </Action>
                <Action>
                    EventGhost.NewJumpIf(XmlIdLink(91), 1, False)
                </Action>
                <Action>
                    EventGhost.TriggerEvent(u'setup_log_pane', 0.0)
                </Action>
            </Macro>
            <Macro Name="wait for remote" id="91">
                <Action>
                    EventGhost.Wait(0.25)
                </Action>
                <Action>
                    EventGhost.TriggerEvent(u'check_for_remote', 0.0)
                </Action>
            </Macro>
            <Macro Name="setup log pane">
                <Event Name="Main.setup_log_pane" />
                <Action>
                    EventGhost.PythonScript(u'eg.Wait(0.5)\neg.log.ctrl.data.clear()\neg.Wait(0.25)\nprint "Technique 2"\nprint ""\nprint "select the mode with this button:"\nprint "   Function (blue Fn)"\nprint "navigate the menu with these buttons:"\nprint "   up down"\nprint "   OK (black down-and-left)"\nprint "   Cancel (black up-and-left)"\nprint ""\nprint "system mode buttons:"\nprint "   Info (black i)"\nprint ""\nprint "mouse mode buttons:"\nprint "   L R up down left right"\nprint ""\nprint "Notepad mode buttons:"\nprint "   Power (red O)"\nprint ""\nprint "Calculator mode buttons:"\nprint "   Power (red O)"\nprint ""')
                </Action>
            </Macro>
        </Folder>
    </Folder>
    <Macro Name="Init" Expanded="True">
        <Event Name="Main.OnInit" />
        <Action>
            EventGhost.EnableExclusive(XmlIdLink(118))
        </Action>
    </Macro>
    <Folder Name="modes" Expanded="True">
        <Folder Name="mode menu" Expanded="True">
            <Macro Name="Show menu">
                <Event Name="DesktopRemote.generic.Function" />
                <Action Name="OS Menu: modes">
                    OSM.ShowMenu([(u'none', u'none'), (u'system', u'system'), (u'mouse', u'mouse'), (u'Notepad', u'Notepad'), (u'Calculator', u'Calculator')], (75, 75, 75), (180, 180, 180), u'0;-48;0;0;0;400;0;0;0;0;0;0;0;0;MS Shell Dlg 2', u'OSM.modes', 0, 0, (180, 180, 180), (75, 75, 75), False, False)
                </Action>
            </Macro>
            <Macro Name="Cursor Up">
                <Event Name="DesktopRemote.generic.Up" />
                <Action>
                    OSM.MoveUp()
                </Action>
            </Macro>
            <Macro Name="Cursor Down">
                <Event Name="DesktopRemote.generic.Down" />
                <Action>
                    OSM.MoveDown()
                </Action>
            </Macro>
            <Macro Name="OK">
                <Event Name="DesktopRemote.generic.OK" />
                <Action>
                    OSM.OK_Btn()
                </Action>
            </Macro>
            <Macro Name="Cancel">
                <Event Name="DesktopRemote.generic.Cancel" />
                <Action>
                    OSM.Cancel_Btn()
                </Action>
            </Macro>
        </Folder>
        <Folder Name="select" Expanded="True">
            <Macro Name="select none">
                <Event Name="OSM.modes.none" />
                <Action>
                    EventGhost.ShowOSD(u'none', u'0;-128;0;0;0;700;0;0;0;255;1;2;1;49;Terminal', (0, 255, 0), (0, 128, 0), 6, (0, 0), 0, 3.0, False)
                </Action>
                <Action>
                    EventGhost.EnableExclusive(XmlIdLink(118))
                </Action>
            </Macro>
            <Macro Name="select system">
                <Event Name="OSM.modes.system" />
                <Action>
                    EventGhost.ShowOSD(u'system', u'0;-128;0;0;0;700;0;0;0;255;1;2;1;49;Terminal', (0, 255, 0), (0, 128, 0), 6, (0, 0), 0, 3.0, False)
                </Action>
                <Action>
                    EventGhost.EnableExclusive(XmlIdLink(119))
                </Action>
            </Macro>
            <Macro Name="select mouse">
                <Event Name="OSM.modes.mouse" />
                <Action>
                    EventGhost.ShowOSD(u'mouse', u'0;-128;0;0;0;700;0;0;0;255;1;2;1;49;Terminal', (0, 255, 0), (0, 128, 0), 6, (0, 0), 0, 3.0, False)
                </Action>
                <Action>
                    EventGhost.EnableExclusive(XmlIdLink(124))
                </Action>
            </Macro>
            <Macro Name="select Notepad">
                <Event Name="OSM.modes.Notepad" />
                <Action>
                    EventGhost.ShowOSD(u'Notepad', u'0;-128;0;0;0;700;0;0;0;255;1;2;1;49;Terminal', (0, 255, 0), (0, 128, 0), 6, (0, 0), 0, 3.0, False)
                </Action>
                <Action>
                    EventGhost.EnableExclusive(XmlIdLink(143))
                </Action>
            </Macro>
            <Macro Name="select Calculator">
                <Event Name="OSM.modes.Calculator" />
                <Action>
                    EventGhost.ShowOSD(u'Calculator', u'0;-128;0;0;0;700;0;0;0;255;1;2;1;49;Terminal', (0, 255, 0), (0, 128, 0), 6, (0, 0), 0, 3.0, False)
                </Action>
                <Action>
                    EventGhost.EnableExclusive(XmlIdLink(156))
                </Action>
            </Macro>
        </Folder>
        <Folder Name="mode" Expanded="True">
            <Folder Name="mode none" id="118" />
            <Folder Name="mode system" id="119" Enabled="False">
                <Macro Name="time">
                    <Event Name="DesktopRemote.generic.Info" />
                    <Action>
                        EventGhost.PythonScript(u"import time\nt = time.localtime()\neg.result = '% 2i' %t.tm_hour + ':' + '%02i' %t.tm_min")
                    </Action>
                    <Action>
                        EventGhost.ShowOSD(u'{eg.result}', u'0;-128;0;0;0;700;0;0;0;255;1;2;1;49;Terminal', (0, 255, 0), (0, 128, 0), 0, (80, 40), 0, 3.0, False)
                    </Action>
                </Macro>
            </Folder>
            <Folder Name="mode mouse" id="124" Enabled="False">
                <Macro Name="Mouse Move Up">
                    <Event Name="DesktopRemote.generic.Up" />
                    <Action>
                        Mouse.GoDirection(0)
                    </Action>
                </Macro>
                <Macro Name="Mouse Move Down">
                    <Event Name="DesktopRemote.generic.Down" />
                    <Action>
                        Mouse.GoDirection(u'180')
                    </Action>
                </Macro>
                <Macro Name="Mouse Move Left">
                    <Event Name="DesktopRemote.generic.Left" />
                    <Action>
                        Mouse.GoDirection(270)
                    </Action>
                </Macro>
                <Macro Name="Mouse Move Right">
                    <Event Name="DesktopRemote.generic.Right" />
                    <Action>
                        Mouse.GoDirection(90)
                    </Action>
                </Macro>
                <Macro Name="Left Mouse Button">
                    <Event Name="DesktopRemote.generic.LeftClick" />
                    <Action>
                        Mouse.LeftButton()
                    </Action>
                </Macro>
                <Macro Name="Right Mouse Button">
                    <Event Name="DesktopRemote.generic.RightClick" />
                    <Action>
                        Mouse.RightButton()
                    </Action>
                </Macro>
            </Folder>
            <Folder Name="mode Notepad" id="143" Enabled="False">
                <Folder Name="power">
                    <Macro Name="power">
                        <Event Name="DesktopRemote.generic.Power" />
                        <Action>
                            Window.FindWindow(u'notepad.exe', None, None, None, None, None, False, 0.0, 2)
                        </Action>
                        <Action>
                            EventGhost.NewJumpIf(XmlIdLink(150), 1, False)
                        </Action>
                        <Action>
                            EventGhost.NewJumpIf(XmlIdLink(152), 2, False)
                        </Action>
                    </Macro>
                    <Macro Name="start program" id="150">
                        <Action>
                            System.Execute(u'C:\\WINDOWS\\NOTEPAD.EXE', u'', 0, False, 2, u'', False)
                        </Action>
                    </Macro>
                    <Macro Name="stop program" id="152">
                        <Action>
                            Window.FindWindow(u'notepad.exe', None, None, None, None, None, False, 0.0, 2)
                        </Action>
                        <Action>
                            Window.BringToFront()
                        </Action>
                        <Action>
                            Window.Close()
                        </Action>
                    </Macro>
                </Folder>
            </Folder>
            <Folder Name="mode Calculator" id="156" Enabled="False">
                <Folder Name="power">
                    <Macro Name="power">
                        <Event Name="DesktopRemote.generic.Power" />
                        <Action>
                            Window.FindWindow(u'calc.exe', None, None, None, None, None, False, 0.0, 2)
                        </Action>
                        <Action>
                            EventGhost.NewJumpIf(XmlIdLink(163), 1, False)
                        </Action>
                        <Action>
                            EventGhost.NewJumpIf(XmlIdLink(165), 2, False)
                        </Action>
                    </Macro>
                    <Macro Name="start program" id="163">
                        <Action>
                            System.Execute(u'C:\\WINDOWS\\system32\\calc.exe', u'', 0, False, 2, u'', False)
                        </Action>
                    </Macro>
                    <Macro Name="stop program" id="165">
                        <Action>
                            Window.FindWindow(u'calc.exe', None, None, None, None, None, False, 0.0, 2)
                        </Action>
                        <Action>
                            Window.BringToFront()
                        </Action>
                        <Action>
                            Window.Close()
                        </Action>
                    </Macro>
                </Folder>
            </Folder>
        </Folder>
    </Folder>
</EventGhost>
Change the context with the Function button and the menu control buttons (Up, Down, OK, and Cancel).
(Up and Down navigate through the menu, OK exits the menu with a choice, Cancel exits the menu without a choice)
Try the other context-specific buttons (Info, Up, Down, Left, Right, L, R, and Power) as well.
Note how the Power button has different contexts for the Notepad and Calculator modes.

In this case, mode is the context folder.
Only one item in the context folder is enabled at any moment.
The menu control commands are not in a context folder.
The mode menu folder contains the commands which control the menu.
The context selection commands are not in a context folder.
The select folder contains the commands which change the context.
The menu choices are events which are assigned to the context selection commands.

Expand the configuration tree to see how it works.
Also use Configure Item to see any additional settings that may be used.

Opinion: It is more complex than technique 1, and also requires the OS Menu plugin, but you only need one button for the contexts.
Last edited by WharfRat on Wed Feb 12, 2014 8:41 pm, edited 5 times in total.
EventGhost 0.4.1.r1640
PHX01RN plugin v3.0.1
Windows XP 32bit (v5.1 Build 2600 Service Pack 2)
Windows7 64bit (v6.1 Build 7601 Service Pack 1)

User avatar
WharfRat
Experienced User
Posts: 159
Joined: Wed Dec 25, 2013 11:56 am

Re: Techniques: controlling multiple programs

Post by WharfRat » Thu Jan 02, 2014 1:53 pm

Technique 3 : cyclic contexts

This is a technique that Pako came up with in one of the forum topics (viewtopic.php?f=2&t=1994).
(t_cmp_3.xml)

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1640" Guid="{BC8B6247-8D07-41BE-BBD5-811B9252D8FF}" Time="1392181976.42">
    <Autostart Name="Autostart" Expanded="True">
        <Plugin Identifier="DesktopRemote" Guid="{5DFFBD61-7582-4D6F-8EA9-9CB36284C9CF}" File="DesktopRemote">
            gAIpLg==
        </Plugin>
    </Autostart>
    <Folder Name="not important">
        <Folder Name="generic remote">
            <Macro Name="show">
                <Event Name="Main.OnInit" />
                <Action>
                    DesktopRemote.CreateNew(40, 40, 3, 3, 4, (108, 108, 108), (255, 255, 255), (78, 78, 78), u'0;-13;0;0;0;700;0;0;0;0;3;2;1;34;Arial', u'remote', 1, True, True, True)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'width': 183, 'height': 5, 'event': u'', 'label': u'increase width of remote'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 0, 0), 'fontInfo': u'0;-19;0;0;0;400;0;0;0;2;3;2;1;2;Wingdings', 'event': u'generic.Power', 'label': u'\xa1'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (0, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.Function', 'label': u'Fn'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(25)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'label': u'/', 'foregroundColour': (0, 0, 0), 'event': u'generic.Documents', 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Wingdings 2'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'label': u'\xaf', 'foregroundColour': (0, 0, 0), 'event': u'generic.Music', 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'label': u'J', 'foregroundColour': (0, 0, 0), 'event': u'generic.Pictures', 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;2;Wingdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'label': u'\xb9', 'foregroundColour': (0, 0, 0), 'event': u'generic.Videos', 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(5)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-16;0;0;0;700;0;0;0;2;3;2;1;18;Wingdings 3', 'event': u'generic.Cancel', 'label': u':'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Minimize', 'label': u'0'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Maximize', 'label': u'1'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-13;0;0;0;700;0;0;0;0;3;2;1;34;Arial', 'event': u'generic.Info', 'label': u'i'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(15)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'L', 'event': u'generic.LeftClick', 'fontInfo': u'0;-13;0;0;0;700;0;0;0;0;3;2;1;34;Arial'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'R', 'event': u'generic.RightClick', 'fontInfo': u'0;-13;0;0;0;700;0;0;0;0;3;2;1;34;Arial'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'width': 18, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'label': u'\xe3', 'foregroundColour': (0, 0, 0), 'event': u'generic.Up', 'fontInfo': u'0;-13;0;0;0;400;0;0;0;2;3;2;1;18;Wingdings 3'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'width': 19, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'label': u'\xe1', 'foregroundColour': (0, 0, 0), 'event': u'generic.Left', 'fontInfo': u'0;-13;0;0;0;400;0;0;0;2;3;2;1;18;Wingdings 3'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'8', 'event': u'generic.OK', 'fontInfo': u'0;-16;0;0;0;700;0;0;0;2;3;2;1;18;Wingdings 3'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'label': u'\xe2', 'foregroundColour': (0, 0, 0), 'event': u'generic.Right', 'fontInfo': u'0;-13;0;0;0;400;0;0;0;2;3;2;1;18;Wingdings 3'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'width': 18, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'label': u'\xe4', 'foregroundColour': (0, 0, 0), 'event': u'generic.Down', 'fontInfo': u'0;-13;0;0;0;400;0;0;0;2;3;2;1;18;Wingdings 3'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'width': 19, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(15)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Stop', 'label': u'<'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Play', 'label': u'4'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'foregroundColour': (255, 0, 0), 'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Record', 'label': u'='})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Pause', 'label': u';'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Previous', 'label': u'9'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Rewind', 'label': u'7'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.FastForward', 'label': u'8'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Next', 'label': u':'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Mute', 'label': u'X'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.1', 'label': u'1'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.2', 'label': u'2'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.3', 'label': u'3'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'label': u'5', 'foregroundColour': (0, 0, 0), 'event': u'generic.Increase', 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.4', 'label': u'4'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.5', 'label': u'5'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.6', 'label': u'6'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'label': u'6', 'foregroundColour': (0, 0, 0), 'event': u'generic.Decrease', 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.7', 'label': u'7'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.8', 'label': u'8'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.9', 'label': u'9'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'label': u'+', 'foregroundColour': (0, 0, 0), 'event': u'generic.Plus', 'fontInfo': u'0;-16;0;0;0;700;0;0;0;0;3;2;1;34;Arial'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-16;0;0;0;700;0;0;0;2;3;2;1;18;Wingdings 2', 'event': u'generic.Star', 'label': u'\xd4'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.0', 'label': u'0'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-16;0;0;0;700;0;0;0;0;3;2;1;34;Arial', 'event': u'generic.Hash', 'label': u'#'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'label': u'-', 'foregroundColour': (0, 0, 0), 'event': u'generic.Minus', 'fontInfo': u'0;-19;0;0;0;700;0;0;0;0;3;2;1;34;Arial'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.Show(10, 10, True)
                </Action>
                <Action>
                    EventGhost.TriggerEvent(u'check_for_remote', 0.0)
                </Action>
            </Macro>
        </Folder>
        <Folder Name="log pane">
            <Macro Name="check for remote">
                <Event Name="Main.check_for_remote" />
                <Action>
                    Window.FindWindow(None, u'remote', u'wxWindowClassNR', None, None, 1, False, 0.0, 2)
                </Action>
                <Action>
                    EventGhost.NewJumpIf(XmlIdLink(90), 1, False)
                </Action>
                <Action>
                    EventGhost.TriggerEvent(u'setup_log_pane', 0.0)
                </Action>
            </Macro>
            <Macro Name="wait for remote" id="90">
                <Action>
                    EventGhost.Wait(0.25)
                </Action>
                <Action>
                    EventGhost.TriggerEvent(u'check_for_remote', 0.0)
                </Action>
            </Macro>
            <Macro Name="setup log pane">
                <Event Name="Main.setup_log_pane" />
                <Action>
                    EventGhost.PythonScript(u'eg.Wait(0.5)\neg.log.ctrl.data.clear()\neg.Wait(0.25)\nprint "Technique 3"\nprint ""\nprint "select the mode with this button:"\nprint "   Function (blue Fn)"\nprint ""\nprint "system mode buttons:"\nprint "   Info (black i)"\nprint ""\nprint "mouse mode buttons:"\nprint "   L R up down left right"\nprint ""\nprint "Notepad mode buttons:"\nprint "   Power (red O)"\nprint ""\nprint "Calculator mode buttons:"\nprint "   Power (red O)"\nprint ""')
                </Action>
            </Macro>
        </Folder>
    </Folder>
    <Macro Name="Init" Expanded="True">
        <Event Name="Main.OnInit" />
        <Action>
            EventGhost.EnableExclusive(XmlIdLink(102))
        </Action>
        <Action>
            EventGhost.EnableExclusive(XmlIdLink(159))
        </Action>
    </Macro>
    <Folder Name="modes" Expanded="True">
        <Folder Name="select" Expanded="True">
            <Macro Name="select none" id="154" Enabled="False">
                <Event Name="DesktopRemote.generic.Function" />
                <Action>
                    EventGhost.ShowOSD(u'none', u'0;-128;0;0;0;700;0;0;0;255;1;2;1;49;Terminal', (0, 255, 0), (0, 128, 0), 6, (0, 0), 0, 3.0, False)
                </Action>
                <Action>
                    EventGhost.EnableExclusive(XmlIdLink(102))
                </Action>
                <Action>
                    EventGhost.EnableExclusive(XmlIdLink(159))
                </Action>
            </Macro>
            <Macro Name="select system" id="159">
                <Event Name="DesktopRemote.generic.Function" />
                <Action>
                    EventGhost.ShowOSD(u'system', u'0;-128;0;0;0;700;0;0;0;255;1;2;1;49;Terminal', (0, 255, 0), (0, 128, 0), 6, (0, 0), 0, 3.0, False)
                </Action>
                <Action>
                    EventGhost.EnableExclusive(XmlIdLink(103))
                </Action>
                <Action>
                    EventGhost.EnableExclusive(XmlIdLink(164))
                </Action>
            </Macro>
            <Macro Name="select mouse" id="164" Enabled="False">
                <Event Name="DesktopRemote.generic.Function" />
                <Action>
                    EventGhost.ShowOSD(u'mouse', u'0;-128;0;0;0;700;0;0;0;255;1;2;1;49;Terminal', (0, 255, 0), (0, 128, 0), 6, (0, 0), 0, 3.0, False)
                </Action>
                <Action>
                    EventGhost.EnableExclusive(XmlIdLink(108))
                </Action>
                <Action>
                    EventGhost.EnableExclusive(XmlIdLink(169))
                </Action>
            </Macro>
            <Macro Name="select Notepad" id="169" Enabled="False">
                <Event Name="DesktopRemote.generic.Function" />
                <Action>
                    EventGhost.ShowOSD(u'Notepad', u'0;-128;0;0;0;700;0;0;0;255;1;2;1;49;Terminal', (0, 255, 0), (0, 128, 0), 6, (0, 0), 0, 3.0, False)
                </Action>
                <Action>
                    EventGhost.EnableExclusive(XmlIdLink(127))
                </Action>
                <Action>
                    EventGhost.EnableExclusive(XmlIdLink(174))
                </Action>
            </Macro>
            <Macro Name="select Calculator" id="174" Enabled="False">
                <Event Name="DesktopRemote.generic.Function" />
                <Action>
                    EventGhost.ShowOSD(u'Calculator', u'0;-128;0;0;0;700;0;0;0;255;1;2;1;49;Terminal', (0, 255, 0), (0, 128, 0), 6, (0, 0), 0, 3.0, False)
                </Action>
                <Action>
                    EventGhost.EnableExclusive(XmlIdLink(140))
                </Action>
                <Action>
                    EventGhost.EnableExclusive(XmlIdLink(154))
                </Action>
            </Macro>
        </Folder>
        <Folder Name="mode" Expanded="True">
            <Folder Name="mode none" id="102" />
            <Folder Name="mode system" id="103" Enabled="False">
                <Macro Name="time">
                    <Event Name="DesktopRemote.generic.Info" />
                    <Action>
                        EventGhost.PythonScript(u"import time\nt = time.localtime()\neg.result = '% 2i' %t.tm_hour + ':' + '%02i' %t.tm_min")
                    </Action>
                    <Action>
                        EventGhost.ShowOSD(u'{eg.result}', u'0;-128;0;0;0;700;0;0;0;255;1;2;1;49;Terminal', (0, 255, 0), (0, 128, 0), 0, (80, 40), 0, 3.0, False)
                    </Action>
                </Macro>
            </Folder>
            <Folder Name="mode mouse" id="108" Enabled="False">
                <Macro Name="Mouse Move Up">
                    <Event Name="DesktopRemote.generic.Up" />
                    <Action>
                        Mouse.GoDirection(0)
                    </Action>
                </Macro>
                <Macro Name="Mouse Move Down">
                    <Event Name="DesktopRemote.generic.Down" />
                    <Action>
                        Mouse.GoDirection(u'180')
                    </Action>
                </Macro>
                <Macro Name="Mouse Move Left">
                    <Event Name="DesktopRemote.generic.Left" />
                    <Action>
                        Mouse.GoDirection(270)
                    </Action>
                </Macro>
                <Macro Name="Mouse Move Right">
                    <Event Name="DesktopRemote.generic.Right" />
                    <Action>
                        Mouse.GoDirection(90)
                    </Action>
                </Macro>
                <Macro Name="Left Mouse Button">
                    <Event Name="DesktopRemote.generic.LeftClick" />
                    <Action>
                        Mouse.LeftButton()
                    </Action>
                </Macro>
                <Macro Name="Right Mouse Button">
                    <Event Name="DesktopRemote.generic.RightClick" />
                    <Action>
                        Mouse.RightButton()
                    </Action>
                </Macro>
            </Folder>
            <Folder Name="mode Notepad" id="127" Enabled="False">
                <Folder Name="power">
                    <Macro Name="power">
                        <Event Name="DesktopRemote.generic.Power" />
                        <Action>
                            Window.FindWindow(u'notepad.exe', None, None, None, None, None, False, 0.0, 2)
                        </Action>
                        <Action>
                            EventGhost.NewJumpIf(XmlIdLink(134), 1, False)
                        </Action>
                        <Action>
                            EventGhost.NewJumpIf(XmlIdLink(136), 2, False)
                        </Action>
                    </Macro>
                    <Macro Name="start program" id="134">
                        <Action>
                            System.Execute(u'C:\\WINDOWS\\NOTEPAD.EXE', u'', 0, False, 2, u'', False)
                        </Action>
                    </Macro>
                    <Macro Name="stop program" id="136">
                        <Action>
                            Window.FindWindow(u'notepad.exe', None, None, None, None, None, False, 0.0, 2)
                        </Action>
                        <Action>
                            Window.BringToFront()
                        </Action>
                        <Action>
                            Window.Close()
                        </Action>
                    </Macro>
                </Folder>
            </Folder>
            <Folder Name="mode Calculator" id="140" Enabled="False">
                <Folder Name="power">
                    <Macro Name="power">
                        <Event Name="DesktopRemote.generic.Power" />
                        <Action>
                            Window.FindWindow(u'calc.exe', None, None, None, None, None, False, 0.0, 2)
                        </Action>
                        <Action>
                            EventGhost.NewJumpIf(XmlIdLink(147), 1, False)
                        </Action>
                        <Action>
                            EventGhost.NewJumpIf(XmlIdLink(149), 2, False)
                        </Action>
                    </Macro>
                    <Macro Name="start program" id="147">
                        <Action>
                            System.Execute(u'C:\\WINDOWS\\system32\\calc.exe', u'', 0, False, 2, u'', False)
                        </Action>
                    </Macro>
                    <Macro Name="stop program" id="149">
                        <Action>
                            Window.FindWindow(u'calc.exe', None, None, None, None, None, False, 0.0, 2)
                        </Action>
                        <Action>
                            Window.BringToFront()
                        </Action>
                        <Action>
                            Window.Close()
                        </Action>
                    </Macro>
                </Folder>
            </Folder>
        </Folder>
    </Folder>
</EventGhost>
Change the context with the Function button.
Try the other context-specific buttons (Info, Up, Down, Left, Right, L, R, and Power) as well.
Note how the Power button has different contexts for the Notepad and Calculator modes.

In this case, both mode and select are context folders.
The Init macro sets mode none and select system as the active items.
Only one item in each context folder is enabled at any moment.
When the context is changed, the next item in each folder is enabled.
After the last item, we start at the first item again.

Expand the configuration tree to see how it works.
Also use Configure Item to see any additional settings that may be used.

Opinion: It is more complex than technique 1, but it does not require a plugin, and you only need one button for the contexts. However, it also takes longer to reach the desired context if there are many. Nevertheless, Pako's solutions are always very elegant.
Last edited by WharfRat on Sat Feb 22, 2014 7:00 am, edited 4 times in total.
EventGhost 0.4.1.r1640
PHX01RN plugin v3.0.1
Windows XP 32bit (v5.1 Build 2600 Service Pack 2)
Windows7 64bit (v6.1 Build 7601 Service Pack 1)

User avatar
WharfRat
Experienced User
Posts: 159
Joined: Wed Dec 25, 2013 11:56 am

Re: Techniques: controlling multiple programs

Post by WharfRat » Thu Jan 02, 2014 2:00 pm

Technique 4 : automatic contexts

This is a variation which can be applied to techniques 1 to 3, in this case technique 1.
(t_cmp_4.xml)

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1640" Guid="{6AB6519A-83EC-46CA-8CF6-8D478D83D9FD}" Time="1392182002.19">
    <Autostart Name="Autostart" Expanded="True">
        <Plugin Identifier="DesktopRemote" Guid="{5DFFBD61-7582-4D6F-8EA9-9CB36284C9CF}" File="DesktopRemote">
            gAIpLg==
        </Plugin>
        <Plugin Identifier="Task" Guid="{D1748551-C605-4423-B392-FB77E6842437}" File="Task">
            gAIpLg==
        </Plugin>
    </Autostart>
    <Folder Name="not important">
        <Folder Name="generic remote">
            <Macro Name="show">
                <Event Name="Main.OnInit" />
                <Action>
                    DesktopRemote.CreateNew(40, 40, 3, 3, 4, (108, 108, 108), (255, 255, 255), (78, 78, 78), u'0;-13;0;0;0;700;0;0;0;0;3;2;1;34;Arial', u'remote', 1, True, True, True)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'width': 183, 'label': u'increase width of remote', 'event': u'', 'height': 5})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 0, 0), 'label': u'\xa1', 'event': u'generic.Power', 'fontInfo': u'0;-19;0;0;0;400;0;0;0;2;3;2;1;2;Wingdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (0, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.Function', 'label': u'Fn'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(25)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Wingdings 2', 'event': u'generic.Documents', 'label': u'/'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Music', 'label': u'\xaf'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;2;Wingdings', 'event': u'generic.Pictures', 'label': u'J'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Videos', 'label': u'\xb9'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(5)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u':', 'event': u'generic.Cancel', 'fontInfo': u'0;-16;0;0;0;700;0;0;0;2;3;2;1;18;Wingdings 3'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'0', 'event': u'generic.Minimize', 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'1', 'event': u'generic.Maximize', 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'i', 'event': u'generic.Info', 'fontInfo': u'0;-13;0;0;0;700;0;0;0;0;3;2;1;34;Arial'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(15)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-13;0;0;0;700;0;0;0;0;3;2;1;34;Arial', 'event': u'generic.LeftClick', 'label': u'L'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-13;0;0;0;700;0;0;0;0;3;2;1;34;Arial', 'event': u'generic.RightClick', 'label': u'R'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'width': 18, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-13;0;0;0;400;0;0;0;2;3;2;1;18;Wingdings 3', 'event': u'generic.Up', 'label': u'\xe3'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'width': 19, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-13;0;0;0;400;0;0;0;2;3;2;1;18;Wingdings 3', 'event': u'generic.Left', 'label': u'\xe1'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-16;0;0;0;700;0;0;0;2;3;2;1;18;Wingdings 3', 'event': u'generic.OK', 'label': u'8'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-13;0;0;0;400;0;0;0;2;3;2;1;18;Wingdings 3', 'event': u'generic.Right', 'label': u'\xe2'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'width': 18, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-13;0;0;0;400;0;0;0;2;3;2;1;18;Wingdings 3', 'event': u'generic.Down', 'label': u'\xe4'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'width': 19, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(15)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'<', 'event': u'generic.Stop', 'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'4', 'event': u'generic.Play', 'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'=', 'foregroundColour': (255, 0, 0), 'event': u'generic.Record', 'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u';', 'event': u'generic.Pause', 'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'9', 'event': u'generic.Previous', 'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'7', 'event': u'generic.Rewind', 'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'8', 'event': u'generic.FastForward', 'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u':', 'event': u'generic.Next', 'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'X', 'event': u'generic.Mute', 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.1', 'label': u'1'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.2', 'label': u'2'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.3', 'label': u'3'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Increase', 'label': u'5'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.4', 'label': u'4'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.5', 'label': u'5'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.6', 'label': u'6'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Decrease', 'label': u'6'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.7', 'label': u'7'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.8', 'label': u'8'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.9', 'label': u'9'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-16;0;0;0;700;0;0;0;0;3;2;1;34;Arial', 'event': u'generic.Plus', 'label': u'+'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'label': u'\xd4', 'foregroundColour': (0, 0, 0), 'event': u'generic.Star', 'fontInfo': u'0;-16;0;0;0;700;0;0;0;2;3;2;1;18;Wingdings 2'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.0', 'label': u'0'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'label': u'#', 'foregroundColour': (0, 0, 0), 'event': u'generic.Hash', 'fontInfo': u'0;-16;0;0;0;700;0;0;0;0;3;2;1;34;Arial'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-19;0;0;0;700;0;0;0;0;3;2;1;34;Arial', 'event': u'generic.Minus', 'label': u'-'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.Show(10, 10, True)
                </Action>
                <Action>
                    EventGhost.TriggerEvent(u'check_for_remote', 0.0)
                </Action>
            </Macro>
        </Folder>
        <Folder Name="log pane">
            <Macro Name="check for remote">
                <Event Name="Main.check_for_remote" />
                <Action>
                    Window.FindWindow(None, u'remote', u'wxWindowClassNR', None, None, 1, False, 0.0, 2)
                </Action>
                <Action>
                    EventGhost.NewJumpIf(XmlIdLink(91), 1, False)
                </Action>
                <Action>
                    EventGhost.TriggerEvent(u'setup_log_pane', 0.0)
                </Action>
            </Macro>
            <Macro Name="wait for remote" id="91">
                <Action>
                    EventGhost.Wait(0.25)
                </Action>
                <Action>
                    EventGhost.TriggerEvent(u'check_for_remote', 0.0)
                </Action>
            </Macro>
            <Macro Name="setup log pane">
                <Event Name="Main.setup_log_pane" />
                <Action>
                    EventGhost.PythonScript(u'eg.Wait(0.5)\neg.log.ctrl.data.clear()\neg.Wait(0.25)\nprint "Technique 4"\nprint ""\nprint "select the mode with these buttons:"\nprint "   Function (blue Fn)"\nprint "   Documents"\nprint "   Music"\nprint "   Pictures"\nprint "   Videos"\nprint ""\nprint "system mode buttons:"\nprint "   Info (black i)"\nprint ""\nprint "mouse mode buttons:"\nprint "   L R up down left right"\nprint ""\nprint "Notepad mode buttons:"\nprint "   Power (red O)"\nprint ""\nprint "Calculator mode buttons:"\nprint "   Power (red O)"\nprint ""\nprint "also: try starting Notepad and Calculator from the Start menu"\nprint "also: try switching between Notepad and Calculator with Alt+Tab or real mouse click"\nprint "also: try closing Notepad and Calculator without the remote control"\nprint ""')
                </Action>
            </Macro>
        </Folder>
    </Folder>
    <Macro Name="Init" Expanded="True">
        <Event Name="Main.OnInit" />
        <Action>
            EventGhost.EnableExclusive(XmlIdLink(102))
        </Action>
    </Macro>
    <Folder Name="modes" Expanded="True">
        <Folder Name="select" Expanded="True">
            <Macro Name="select none">
                <Event Name="DesktopRemote.generic.Function" />
                <Action>
                    EventGhost.ShowOSD(u'none', u'0;-128;0;0;0;700;0;0;0;255;1;2;1;49;Terminal', (0, 255, 0), (0, 128, 0), 6, (0, 0), 0, 3.0, False)
                </Action>
                <Action>
                    EventGhost.EnableExclusive(XmlIdLink(102))
                </Action>
            </Macro>
            <Macro Name="select system">
                <Event Name="DesktopRemote.generic.Documents" />
                <Action>
                    EventGhost.ShowOSD(u'system', u'0;-128;0;0;0;700;0;0;0;255;1;2;1;49;Terminal', (0, 255, 0), (0, 128, 0), 6, (0, 0), 0, 3.0, False)
                </Action>
                <Action>
                    EventGhost.EnableExclusive(XmlIdLink(103))
                </Action>
            </Macro>
            <Macro Name="select mouse">
                <Event Name="DesktopRemote.generic.Music" />
                <Action>
                    EventGhost.ShowOSD(u'mouse', u'0;-128;0;0;0;700;0;0;0;255;1;2;1;49;Terminal', (0, 255, 0), (0, 128, 0), 6, (0, 0), 0, 3.0, False)
                </Action>
                <Action>
                    EventGhost.EnableExclusive(XmlIdLink(108))
                </Action>
            </Macro>
            <Macro Name="select Notepad">
                <Event Name="DesktopRemote.generic.Pictures" />
                <Event Name="Task.Activated.NOTEPAD" />
                <Event Name="Task.Activated.notepad" />
                <Action>
                    EventGhost.ShowOSD(u'Notepad', u'0;-128;0;0;0;700;0;0;0;255;1;2;1;49;Terminal', (0, 255, 0), (0, 128, 0), 6, (0, 0), 0, 3.0, False)
                </Action>
                <Action>
                    EventGhost.EnableExclusive(XmlIdLink(127))
                </Action>
                <Action>
                    Window.FindWindow(u'notepad.exe', None, None, None, None, None, False, 0.0, 0)
                </Action>
                <Action>
                    Window.BringToFront()
                </Action>
            </Macro>
            <Macro Name="select Calculator">
                <Event Name="DesktopRemote.generic.Videos" />
                <Event Name="Task.Activated.calc" />
                <Action>
                    EventGhost.ShowOSD(u'Calculator', u'0;-128;0;0;0;700;0;0;0;255;1;2;1;49;Terminal', (0, 255, 0), (0, 128, 0), 6, (0, 0), 0, 3.0, False)
                </Action>
                <Action>
                    EventGhost.EnableExclusive(XmlIdLink(140))
                </Action>
                <Action>
                    Window.FindWindow(u'calc.exe', None, None, None, None, None, False, 0.0, 0)
                </Action>
                <Action>
                    Window.BringToFront()
                </Action>
            </Macro>
        </Folder>
        <Folder Name="mode" Expanded="True">
            <Folder Name="mode none" id="102" />
            <Folder Name="mode system" id="103" Enabled="False">
                <Macro Name="time">
                    <Event Name="DesktopRemote.generic.Info" />
                    <Action>
                        EventGhost.PythonScript(u"import time\nt = time.localtime()\neg.result = '% 2i' %t.tm_hour + ':' + '%02i' %t.tm_min")
                    </Action>
                    <Action>
                        EventGhost.ShowOSD(u'{eg.result}', u'0;-128;0;0;0;700;0;0;0;255;1;2;1;49;Terminal', (0, 255, 0), (0, 128, 0), 0, (80, 40), 0, 3.0, False)
                    </Action>
                </Macro>
            </Folder>
            <Folder Name="mode mouse" id="108" Enabled="False">
                <Macro Name="Mouse Move Up">
                    <Event Name="DesktopRemote.generic.Up" />
                    <Action>
                        Mouse.GoDirection(0)
                    </Action>
                </Macro>
                <Macro Name="Mouse Move Down">
                    <Event Name="DesktopRemote.generic.Down" />
                    <Action>
                        Mouse.GoDirection(u'180')
                    </Action>
                </Macro>
                <Macro Name="Mouse Move Left">
                    <Event Name="DesktopRemote.generic.Left" />
                    <Action>
                        Mouse.GoDirection(270)
                    </Action>
                </Macro>
                <Macro Name="Mouse Move Right">
                    <Event Name="DesktopRemote.generic.Right" />
                    <Action>
                        Mouse.GoDirection(90)
                    </Action>
                </Macro>
                <Macro Name="Left Mouse Button">
                    <Event Name="DesktopRemote.generic.LeftClick" />
                    <Action>
                        Mouse.LeftButton()
                    </Action>
                </Macro>
                <Macro Name="Right Mouse Button">
                    <Event Name="DesktopRemote.generic.RightClick" />
                    <Action>
                        Mouse.RightButton()
                    </Action>
                </Macro>
            </Folder>
            <Folder Name="mode Notepad" id="127" Enabled="False">
                <Folder Name="power">
                    <Macro Name="power">
                        <Event Name="DesktopRemote.generic.Power" />
                        <Action>
                            Window.FindWindow(u'notepad.exe', None, None, None, None, None, False, 0.0, 2)
                        </Action>
                        <Action>
                            EventGhost.NewJumpIf(XmlIdLink(134), 1, False)
                        </Action>
                        <Action>
                            EventGhost.NewJumpIf(XmlIdLink(136), 2, False)
                        </Action>
                    </Macro>
                    <Macro Name="start program" id="134">
                        <Action>
                            System.Execute(u'C:\\WINDOWS\\NOTEPAD.EXE', u'', 0, False, 2, u'', False)
                        </Action>
                    </Macro>
                    <Macro Name="stop program" id="136">
                        <Action>
                            Window.FindWindow(u'notepad.exe', None, None, None, None, None, False, 0.0, 2)
                        </Action>
                        <Action>
                            Window.BringToFront()
                        </Action>
                        <Action>
                            Window.Close()
                        </Action>
                    </Macro>
                </Folder>
            </Folder>
            <Folder Name="mode Calculator" id="140" Enabled="False">
                <Folder Name="power">
                    <Macro Name="power">
                        <Event Name="DesktopRemote.generic.Power" />
                        <Action>
                            Window.FindWindow(u'calc.exe', None, None, None, None, None, False, 0.0, 2)
                        </Action>
                        <Action>
                            EventGhost.NewJumpIf(XmlIdLink(147), 1, False)
                        </Action>
                        <Action>
                            EventGhost.NewJumpIf(XmlIdLink(149), 2, False)
                        </Action>
                    </Macro>
                    <Macro Name="start program" id="147">
                        <Action>
                            System.Execute(u'C:\\WINDOWS\\system32\\calc.exe', u'', 0, False, 2, u'', False)
                        </Action>
                    </Macro>
                    <Macro Name="stop program" id="149">
                        <Action>
                            Window.FindWindow(u'calc.exe', None, None, None, None, None, False, 0.0, 2)
                        </Action>
                        <Action>
                            Window.BringToFront()
                        </Action>
                        <Action>
                            Window.Close()
                        </Action>
                    </Macro>
                </Folder>
            </Folder>
        </Folder>
    </Folder>
</EventGhost>
Change the context with the Function, Documents, Music, Pictures and Videos buttons.
Try the other context-specific buttons (Info, Up, Down, Left, Right, L, R, and Power) as well.
Note how the Power button has different contexts for the Notepad and Calculator modes.
Try starting Notepad and Calculator from the Start menu.
Try switching between Notepad and Calculator with Alt+Tab or by clicking with the real mouse.
Try closing Notepad and Calculator with the real mouse.

In this case, mode is the context folder.
Only one item in the context folder is enabled at any moment.
The context selection commands (for the Function, Documents, etc. buttons) are not in a context folder.
The select folder contains the commands which change the context.
Additional events from the Task Create/Swith Events plugin are added to the context selection commands.
Note also how Notepad generates two different Task.Activated events. (Is this a bug?)

Expand the configuration tree to see how it works.
Also use Configure Item to see any additional settings that may be used.

Opinion: It is more complex than technique 1, and also requires another plugin. I don't use this often because I am a control freak :twisted: .

Exercise 1: (Easy) Modify Technique 3 with Technique 4.

Exercise 2: (Hard) Modify Technique 2 with Technique 4. (hint: see themaster1's configuration)
Last edited by WharfRat on Sat Feb 22, 2014 7:02 am, edited 3 times in total.
EventGhost 0.4.1.r1640
PHX01RN plugin v3.0.1
Windows XP 32bit (v5.1 Build 2600 Service Pack 2)
Windows7 64bit (v6.1 Build 7601 Service Pack 1)

User avatar
WharfRat
Experienced User
Posts: 159
Joined: Wed Dec 25, 2013 11:56 am

Re: Techniques: controlling multiple programs

Post by WharfRat » Thu Jan 02, 2014 2:01 pm

That's all I have.

Anyone else?
EventGhost 0.4.1.r1640
PHX01RN plugin v3.0.1
Windows XP 32bit (v5.1 Build 2600 Service Pack 2)
Windows7 64bit (v6.1 Build 7601 Service Pack 1)

jonib
Plugin Developer
Posts: 1344
Joined: Thu Mar 26, 2009 9:33 pm
Location: Sweden

Re: Techniques: controlling multiple programs

Post by jonib » Thu Jan 02, 2014 6:15 pm

Great work WharfRat, finally somebody's done a guide for this. Hopefully this can help new users to control multiple programs faster.

jonib
XBMC2 plugin to control XBMC. If you want to flatter me Image

User avatar
WharfRat
Experienced User
Posts: 159
Joined: Wed Dec 25, 2013 11:56 am

Re: Techniques: controlling multiple programs

Post by WharfRat » Sun Jan 05, 2014 9:19 am

Thanks jonib...

I hope it doesn't fade into the mists of this forum.

I have some ideas for other Techniques topics as well, time permitting.

One would be a tutorial on controlling apps, from simple ways like keystroke emulation all the way up to message probing with WinSpector. Again, time permitting.
EventGhost 0.4.1.r1640
PHX01RN plugin v3.0.1
Windows XP 32bit (v5.1 Build 2600 Service Pack 2)
Windows7 64bit (v6.1 Build 7601 Service Pack 1)

Ron The Don
Posts: 19
Joined: Sun Dec 22, 2013 11:34 am

Re: Techniques: controlling multiple programs

Post by Ron The Don » Thu Jan 09, 2014 8:48 pm

First off, thank you very much Wharf! I was waiting for a thorough explanation and you delivered!

Life would be too great, if there wasn't, of course, a problem lurking behind the next corner.
I have been unable to copy/paste your code into an XML file and get EventGhost to open it.
I also notice that whenever I click on "select all" and copy/paste your code into Notepad++, or Notepad, I get additional spaces and I don't know why.
Maybe I should see this as a sign that I am too much of a beginner. Can't even copy/paste haha. :lol:

This is what I copied into Notepad++ and saved as test.xml
http://pastebin.com/2RuiSJFd


EventGhost throws out these errors (that's a lot of red for so few lines)
Image


I tried copy/paste with Firefox and Internet Explorer, both to no avail. Maybe you have an idea, so I can get started with your awesome tutorial. Thanks!

User avatar
WharfRat
Experienced User
Posts: 159
Joined: Wed Dec 25, 2013 11:56 am

Re: Techniques: controlling multiple programs

Post by WharfRat » Fri Jan 10, 2014 6:53 am

Ron The Don...

I went to the PasteBin website link, but you only have about 10 lines of code that is copied there.
Technique 1 is about 170 lines of code, so something is not working correctly in you browser or elsewhere.

Whatever it is, here are the examples in a ZIP archive, if that is more convenient.

EDIT: archive is now in the first post

I did the Select All and copy for all four examples from the EventGhost forum with Internet Explorer into Notepad just to make sure everything is OK. EventGhost loaded them without a problem for me.

Hopefully that is what the problem is, and not something else.

WharRat.
Last edited by WharfRat on Wed Feb 12, 2014 1:11 pm, edited 1 time in total.
EventGhost 0.4.1.r1640
PHX01RN plugin v3.0.1
Windows XP 32bit (v5.1 Build 2600 Service Pack 2)
Windows7 64bit (v6.1 Build 7601 Service Pack 1)

User avatar
WharfRat
Experienced User
Posts: 159
Joined: Wed Dec 25, 2013 11:56 am

Re: Techniques: controlling multiple programs

Post by WharfRat » Mon Jan 13, 2014 9:39 am

:oops: How embarassing...

EDIT: see the next embarassment later on however

While technique 2 (menu control) originally worked as intended for demonstration, in practice it was not well implemented.

I have modified the code to be more robust.
(t_cmp_2a.xml)

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1640" Guid="{FE0AE956-386C-4DAC-BC22-9850CFFACDD8}" Time="1392181923.86">
    <Autostart Name="Autostart" Expanded="True">
        <Plugin Identifier="DesktopRemote" Guid="{5DFFBD61-7582-4D6F-8EA9-9CB36284C9CF}" File="DesktopRemote">
            gAIpLg==
        </Plugin>
        <Plugin Identifier="OSM" Guid="{FCF3C7A7-FBC1-444D-B768-9477521946DC}" File="OSM">
            gAIpLg==
        </Plugin>
    </Autostart>
    <Folder Name="not important">
        <Folder Name="generic remote">
            <Macro Name="show">
                <Event Name="Main.OnInit" />
                <Action>
                    DesktopRemote.CreateNew(40, 40, 3, 3, 4, (108, 108, 108), (255, 255, 255), (78, 78, 78), u'0;-13;0;0;0;700;0;0;0;0;3;2;1;34;Arial', u'remote', 1, True, True, True)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'width': 183, 'height': 5, 'event': u'', 'label': u'increase width of remote'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 0, 0), 'fontInfo': u'0;-19;0;0;0;400;0;0;0;2;3;2;1;2;Wingdings', 'event': u'generic.Power', 'label': u'\xa1'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (0, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.Function', 'label': u'Fn'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(25)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'label': u'/', 'foregroundColour': (0, 0, 0), 'event': u'generic.Documents', 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Wingdings 2'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'label': u'\xaf', 'foregroundColour': (0, 0, 0), 'event': u'generic.Music', 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'label': u'J', 'foregroundColour': (0, 0, 0), 'event': u'generic.Pictures', 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;2;Wingdings'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'label': u'\xb9', 'foregroundColour': (0, 0, 0), 'event': u'generic.Videos', 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(5)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-16;0;0;0;700;0;0;0;2;3;2;1;18;Wingdings 3', 'event': u'generic.Cancel', 'label': u':'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Minimize', 'label': u'0'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Maximize', 'label': u'1'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-13;0;0;0;700;0;0;0;0;3;2;1;34;Arial', 'event': u'generic.Info', 'label': u'i'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(15)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'L', 'event': u'generic.LeftClick', 'fontInfo': u'0;-13;0;0;0;700;0;0;0;0;3;2;1;34;Arial'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'R', 'event': u'generic.RightClick', 'fontInfo': u'0;-13;0;0;0;700;0;0;0;0;3;2;1;34;Arial'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'width': 18, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'label': u'\xe3', 'foregroundColour': (0, 0, 0), 'event': u'generic.Up', 'fontInfo': u'0;-13;0;0;0;400;0;0;0;2;3;2;1;18;Wingdings 3'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'width': 19, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'label': u'\xe1', 'foregroundColour': (0, 0, 0), 'event': u'generic.Left', 'fontInfo': u'0;-13;0;0;0;400;0;0;0;2;3;2;1;18;Wingdings 3'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'label': u'8', 'event': u'generic.OK', 'fontInfo': u'0;-16;0;0;0;700;0;0;0;2;3;2;1;18;Wingdings 3'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'label': u'\xe2', 'foregroundColour': (0, 0, 0), 'event': u'generic.Right', 'fontInfo': u'0;-13;0;0;0;400;0;0;0;2;3;2;1;18;Wingdings 3'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'width': 18, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'label': u'\xe4', 'foregroundColour': (0, 0, 0), 'event': u'generic.Down', 'fontInfo': u'0;-13;0;0;0;400;0;0;0;2;3;2;1;18;Wingdings 3'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'width': 19, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(15)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Stop', 'label': u'<'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Play', 'label': u'4'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'foregroundColour': (255, 0, 0), 'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Record', 'label': u'='})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Pause', 'label': u';'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Previous', 'label': u'9'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Rewind', 'label': u'7'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.FastForward', 'label': u'8'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-15;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Next', 'label': u':'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'invisible': True, 'event': u'', 'label': u''})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings', 'event': u'generic.Mute', 'label': u'X'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.1', 'label': u'1'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.2', 'label': u'2'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.3', 'label': u'3'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'label': u'5', 'foregroundColour': (0, 0, 0), 'event': u'generic.Increase', 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.4', 'label': u'4'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.5', 'label': u'5'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.6', 'label': u'6'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'label': u'6', 'foregroundColour': (0, 0, 0), 'event': u'generic.Decrease', 'fontInfo': u'0;-16;0;0;0;400;0;0;0;2;3;2;1;18;Webdings'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.7', 'label': u'7'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.8', 'label': u'8'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.9', 'label': u'9'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'label': u'+', 'foregroundColour': (0, 0, 0), 'event': u'generic.Plus', 'fontInfo': u'0;-16;0;0;0;700;0;0;0;0;3;2;1;34;Arial'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-16;0;0;0;700;0;0;0;2;3;2;1;18;Wingdings 2', 'event': u'generic.Star', 'label': u'\xd4'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'event': u'generic.0', 'label': u'0'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'foregroundColour': (0, 0, 0), 'fontInfo': u'0;-16;0;0;0;700;0;0;0;0;3;2;1;34;Arial', 'event': u'generic.Hash', 'label': u'#'})
                </Action>
                <Action>
                    DesktopRemote.AddButton({'backgroundColour': (200, 200, 200), 'label': u'-', 'foregroundColour': (0, 0, 0), 'event': u'generic.Minus', 'fontInfo': u'0;-19;0;0;0;700;0;0;0;0;3;2;1;34;Arial'})
                </Action>
                <Action>
                    DesktopRemote.StartNewLine(0)
                </Action>
                <Action>
                    DesktopRemote.Show(10, 10, True)
                </Action>
                <Action>
                    EventGhost.TriggerEvent(u'check_for_remote', 0.0)
                </Action>
            </Macro>
        </Folder>
        <Folder Name="log pane">
            <Macro Name="check for remote">
                <Event Name="Main.check_for_remote" />
                <Action>
                    Window.FindWindow(None, u'remote', u'wxWindowClassNR', None, None, 1, False, 0.0, 2)
                </Action>
                <Action>
                    EventGhost.NewJumpIf(XmlIdLink(91), 1, False)
                </Action>
                <Action>
                    EventGhost.TriggerEvent(u'setup_log_pane', 0.0)
                </Action>
            </Macro>
            <Macro Name="wait for remote" id="91">
                <Action>
                    EventGhost.Wait(0.25)
                </Action>
                <Action>
                    EventGhost.TriggerEvent(u'check_for_remote', 0.0)
                </Action>
            </Macro>
            <Macro Name="setup log pane">
                <Event Name="Main.setup_log_pane" />
                <Action>
                    EventGhost.PythonScript(u'eg.Wait(0.5)\neg.log.ctrl.data.clear()\neg.Wait(0.25)\nprint "Technique 2a"\nprint ""\nprint "select the mode with this button:"\nprint "   Function (blue Fn)"\nprint "navigate the menu with these buttons:"\nprint "   up down"\nprint "   OK (black down-and-left)"\nprint "   Cancel (black up-and-left)"\nprint ""\nprint "system mode buttons:"\nprint "   Info (black i)"\nprint ""\nprint "mouse mode buttons:"\nprint "   L R up down left right"\nprint ""\nprint "Notepad mode buttons:"\nprint "   Power (red O)"\nprint ""\nprint "Calculator mode buttons:"\nprint "   Power (red O)"\nprint ""')
                </Action>
            </Macro>
        </Folder>
    </Folder>
    <Macro Name="Init" Expanded="True">
        <Event Name="Main.OnInit" />
        <Action>
            EventGhost.EnableExclusive(XmlIdLink(122))
        </Action>
    </Macro>
    <Folder Name="modes" Expanded="True">
        <Folder Name="mode menu" Expanded="True">
            <Macro Name="Show menu">
                <Event Name="DesktopRemote.generic.Function" />
                <Action Name="OS Menu: modes">
                    OSM.ShowMenu([(u'none', u'none'), (u'system', u'system'), (u'mouse', u'mouse'), (u'Notepad', u'Notepad'), (u'Calculator', u'Calculator')], (75, 75, 75), (180, 180, 180), u'0;-48;0;0;0;400;0;0;0;0;0;0;0;0;MS Shell Dlg 2', u'OSM.modes', 0, 0, (180, 180, 180), (75, 75, 75), False, False)
                </Action>
                <Action>
                    EventGhost.EnableItem(XmlIdLink(106))
                </Action>
            </Macro>
            <Folder Name="menu control" id="106" Enabled="False">
                <Macro Name="Cursor Up">
                    <Event Name="DesktopRemote.generic.Up" />
                    <Action>
                        OSM.MoveUp()
                    </Action>
                </Macro>
                <Macro Name="Cursor Down">
                    <Event Name="DesktopRemote.generic.Down" />
                    <Action>
                        OSM.MoveDown()
                    </Action>
                </Macro>
                <Macro Name="OK">
                    <Event Name="DesktopRemote.generic.OK" />
                    <Action>
                        EventGhost.DisableItem(XmlIdLink(106))
                    </Action>
                    <Action>
                        OSM.OK_Btn()
                    </Action>
                </Macro>
                <Macro Name="Cancel">
                    <Event Name="DesktopRemote.generic.Cancel" />
                    <Action>
                        EventGhost.DisableItem(XmlIdLink(106))
                    </Action>
                    <Action>
                        OSM.Cancel_Btn()
                    </Action>
                </Macro>
            </Folder>
        </Folder>
        <Folder Name="select" Expanded="True">
            <Macro Name="select none">
                <Event Name="OSM.modes.none" />
                <Action>
                    EventGhost.ShowOSD(u'none', u'0;-128;0;0;0;700;0;0;0;255;1;2;1;49;Terminal', (0, 255, 0), (0, 128, 0), 6, (0, 0), 0, 3.0, False)
                </Action>
                <Action>
                    EventGhost.EnableExclusive(XmlIdLink(122))
                </Action>
            </Macro>
            <Macro Name="select system">
                <Event Name="OSM.modes.system" />
                <Action>
                    EventGhost.ShowOSD(u'system', u'0;-128;0;0;0;700;0;0;0;255;1;2;1;49;Terminal', (0, 255, 0), (0, 128, 0), 6, (0, 0), 0, 3.0, False)
                </Action>
                <Action>
                    EventGhost.EnableExclusive(XmlIdLink(123))
                </Action>
            </Macro>
            <Macro Name="select mouse">
                <Event Name="OSM.modes.mouse" />
                <Action>
                    EventGhost.ShowOSD(u'mouse', u'0;-128;0;0;0;700;0;0;0;255;1;2;1;49;Terminal', (0, 255, 0), (0, 128, 0), 6, (0, 0), 0, 3.0, False)
                </Action>
                <Action>
                    EventGhost.EnableExclusive(XmlIdLink(128))
                </Action>
            </Macro>
            <Macro Name="select Notepad">
                <Event Name="OSM.modes.Notepad" />
                <Action>
                    EventGhost.ShowOSD(u'Notepad', u'0;-128;0;0;0;700;0;0;0;255;1;2;1;49;Terminal', (0, 255, 0), (0, 128, 0), 6, (0, 0), 0, 3.0, False)
                </Action>
                <Action>
                    EventGhost.EnableExclusive(XmlIdLink(147))
                </Action>
            </Macro>
            <Macro Name="select Calculator">
                <Event Name="OSM.modes.Calculator" />
                <Action>
                    EventGhost.ShowOSD(u'Calculator', u'0;-128;0;0;0;700;0;0;0;255;1;2;1;49;Terminal', (0, 255, 0), (0, 128, 0), 6, (0, 0), 0, 3.0, False)
                </Action>
                <Action>
                    EventGhost.EnableExclusive(XmlIdLink(160))
                </Action>
            </Macro>
        </Folder>
        <Folder Name="mode" Expanded="True">
            <Folder Name="mode none" id="122" />
            <Folder Name="mode system" id="123" Enabled="False">
                <Macro Name="time">
                    <Event Name="DesktopRemote.generic.Info" />
                    <Action>
                        EventGhost.PythonScript(u"import time\nt = time.localtime()\neg.result = '% 2i' %t.tm_hour + ':' + '%02i' %t.tm_min")
                    </Action>
                    <Action>
                        EventGhost.ShowOSD(u'{eg.result}', u'0;-128;0;0;0;700;0;0;0;255;1;2;1;49;Terminal', (0, 255, 0), (0, 128, 0), 0, (80, 40), 0, 3.0, False)
                    </Action>
                </Macro>
            </Folder>
            <Folder Name="mode mouse" id="128" Enabled="False">
                <Macro Name="Mouse Move Up">
                    <Event Name="DesktopRemote.generic.Up" />
                    <Action>
                        Mouse.GoDirection(0)
                    </Action>
                </Macro>
                <Macro Name="Mouse Move Down">
                    <Event Name="DesktopRemote.generic.Down" />
                    <Action>
                        Mouse.GoDirection(u'180')
                    </Action>
                </Macro>
                <Macro Name="Mouse Move Left">
                    <Event Name="DesktopRemote.generic.Left" />
                    <Action>
                        Mouse.GoDirection(270)
                    </Action>
                </Macro>
                <Macro Name="Mouse Move Right">
                    <Event Name="DesktopRemote.generic.Right" />
                    <Action>
                        Mouse.GoDirection(90)
                    </Action>
                </Macro>
                <Macro Name="Left Mouse Button">
                    <Event Name="DesktopRemote.generic.LeftClick" />
                    <Action>
                        Mouse.LeftButton()
                    </Action>
                </Macro>
                <Macro Name="Right Mouse Button">
                    <Event Name="DesktopRemote.generic.RightClick" />
                    <Action>
                        Mouse.RightButton()
                    </Action>
                </Macro>
            </Folder>
            <Folder Name="mode Notepad" id="147" Enabled="False">
                <Folder Name="power">
                    <Macro Name="power">
                        <Event Name="DesktopRemote.generic.Power" />
                        <Action>
                            Window.FindWindow(u'notepad.exe', None, None, None, None, None, False, 0.0, 2)
                        </Action>
                        <Action>
                            EventGhost.NewJumpIf(XmlIdLink(154), 1, False)
                        </Action>
                        <Action>
                            EventGhost.NewJumpIf(XmlIdLink(156), 2, False)
                        </Action>
                    </Macro>
                    <Macro Name="start program" id="154">
                        <Action>
                            System.Execute(u'C:\\WINDOWS\\NOTEPAD.EXE', u'', 0, False, 2, u'', False)
                        </Action>
                    </Macro>
                    <Macro Name="stop program" id="156">
                        <Action>
                            Window.FindWindow(u'notepad.exe', None, None, None, None, None, False, 0.0, 2)
                        </Action>
                        <Action>
                            Window.BringToFront()
                        </Action>
                        <Action>
                            Window.Close()
                        </Action>
                    </Macro>
                </Folder>
            </Folder>
            <Folder Name="mode Calculator" id="160" Enabled="False">
                <Folder Name="power">
                    <Macro Name="power">
                        <Event Name="DesktopRemote.generic.Power" />
                        <Action>
                            Window.FindWindow(u'calc.exe', None, None, None, None, None, False, 0.0, 2)
                        </Action>
                        <Action>
                            EventGhost.NewJumpIf(XmlIdLink(167), 1, False)
                        </Action>
                        <Action>
                            EventGhost.NewJumpIf(XmlIdLink(169), 2, False)
                        </Action>
                    </Macro>
                    <Macro Name="start program" id="167">
                        <Action>
                            System.Execute(u'C:\\WINDOWS\\system32\\calc.exe', u'', 0, False, 2, u'', False)
                        </Action>
                    </Macro>
                    <Macro Name="stop program" id="169">
                        <Action>
                            Window.FindWindow(u'calc.exe', None, None, None, None, None, False, 0.0, 2)
                        </Action>
                        <Action>
                            Window.BringToFront()
                        </Action>
                        <Action>
                            Window.Close()
                        </Action>
                    </Macro>
                </Folder>
            </Folder>
        </Folder>
    </Folder>
</EventGhost>
t_cmp_2a.zip
t_cmp_2a.xml
(2.79 KiB) Downloaded 165 times
As a backgrounder, I usually prefer technique 3. Someone else here, who usually uses another computer, prefers technique 2. So I quickly set that one up with the menus and added keyboard navigation keys to the menu control for good measure.
Everything seemed fine, but eventually IrfanView refused to respond to some keyboard keys. Since you cannot reconfigure the IrfanView keys, I was slightly confused. After a while I saw the problem.
The victims were cursor up/down, Enter, and Escape.
The culprit was the menu control keys for the On Screen Menu. It was stealing them from IrfanView, and everything else as well.

There are many solutions.
One is to use more context folders.
Another is the new technique 2 method, which explicitly enables and disables a folder containing the menu commands.

Open both versions of technique 2 to see what they do and how they do it.
Last edited by WharfRat on Wed Feb 12, 2014 8:46 pm, edited 2 times in total.
EventGhost 0.4.1.r1640
PHX01RN plugin v3.0.1
Windows XP 32bit (v5.1 Build 2600 Service Pack 2)
Windows7 64bit (v6.1 Build 7601 Service Pack 1)

themaster1
Experienced User
Posts: 137
Joined: Wed Feb 03, 2010 9:02 pm

Re: Techniques: controlling multiple programs

Post by themaster1 » Tue Jan 14, 2014 8:39 pm

I fail to see the benefit of your config compared to mine see here perhaps you can enlighten me

blaher
Experienced User
Posts: 494
Joined: Thu Nov 17, 2011 1:27 am

Re: Techniques: controlling multiple programs

Post by blaher » Wed Jan 15, 2014 1:58 am

themaster1 wrote:I fail to see the benefit of your config compared to mine see here perhaps you can enlighten me
Yours is very similar to the 'Tree2' example, i.e. using the OSD to select from a menu.

User avatar
WharfRat
Experienced User
Posts: 159
Joined: Wed Dec 25, 2013 11:56 am

Re: Techniques: controlling multiple programs

Post by WharfRat » Wed Jan 15, 2014 11:52 am

themaster1...

I am just an inexperienced user showing another inexperienced user how to control multiple programs which we were discussing here (viewtopic.php?f=9&t=5927).
Help from more experienced users is most welcome.

The examples have been kept simple so that other new users can benefit from them quickly.

This topic, so far, has 3 techniques and a variation for those 3 techniques resulting in 6 techniques for controlling multiple programs.
Technique 1 used many buttons to change contexts.
Technique 2 used 1 button and a menu to change contexts.
Technique 3 used 1 button only to change contexts.
Technique 4 varied Technique 1 to automatically change contexts.
Technique 4 could also be applied to Techniques 2 and 3.

My config (I presume you are referring to the new version of technique 2) has no benefit over yours.

The only difference that I can see is that your OS Menu has been placed in a context folder, while the new technique 2 explicitly disables the menu navigation commands. From the 'How embarassing...' post:
There are many solutions.
One is to use more context folders.
Another is the new technique 2 method, which explicitly enables and disables a folder containing the menu commands.
The new version just showed another way of doing things.

If I did not understand your config properly, could you please make an example config for us using a similar setup which shows your difference more clearly?

Thank you.
Last edited by WharfRat on Wed Feb 12, 2014 1:21 pm, edited 1 time in total.
EventGhost 0.4.1.r1640
PHX01RN plugin v3.0.1
Windows XP 32bit (v5.1 Build 2600 Service Pack 2)
Windows7 64bit (v6.1 Build 7601 Service Pack 1)

Post Reply