Index: programs/mythfrontend/mythfrontend.pro
===================================================================
--- programs/mythfrontend/mythfrontend.pro	(revision 19523)
+++ programs/mythfrontend/mythfrontend.pro	(working copy)
@@ -25,17 +25,18 @@
 QMAKE_CLEAN += $(TARGET)
 
 # Input
-HEADERS += playbackbox.h viewscheduled.h globalsettings.h
-HEADERS += manualschedule.h programrecpriority.h channelrecpriority.h
-HEADERS += statusbox.h networkcontrol.h custompriority.h
+HEADERS += playbackbox.h viewscheduled.h
+HEADERS += globalsettings.h manualschedule.h
+HEADERS += programrecpriority.h channelrecpriority.h custompriority.h
+HEADERS += statusbox.h networkcontrol.h sendxkey.h
 HEADERS += mediarenderer.h mythfexml.h
 HEADERS += mythappearance.h exitprompt.h
 
 SOURCES += main.cpp playbackbox.cpp viewscheduled.cpp
-SOURCES += globalsettings.cpp manualschedule.cpp programrecpriority.cpp 
-SOURCES += channelrecpriority.cpp statusbox.cpp networkcontrol.cpp
+SOURCES += globalsettings.cpp manualschedule.cpp
+SOURCES += programrecpriority.cpp channelrecpriority.cpp custompriority.cpp
+SOURCES += statusbox.cpp networkcontrol.cpp sendxkey.cpp
 SOURCES += mediarenderer.cpp mythfexml.cpp
-SOURCES += custompriority.cpp
 SOURCES += mythappearance.cpp exitprompt.cpp
 
 macx {
Index: programs/mythfrontend/networkcontrol.h
===================================================================
--- programs/mythfrontend/networkcontrol.h	(revision 19529)
+++ programs/mythfrontend/networkcontrol.h	(working copy)
@@ -41,6 +41,7 @@
   private:
     QString processJump(QStringList tokens);
     QString processKey(QStringList tokens);
+    QString processXKey(QString command);
     QString processLiveTV(QStringList tokens);
     QString processPlay(QStringList tokens);
     QString processQuery(QStringList tokens);
@@ -61,6 +62,7 @@
     QString answer;
     QMap <QString, QString> jumpMap;
     QMap <QString, int> keyMap;
+    QMap <QString, QString> xkeyMap;
 
     mutable QMutex  clientLock;
     QTcpSocket     *client;
Index: programs/mythfrontend/networkcontrol.cpp
===================================================================
--- programs/mythfrontend/networkcontrol.cpp	(revision 19529)
+++ programs/mythfrontend/networkcontrol.cpp	(working copy)
@@ -20,6 +20,7 @@
 #include "mythverbose.h"
 #include "mythversion.h"
 #include "mythuihelper.h"
+#include "sendxkey.h"
 
 #define LOC QString("NetworkControl: ")
 #define LOC_ERR QString("NetworkControl Error: ")
@@ -186,6 +187,286 @@
     keyMap["f22"]                    = Qt::Key_F22;
     keyMap["f23"]                    = Qt::Key_F23;
     keyMap["f24"]                    = Qt::Key_F24;
+    
+    xkeyMap["BackSpace"] = "BackSpace";
+    xkeyMap["Tab"] = "Tab";
+    xkeyMap["Linefeed"] = "Linefeed";
+    xkeyMap["Clear"] = "Clear";
+    xkeyMap["Return"] = "Return";
+    xkeyMap["Pause"] = "Pause";
+    xkeyMap["Scroll_Lock"] = "Scroll_Lock";
+    xkeyMap["Sys_Req"] = "Sys_Req";
+    xkeyMap["Escape"] = "Escape";
+    xkeyMap["Delete"] = "Delete";
+    xkeyMap["Home"] = "Home";
+    xkeyMap["Left"] = "Left";
+    xkeyMap["Up"] = "Up";
+    xkeyMap["Right"] = "Right";
+    xkeyMap["Down"] = "Down";
+    xkeyMap["Prior"] = "Prior";
+    xkeyMap["Page_Up"] = "Page_Up";
+    xkeyMap["Next"] = "Next";
+    xkeyMap["Page_Down"] = "Page_Down";
+    xkeyMap["End"] = "End";
+    xkeyMap["Begin"] = "Begin";
+    xkeyMap["Select"] = "Select";
+    xkeyMap["Print"] = "Print";
+    xkeyMap["Execute"] = "Execute";
+    xkeyMap["Insert"] = "Insert";
+    xkeyMap["Undo"] = "Undo";
+    xkeyMap["Redo"] = "Redo";
+    xkeyMap["Menu"] = "Menu";
+    xkeyMap["Find"] = "Find";
+    xkeyMap["Cancel"] = "Cancel";
+    xkeyMap["Help"] = "Help";
+    xkeyMap["Break"] = "Break";
+    xkeyMap["Mode_switch"] = "Mode_switch";
+    xkeyMap["script_switch"] = "script_switch";
+    xkeyMap["Num_Lock"] = "Num_Lock";
+    xkeyMap["KP_Space"] = "KP_Space";
+    xkeyMap["KP_Tab"] = "KP_Tab";
+    xkeyMap["KP_Enter"] = "KP_Enter";
+    xkeyMap["KP_F1"] = "KP_F1";
+    xkeyMap["KP_F2"] = "KP_F2";
+    xkeyMap["KP_F3"] = "KP_F3";
+    xkeyMap["KP_F4"] = "KP_F4";
+    xkeyMap["KP_Home"] = "KP_Home";
+    xkeyMap["KP_Left"] = "KP_Left";
+    xkeyMap["KP_Up"] = "KP_Up";
+    xkeyMap["KP_Right"] = "KP_Right";
+    xkeyMap["KP_Down"] = "KP_Down";
+    xkeyMap["KP_Prior"] = "KP_Prior";
+    xkeyMap["KP_Page_Up"] = "KP_Page_Up";
+    xkeyMap["KP_Next"] = "KP_Next";
+    xkeyMap["KP_Page_Down"] = "KP_Page_Down";
+    xkeyMap["KP_End"] = "KP_End";
+    xkeyMap["KP_Begin"] = "KP_Begin";
+    xkeyMap["KP_Insert"] = "KP_Insert";
+    xkeyMap["KP_Delete"] = "KP_Delete";
+    xkeyMap["KP_Equal"] = "KP_Equal";
+    xkeyMap["KP_Multiply"] = "KP_Multiply";
+    xkeyMap["KP_Add"] = "KP_Add";
+    xkeyMap["KP_Separator"] = "KP_Separator";
+    xkeyMap["KP_Subtract"] = "KP_Subtract";
+    xkeyMap["KP_Decimal"] = "KP_Decimal";
+    xkeyMap["KP_Divide"] = "KP_Divide";
+    xkeyMap["KP_0"] = "KP_0";
+    xkeyMap["KP_1"] = "KP_1";
+    xkeyMap["KP_2"] = "KP_2";
+    xkeyMap["KP_3"] = "KP_3";
+    xkeyMap["KP_4"] = "KP_4";
+    xkeyMap["KP_5"] = "KP_5";
+    xkeyMap["KP_6"] = "KP_6";
+    xkeyMap["KP_7"] = "KP_7";
+    xkeyMap["KP_8"] = "KP_8";
+    xkeyMap["KP_9"] = "KP_9";
+    xkeyMap["F1"] = "F1";
+    xkeyMap["F2"] = "F2";
+    xkeyMap["F3"] = "F3";
+    xkeyMap["F4"] = "F4";
+    xkeyMap["F5"] = "F5";
+    xkeyMap["F6"] = "F6";
+    xkeyMap["F7"] = "F7";
+    xkeyMap["F8"] = "F8";
+    xkeyMap["F9"] = "F9";
+    xkeyMap["F10"] = "F10";
+    xkeyMap["F11"] = "F11";
+    xkeyMap["L1"] = "L1";
+    xkeyMap["F12"] = "F12";
+    xkeyMap["L2"] = "L2";
+    xkeyMap["F13"] = "F13";
+    xkeyMap["L3"] = "L3";
+    xkeyMap["F14"] = "F14";
+    xkeyMap["L4"] = "L4";
+    xkeyMap["F15"] = "F15";
+    xkeyMap["L5"] = "L5";
+    xkeyMap["F16"] = "F16";
+    xkeyMap["L6"] = "L6";
+    xkeyMap["F17"] = "F17";
+    xkeyMap["L7"] = "L7";
+    xkeyMap["F18"] = "F18";
+    xkeyMap["L8"] = "L8";
+    xkeyMap["F19"] = "F19";
+    xkeyMap["L9"] = "L9";
+    xkeyMap["F20"] = "F20";
+    xkeyMap["L10"] = "L10";
+    xkeyMap["F21"] = "F21";
+    xkeyMap["R1"] = "R1";
+    xkeyMap["F22"] = "F22";
+    xkeyMap["R2"] = "R2";
+    xkeyMap["F23"] = "F23";
+    xkeyMap["R3"] = "R3";
+    xkeyMap["F24"] = "F24";
+    xkeyMap["R4"] = "R4";
+    xkeyMap["F25"] = "F25";
+    xkeyMap["R5"] = "R5";
+    xkeyMap["F26"] = "F26";
+    xkeyMap["R6"] = "R6";
+    xkeyMap["F27"] = "F27";
+    xkeyMap["R7"] = "R7";
+    xkeyMap["F28"] = "F28";
+    xkeyMap["R8"] = "R8";
+    xkeyMap["F29"] = "F29";
+    xkeyMap["R9"] = "R9";
+    xkeyMap["F30"] = "F30";
+    xkeyMap["R10"] = "R10";
+    xkeyMap["F31"] = "F31";
+    xkeyMap["R11"] = "R11";
+    xkeyMap["F32"] = "F32";
+    xkeyMap["R12"] = "R12";
+    xkeyMap["F33"] = "F33";
+    xkeyMap["R13"] = "R13";
+    xkeyMap["F34"] = "F34";
+    xkeyMap["R14"] = "R14";
+    xkeyMap["F35"] = "F35";
+    xkeyMap["R15"] = "R15";
+    xkeyMap["Shift_L"] = "Shift_L";
+    xkeyMap["Shift_R"] = "Shift_R";
+    xkeyMap["Control_L"] = "Control_L";
+    xkeyMap["Control_R"] = "Control_R";
+    xkeyMap["Caps_Lock"] = "Caps_Lock";
+    xkeyMap["Shift_Lock"] = "Shift_Lock";
+    xkeyMap["Meta_L"] = "Meta_L";
+    xkeyMap["Meta_R"] = "Meta_R";
+    xkeyMap["Alt_L"] = "Alt_L";
+    xkeyMap["Alt_R"] = "Alt_R";
+    xkeyMap["Super_L"] = "Super_L";
+    xkeyMap["Super_R"] = "Super_R";
+    xkeyMap["Hyper_L"] = "Hyper_L";
+    xkeyMap["Hyper_R"] = "Hyper_R";
+    xkeyMap["space"] = "space";
+    xkeyMap["exclam"] = "exclam";
+    xkeyMap["quotedbl"] = "quotedbl";
+    xkeyMap["numbersign"] = "numbersign";
+    xkeyMap["dollar"] = "dollar";
+    xkeyMap["percent"] = "percent";
+    xkeyMap["ampersand"] = "ampersand";
+    xkeyMap["apostrophe"] = "apostrophe";
+    xkeyMap["quoteright"] = "quoteright";
+    xkeyMap["parenleft"] = "parenleft";
+    xkeyMap["parenright"] = "parenright";
+    xkeyMap["asterisk"] = "asterisk";
+    xkeyMap["plus"] = "plus";
+    xkeyMap["comma"] = "comma";
+    xkeyMap["minus"] = "minus";
+    xkeyMap["period"] = "period";
+    xkeyMap["slash"] = "slash";
+    xkeyMap["colon"] = "colon";
+    xkeyMap["semicolon"] = "semicolon";
+    xkeyMap["less"] = "less";
+    xkeyMap["equal"] = "equal";
+    xkeyMap["greater"] = "greater";
+    xkeyMap["question"] = "question";
+    xkeyMap["at"] = "at";
+    xkeyMap["bracketleft"] = "bracketleft";
+    xkeyMap["backslash"] = "backslash";
+    xkeyMap["bracketright"] = "bracketright";
+    xkeyMap["asciicircum"] = "asciicircum";
+    xkeyMap["underscore"] = "underscore";
+    xkeyMap["grave"] = "grave";
+    xkeyMap["quoteleft"] = "quoteleft";
+    xkeyMap["braceleft"] = "braceleft";
+    xkeyMap["bar"] = "bar";
+    xkeyMap["braceright"] = "braceright";
+    xkeyMap["asciitilde"] = "asciitilde";
+    xkeyMap["nobreakspace"] = "nobreakspace";
+    xkeyMap["exclamdown"] = "exclamdown";
+    xkeyMap["cent"] = "cent";
+    xkeyMap["sterling"] = "sterling";
+    xkeyMap["currency"] = "currency";
+    xkeyMap["yen"] = "yen";
+    xkeyMap["brokenbar"] = "brokenbar";
+    xkeyMap["section"] = "section";
+    xkeyMap["diaeresis"] = "diaeresis";
+    xkeyMap["copyright"] = "copyright";
+    xkeyMap["ordfeminine"] = "ordfeminine";
+    xkeyMap["guillemotleft"] = "guillemotleft";
+    xkeyMap["notsign"] = "notsign";
+    xkeyMap["hyphen"] = "hyphen";
+    xkeyMap["registered"] = "registered";
+    xkeyMap["macron"] = "macron";
+    xkeyMap["degree"] = "degree";
+    xkeyMap["plusminus"] = "plusminus";
+    xkeyMap["twosuperior"] = "twosuperior";
+    xkeyMap["threesuperior"] = "threesuperior";
+    xkeyMap["acute"] = "acute";
+    xkeyMap["mu"] = "mu";
+    xkeyMap["paragraph"] = "paragraph";
+    xkeyMap["periodcentered"] = "periodcentered";
+    xkeyMap["cedilla"] = "cedilla";
+    xkeyMap["onesuperior"] = "onesuperior";
+    xkeyMap["masculine"] = "masculine";
+    xkeyMap["guillemotright"] = "guillemotright";
+    xkeyMap["onequarter"] = "onequarter";
+    xkeyMap["onehalf"] = "onehalf";
+    xkeyMap["threequarters"] = "threequarters";
+    xkeyMap["questiondown"] = "questiondown";
+    xkeyMap["Agrave"] = "Agrave";
+    xkeyMap["Aacute"] = "Aacute";
+    xkeyMap["Acircumflex"] = "Acircumflex";
+    xkeyMap["Atilde"] = "Atilde";
+    xkeyMap["Adiaeresis"] = "Adiaeresis";
+    xkeyMap["Aring"] = "Aring";
+    xkeyMap["AE"] = "AE";
+    xkeyMap["Ccedilla"] = "Ccedilla";
+    xkeyMap["Egrave"] = "Egrave";
+    xkeyMap["Eacute"] = "Eacute";
+    xkeyMap["Ecircumflex"] = "Ecircumflex";
+    xkeyMap["Ediaeresis"] = "Ediaeresis";
+    xkeyMap["Igrave"] = "Igrave";
+    xkeyMap["Iacute"] = "Iacute";
+    xkeyMap["Icircumflex"] = "Icircumflex";
+    xkeyMap["Idiaeresis"] = "Idiaeresis";
+    xkeyMap["ETH"] = "ETH";
+    xkeyMap["Eth"] = "Eth";
+    xkeyMap["Ntilde"] = "Ntilde";
+    xkeyMap["Ograve"] = "Ograve";
+    xkeyMap["Oacute"] = "Oacute";
+    xkeyMap["Ocircumflex"] = "Ocircumflex";
+    xkeyMap["Otilde"] = "Otilde";
+    xkeyMap["Odiaeresis"] = "Odiaeresis";
+    xkeyMap["multiply"] = "multiply";
+    xkeyMap["Ooblique"] = "Ooblique";
+    xkeyMap["Ugrave"] = "Ugrave";
+    xkeyMap["Uacute"] = "Uacute";
+    xkeyMap["Ucircumflex"] = "Ucircumflex";
+    xkeyMap["Udiaeresis"] = "Udiaeresis";
+    xkeyMap["Yacute"] = "Yacute";
+    xkeyMap["THORN"] = "THORN";
+    xkeyMap["Thorn"] = "Thorn";
+    xkeyMap["ssharp"] = "ssharp";
+    xkeyMap["agrave"] = "agrave";
+    xkeyMap["aacute"] = "aacute";
+    xkeyMap["acircumflex"] = "acircumflex";
+    xkeyMap["atilde"] = "atilde";
+    xkeyMap["adiaeresis"] = "adiaeresis";
+    xkeyMap["aring"] = "aring";
+    xkeyMap["ae"] = "ae";
+    xkeyMap["ccedilla"] = "ccedilla";
+    xkeyMap["egrave"] = "egrave";
+    xkeyMap["eacute"] = "eacute";
+    xkeyMap["ecircumflex"] = "ecircumflex";
+    xkeyMap["ediaeresis"] = "ediaeresis";
+    xkeyMap["igrave"] = "igrave";
+    xkeyMap["iacute"] = "iacute";
+    xkeyMap["icircumflex"] = "icircumflex";
+    xkeyMap["idiaeresis"] = "idiaeresis";
+    xkeyMap["eth"] = "eth";
+    xkeyMap["ntilde"] = "ntilde";
+    xkeyMap["ograve"] = "ograve";
+    xkeyMap["oacute"] = "oacute";
+    xkeyMap["ocircumflex"] = "ocircumflex";
+    xkeyMap["otilde"] = "otilde";
+    xkeyMap["odiaeresis"] = "odiaeresis";
+    xkeyMap["division"] = "division";
+    xkeyMap["oslash"] = "oslash";
+    xkeyMap["ugrave"] = "ugrave";
+    xkeyMap["uacute"] = "uacute";
+    xkeyMap["ucircumflex"] = "ucircumflex";
+    xkeyMap["udiaeresis"] = "udiaeresis";
+    xkeyMap["yacute"] = "yacute";
+    xkeyMap["thorn"] = "thorn";
+    xkeyMap["ydiaeresis"] = "ydiaeresis";
 
     stopCommandThread = false;
     pthread_create(&command_thread, NULL, CommandThread, this);
@@ -277,6 +558,8 @@
         result = processJump(tokens);
     else if (is_abbrev("key", tokens[0]))
         result = processKey(tokens);
+    else if (is_abbrev("xkey", tokens[0]))
+        result = processXKey(command);
     else if (is_abbrev("play", tokens[0]))
         result = processPlay(tokens);
     else if (is_abbrev("query", tokens[0]))
@@ -520,6 +803,19 @@
     return result;
 }
 
+QString NetworkControl::processXKey(QString command)
+{
+    QString result = "OK";
+
+    QString cmd = command.remove(0, 5);
+    if (xkeyMap.contains(cmd) || (cmd[0].isLetterOrNumber()))
+        sendxkey(cmd.toAscii().constData());
+    else
+        return QString("ERROR: Invalid syntax at '%1', see 'help xkey' for "
+                       "usage information").arg(cmd);
+    return result;
+}
+
 QString NetworkControl::processPlay(QStringList tokens)
 {
     QString result = "OK";
@@ -741,6 +1037,13 @@
         return listRecordings(tokens[2], tokens[3].toUpper());
     else if (is_abbrev("recordings", tokens[1]))
         return listRecordings();
+    else if (is_abbrev("focused", tokens[1]))
+    {
+        char *title;
+        get_focused_window(&title);
+        result = QString(title);
+    delete [] title;
+    }
     else
         return QString("ERROR: See 'help %1' for usage information")
                        .arg(tokens[0]);
@@ -803,6 +1106,27 @@
         }
         helpText += "\r\n";
     }
+    else if (is_abbrev("xkey", command))
+    {
+        helpText +=
+            "xkey LETTER           - Send the letter key specified\r\n"
+            "xkey NUMBER           - Send the number key specified\r\n"
+            "xkey CODE             - Send one of the following key codes\r\n"
+            "\r\n";
+
+        QMap<QString, QString>::Iterator it;
+        bool first = true;
+        for (it = xkeyMap.begin(); it != xkeyMap.end(); ++it)
+        {
+            if (first)
+                first = false;
+            else
+                helpText += ", ";
+
+            helpText += it.key();
+        }
+        helpText += "\r\n";
+    }
     else if (is_abbrev("play", command))
     {
         helpText +=
@@ -844,6 +1168,7 @@
             "query liveTV          - List current TV schedule\r\n"
             "query liveTV CHANID   - Query current program for specified channel\r\n"
             "query time            - Query current time on server\r\n"
+            "query focused         - Returns the name of the focused window\r\n"
             "query version         - Query Frontend version details\r\n";
     }
     else if (command == "exit")
@@ -863,6 +1188,7 @@
         "---------------\r\n"
         "jump               - Jump to a specified location in Myth\r\n"
         "key                - Send a keypress to the program\r\n"
+        "xkey               - Send a keypress to the focused program\r\n"
         "play               - Playback related commands\r\n"
         "query              - Queries\r\n"
         "exit               - Exit Network Control\r\n"
