From 81fdc06ec3012995256bde3440a0a45c0f3b9c27 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Sun, 28 Jul 2019 14:32:54 -0700 Subject: [PATCH] Added remote desktop typing dialog. --- package.json | 2 +- public/scripts/amt-desktop-0.0.2.js | 8 +++-- views/default-min.handlebars | 2 +- views/default-mobile-min.handlebars | 2 +- views/default.handlebars | 55 +++++++++++++++++++++++++++-- 5 files changed, 61 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 97e84fc2..144cfed2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.3.8-p", + "version": "0.3.8-r", "keywords": [ "Remote Management", "Intel AMT", diff --git a/public/scripts/amt-desktop-0.0.2.js b/public/scripts/amt-desktop-0.0.2.js index 9767c24b..6b639936 100644 --- a/public/scripts/amt-desktop-0.0.2.js +++ b/public/scripts/amt-desktop-0.0.2.js @@ -747,8 +747,12 @@ var CreateAmtRemoteDesktop = function (divid, scrolldiv) { } obj.sendkey = function (k, d) { - if (typeof k == 'object') { for (var i in k) { obj.sendkey(k[i][0], k[i][1]); } } - else { obj.send(String.fromCharCode(4, d, 0, 0) + IntToStr(k)); } + if (typeof k == 'object') { + //for (var i in k) { obj.sendkey(k[i][0], k[i][1]); } + var buf = ''; for (var i in k) { buf += (String.fromCharCode(4, k[i][1], 0, 0) + IntToStr(k[i][0])); } obj.send(buf); + } else { + obj.send(String.fromCharCode(4, d, 0, 0) + IntToStr(k)); + } } function handleServerCutText(acc) { diff --git a/views/default-min.handlebars b/views/default-min.handlebars index ba2f0bb9..398a8638 100644 --- a/views/default-min.handlebars +++ b/views/default-min.handlebars @@ -1 +1 @@ - {{{title}}}
{{{title}}}
{{{title2}}}

{{{logoutControl}}}

 

\ No newline at end of file + {{{title}}}
{{{title}}}
{{{title2}}}

{{{logoutControl}}}

 

\ No newline at end of file diff --git a/views/default-mobile-min.handlebars b/views/default-mobile-min.handlebars index bdb372c9..b02b2847 100644 --- a/views/default-mobile-min.handlebars +++ b/views/default-mobile-min.handlebars @@ -1 +1 @@ - {{{title}}}
{{{title}}}
{{{title2}}}
\ No newline at end of file + {{{title}}}
{{{title}}}
{{{title2}}}
\ No newline at end of file diff --git a/views/default.handlebars b/views/default.handlebars index 5f0f5a5a..22ffe91f 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -503,6 +503,7 @@ +   @@ -2230,7 +2231,8 @@ } //function ondocfocus() { } - function ondocblur() { if (!xxdialogMode && xxcurrentView == 11 && desktop && Q("DeskControl").checked) { return desktop.m.handleReleaseKeys(); } } + // TODO: Add handleReleaseKeys() for Intel AMT. + function ondocblur() { if (!xxdialogMode && xxcurrentView == 11 && desktop && Q("DeskControl").checked && desktop.m.handleReleaseKeys) { return desktop.m.handleReleaseKeys(); } } // Highlights the device being hovered function devMouseHover(element, over) { @@ -2383,7 +2385,7 @@ //r += '' + (node.pwr != null ? powerStateStrings[node.pwr] : ''); r += ''; } else if ((view == 3) && (node.conn & 1) && (((meshrights & 8) || (meshrights & 256)) != 0) && ((node.agent.caps & 1) != 0)) { // Check if we have rights and agent is capable of KVM. - if ((multiDesktopFilter.length == 0) || (multiDesktopFilter.indexOf('devid_' + node._id) >= 0)) { + if ((multiDesktopFilter) && ((multiDesktopFilter.length == 0) || (multiDesktopFilter.indexOf('devid_' + node._id) >= 0))) { r += '
'; //r += ''; r += '
 ' + name + '
'; @@ -2474,7 +2476,7 @@ // Re-check nodeid's var elements = document.getElementsByClassName("DeviceCheckbox"), checkcount = 0; - for (var i=0;i= 0); } + if (checkedNodeids) { for (var i=0;i= 0); } } for (var i in deviceHeaders) { QH(i, deviceHeaders[i]); } for (var i in deviceHeadersTitles) { Q(i).title = deviceHeadersTitles[i]; } @@ -4575,6 +4577,7 @@ QV('deskFocusBtn', (desktop != null) && (desktop.contype == 2) && (deskState != 0) && (desktopsettings.showfocus)); QV('DeskClip', (currentNode.agent) && (currentNode.agent.id != 11) && (currentNode.agent.id != 16) && ((desktop == null) || (desktop.contype != 2))); // Clipboard not supported on MacOS QE('DeskClip', deskState == 3); + QE('DeskType', deskState == 3); QV('DeskWD', (currentNode.agent) && (currentNode.agent.id < 5) && inputAllowed); QE('DeskWD', deskState == 3); QV('deskkeys', (currentNode.agent) && (currentNode.agent.id < 5) && inputAllowed); @@ -5000,6 +5003,52 @@ } } + // Remote desktop typing + function showDeskType() { + if (xxdialogMode || desktop == null || desktop.State != 3) return; + Q('DeskType').blur(); + var x = '
Enter text and click OK to remotely type it using a US english keyboard. Make sure to place the remote cursor at the correct position before proceeding.
'; + x += ''; + setDialogMode(2, "Remote Keyboard Entry", 3, showDeskTypeEx, x); + Q('d2typeText').focus(); + } + + var AmtDeskTypeTimer = null; + var AmtDeskTypeContent = null; + var DeskTypeTranslate = { 39: 222, 42: 106, 43: 107, 44: 188, 45: 189, 46: 190, 47: 191, 59: 186, 61: 187, 91: 219, 92: 220, 93: 221, 96: 192, 191: 111 }; + var DeskTypeShiftTranslate = { 33: 49, 34: 222, 35: 51, 36: 52, 37: 53, 38: 55, 40: 57, 41: 48, 58: 186, 60: 188, 62: 190, 63: 191, 64: 50, 94: 54, 95: 189, 106: 56, 107: 187, 123: 219, 124: 220, 125: 221, 126: 192 }; + function showDeskTypeEx() { + var txt = Q('d2typeText').value, ltxt = Q('d2typeText').value.toUpperCase(), x = [], shift = false; + if (desktop.contype == 2) { + // Intel AMT + for (var i in txt) { var a = txt.charCodeAt(i); x.push([a, 1], [a, 0]); } + AmtDeskTypeContent = x; + AmtDeskTypeTimer = setInterval(function () { + var key = AmtDeskTypeContent.shift(); + if (desktop) { desktop.m.sendkey(key[0], key[1]); } + if ((desktop == null) || (AmtDeskTypeContent.length == 0)) { clearInterval(AmtDeskTypeTimer); AmtDeskTypeContent = null; } + }, 10); + } else { + // MeshAgent + for (var i in txt) { + var a = txt.charCodeAt(i), b = ltxt.charCodeAt(i); + if ((a >= 65) && (a <= 90)) { + if ((a == b) && (shift == false)) { x.push([desktop.m.KeyAction.DOWN, 16]); shift = true; } // LShift down + if ((a != b) && (shift == true)) { x.push([desktop.m.KeyAction.UP, 16]); shift = false; } // LShift up + } else if (DeskTypeTranslate[a]) { + if (shift == true) { x.push([desktop.m.KeyAction.UP, 16]); shift = false; } // Shift up + b = DeskTypeTranslate[a]; + } else if (DeskTypeShiftTranslate[a]) { + if (shift == false) { x.push([desktop.m.KeyAction.DOWN, 16]); shift = true; } // LShift down + b = DeskTypeShiftTranslate[a]; + } + x.push([desktop.m.KeyAction.DOWN, b], [desktop.m.KeyAction.UP, b]); + } + if (shift == true) { x.push([desktop.m.KeyAction.UP, 16]); shift = false; } // Shift up + desktop.m.SendKeyMsgKC(x); + } + } + // Show clipboard dialog function showDeskClip() { if (xxdialogMode || desktop == null || desktop.State != 3) return;