Having said that, I did find a need to extend EG for some custom functionality. That's why I wrote the TextGrab plugin. As I find it useful, I think somebody else may find it useful too, and that's why I'm posting the plugin here.
So, what does the TextGrab plugin do? As you might have guessed, it grabs some text, to be further processed (displayed or read aloud or written somewhere) later. You might ask, what good is THAT for? Well... it can be pretty useful. For example, I use it to grab the currently playing song title from my favourite media player (MPC) and then having it read aloud through the speech plugin. If I'm listening to the playlist of mp3's, without the monitor/TV turned on, laying on the couch reading something, and an interesting song plays, I can press a button on my remote, the EventGhost grabs the current song title from the Media Player Classic, and then it reads it aloud for me to hear it. No visuals are involved in any of this (although they can be if you wish).
How does TextGrab plugin work? It's basically a programmatic glue between two other plugins/actions: the FindWindow action and some other arbitrary action, like Speech or Show OSD. Actually, TextGrab leverages FindWindow functionality heavily, and is basically only an extension of this one. FindWindow is a very powerful action.. it does not only find a certain window, it can actually browse the whole graphic subtree of objects below a certain application window as well. This is awesome - and this provides the real power behind the TextGrab plugin. Namely, using the FindWindow action you can target not just a whole window, but a certain component of a window - for example, a label (static text). Do you see where I'm getting at? When you successfully target a label, all you have to do is programmatically read (grab) its text - and that's exactly what TextGrab plugin does!
Installation guide and a configuration example
--------------------------------------------------------------
First, download the __init__.py file atached to this message, which contains the plugin. Then, create a new directory below your EventGhost\plugins directory called TextGrab, and copy the downloaded __init__.py in there. Restart EventGhost and activate the plugin via Add Plugin toolbar button (search for the TextGrab plugin in the 'Other' plugins section). This completes the installation part, now for the configuration...
Now, create/add a new macro via the Add Macro toolbar button and name it whatever you wish it to (e.g., "display currently playing song title"). Then, you will need to add 3 actions to the newly created macro:
1) add a FindWindow action (it's inside the 'Window' plugin) and configure it appropriately. This is the trickiest part of the configuration so let me spend a little more time on that.
FindWindow action is a very configurable and powerful action. In this case, we're hunting not necessarily for a window, but for some other graphic object that is displaying some text (which we are about to grab). In this example, we'll be hunting for a label (static text) that displays the current song title inside the Media Player Classic, but you can use any other application that displays any text in a similar manner. Let's assume the MPC is running and the configuration dialog of FindWindow is showing MPC among the running application. Now we click on the plus sign to expand the object tree below that application and we can see the something like this:

After we expand the whole tree of graphic objects, the so-called "Static" objects (labels) appear in the tree bearing their current text values. Now click on the "static" (label) element to select it. All the checkboxes below will be automatically selected with appropriate values. They carry the full criteria for finding the selected graphic element, however, you may want to change them to be more flexible. In our case, we must uncheck the "Window name" and "Child name", as those two are different every time a new song plays (they may carry the song title), and we want fixed criteria for finding the appropriate label element. Lastly, we must enter the "n'th element" number. Looking at the fully expanded tree of graphic objects, we can see that the searched-for graphic element is the fifth in a row of all so-called "Static" elements (labels). Such is the case on my computer, with my configuration of MPC, but your situation may be different, depending on how the MPC is set up (what information it displays). In any case, just count the number of previous "Static"-s in the object tree and add one, then put the number in "only return n'th match" entry field. Phew...
What we have just done is configure the FindWindow action in such a way that it searches for (and hopefully finds) exact graphic element inside the Media Player Classic that is displaying the text we wish to grab. If the application we would be trying to read from was something else, we would need to configure the FindWindow action differently, although the same principle still aplies: find the appropriate graphic element in a subtree of elements.
2) now the easy part: add a GrabText action (from the TextGrab plugin). Just add the action using the Add Action button from the toolbar, no need to configure anything here.
3) lastly, the fun part: add an action that actually does something with your grabbed text. Good candidates are either the Show OSD action or Speech action. Let's have a look at the Speech action example. Add the Speech action (speech plugin must be activated before you do this) and the configuration window will open. Now, insert the text you wish to be read aloud, including the {eg.globals.grabbedText} , curly brackets included, which will be replaced by the grabbed text. For example, type in "now playing {eg.globals.grabbedText}", without the quotes of course. Here's an example screenshot:

Alternatively, if you wish to SEE the song title instead of HEAR it, you may wish to use Show OSD action instead of Speech. In the config dialog of Show OSD, "Text to display" should contain {eg. globals.grabbedText} somewhere.
And that's basically it for the TextGrab plugin. The only thing left to do is to add a trigger event to the top of the macro we just created, something like a remote control button press that will trigger it. Now, the next time you listen to your internet radio station and an interesting song comes up, just press that button and magically you'll be informed what song is playing (assuming your player is displaying that information somewhere).
Here's a screenshot of what the final macro should look like:

Here's the configuration code of the aforementioned example. Note that you may need to configure the FindWindow action differently in order to suit your player's configuration:
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1194">
<Macro Name="read currently playing song title in MPC" Expanded="True">
<Event Name="USB_UIRT.Mce.Details" />
<Action>
Window.FindWindow(u'mplayerc.exe', None, u'MediaPlayerClassicW', None, u'Static', 5, False, 0.0, 0)
</Action>
<Action>
TextGrabPlugin.GrabText()
</Action>
<Action>
Speech.TextToSpeech(u'ATT DTNV 1.4 Crystal', 0, u'now playing {eg.globals.grabbedText}', 0, 100)
</Action>
</Macro>
</EventGhost>
