1
0
mirror of https://github.com/Ylianst/MeshCentralRouter synced 2025-12-06 00:13:33 +00:00

Minor fix in case agent does not support remote desktop.

This commit is contained in:
Ylian Saint-Hilaire
2020-11-27 14:27:24 -08:00
parent 9812e8c67f
commit ba20ab746c
3 changed files with 21 additions and 24 deletions

View File

@@ -84,12 +84,12 @@ namespace MeshCentralRouter
private enum KvmMouseButtonCommands
{
MOUSEEVENTF_LEFTDOWN = 0x0002,
MOUSEEVENTF_RIGHTDOWN = 0x0008,
MOUSEEVENTF_MIDDLEDOWN = 0x0020,
MOUSEEVENTF_LEFTUP = 0x0004,
MOUSEEVENTF_RIGHTUP = 0x0010,
MOUSEEVENTF_MIDDLEUP = 0x0040
MOUSEEVENTF_LEFTDOWN = 0x0002,
MOUSEEVENTF_RIGHTDOWN = 0x0008,
MOUSEEVENTF_MIDDLEDOWN = 0x0020,
MOUSEEVENTF_LEFTUP = 0x0004,
MOUSEEVENTF_RIGHTUP = 0x0010,
MOUSEEVENTF_MIDDLEUP = 0x0040
}
[Category("Action")]
@@ -144,14 +144,7 @@ namespace MeshCentralRouter
{
isHookWanted = false;
}
if (Settings.GetRegValue("Exp_KeyboardHookPriority", false))
{
isHookPriority = true;
}
else
{
isHookPriority = false;
}
isHookPriority = Settings.GetRegValue("Exp_KeyboardHookPriority", false);
}
public void AttachKeyboard()
@@ -249,8 +242,8 @@ namespace MeshCentralRouter
ushort sourcey = (ushort)((buffer[off + 6] << 8) + buffer[off + 7]);
ushort targetx = (ushort)((buffer[off + 8] << 8) + buffer[off + 9]);
ushort targety = (ushort)((buffer[off + 10] << 8) + buffer[off + 11]);
ushort tilew = (ushort)((buffer[off + 12] << 8) + buffer[off + 13]);
ushort tileh = (ushort)((buffer[off + 14] << 8) + buffer[off + 15]);
ushort tilew = (ushort)((buffer[off + 12] << 8) + buffer[off + 13]);
ushort tileh = (ushort)((buffer[off + 14] << 8) + buffer[off + 15]);
Rectangle r1 = new Rectangle((int)sourcex, (int)sourcey, (int)tilew, (int)tileh);
Rectangle r2 = new Rectangle((int)targetx, (int)targety, (int)tilew, (int)tileh);
Rectangle r3 = new Rectangle((int)((double)targetx / (double)scalefactor) - 2, (int)((double)targety / (double)scalefactor) - 2, (int)((double)tilew / (double)scalefactor) + 4, (int)((double)tileh / (double)scalefactor) + 4);
@@ -323,7 +316,7 @@ namespace MeshCentralRouter
private delegate void ChangeMouseCursorHandler(int cursorId);
private void ChangeMouseCursor(int cursorId)
{
if (this.InvokeRequired) { this.Invoke(new ChangeMouseCursorHandler(ChangeMouseCursor), cursorId); return; }
if (this.InvokeRequired) { this.Invoke(new ChangeMouseCursorHandler(ChangeMouseCursor), cursorId); return; }
if (cursorId == 0) { this.Cursor = System.Windows.Forms.Cursors.Default; return; } // default
if (cursorId == 1) { this.Cursor = System.Windows.Forms.Cursors.AppStarting; return; } // progress
if (cursorId == 2) { this.Cursor = System.Windows.Forms.Cursors.Cross; return; } // crosshair
@@ -418,7 +411,8 @@ namespace MeshCentralRouter
if (remoteKeybaordMap == true) return;
if (killNextKeyPress > 0) {
if (killNextKeyPress > 0)
{
long t = DateTime.Now.Ticks;
if ((t - killNextKeyPress) < 10) { killNextKeyPress = 0; return; }
}
@@ -568,7 +562,7 @@ namespace MeshCentralRouter
//if (remotepauseactive == false || paused == remotepause) return;
//if (paused == remotepause) return;
remotepause = paused;
BinaryWriter bw = GetBinaryWriter();
bw.Write(IPAddress.HostToNetworkOrder((short)KvmCommands.Pause));
bw.Write(IPAddress.HostToNetworkOrder((short)5));
@@ -615,7 +609,7 @@ namespace MeshCentralRouter
}
RecycleBinaryWriter(bw);
}
private void KVMControl_MouseDown(object sender, MouseEventArgs e)
{
SendMouse(e, 1);
@@ -631,7 +625,8 @@ namespace MeshCentralRouter
private void KVMControl_MouseMove(object sender, MouseEventArgs e)
{
long ct = DateTime.Now.Ticks;
if ((lastMouseMove + 30) < ct) {
if ((lastMouseMove + 30) < ct)
{
lastMouseMove = ct;
SendMouse(e, 0);
}

View File

@@ -191,7 +191,7 @@ namespace MeshCentralRouter
return;
}
if (state != 3) return;
// Parse the received JSON
Dictionary<string, object> jsonAction = new Dictionary<string, object>();
jsonAction = new JavaScriptSerializer().Deserialize<Dictionary<string, object>>(data);
@@ -203,7 +203,7 @@ namespace MeshCentralRouter
case "metadata":
{
if ((jsonAction.ContainsKey("users") == false) || (jsonAction["users"] == null)) return;
Dictionary <string, object> usersex = (Dictionary<string, object>)jsonAction["users"];
Dictionary<string, object> usersex = (Dictionary<string, object>)jsonAction["users"];
userSessions = new Dictionary<string, int>();
foreach (string user in usersex.Keys) { userSessions.Add(user, (int)usersex[user]); }
UpdateStatus();
@@ -475,7 +475,8 @@ namespace MeshCentralRouter
{
kvmStats = new KVMStats(this);
kvmStats.Show(this);
} else
}
else
{
kvmStats.Focus();
}

View File

@@ -1666,6 +1666,7 @@ namespace MeshCentralRouter
if (devicesListView.SelectedItems.Count != 1) { return; }
ListViewItem selecteditem = devicesListView.SelectedItems[0];
NodeClass node = (NodeClass)selecteditem.Tag;
if ((node.agentcaps & 1) == 0) { return; } // Agent does not support remote desktop
if ((node.conn & 1) == 0) { return; } // Agent not connected on this device
if (node.desktopViewer == null)
{