diff --git a/Sunfish/Sunfish/Resources/ShScreen.js b/Sunfish/Sunfish/Resources/ShScreen.js index 6bd4db3..a43a506 100644 --- a/Sunfish/Sunfish/Resources/ShScreen.js +++ b/Sunfish/Sunfish/Resources/ShScreen.js @@ -16,6 +16,7 @@ xmlhttp.onerror = function () { sending = false; } + //console.log(cmd); xmlhttp.send(); } this.start = function () { @@ -37,17 +38,20 @@ frm.style.display = ""; } img.onmousemove = function (evt) { - send(code, "M"+evt.offsetX+";"+evt.offsetY); + send(code, "MV"+evt.offsetX+";"+evt.offsetY); } img.onmousedown = function (evt) { - send(code, "D" + evt.offsetX + ";" + evt.offsetY); + var buttons = ["LD","MD","RD"]; + send(code, buttons[evt.button] + evt.offsetX + ";" + evt.offsetY); return false; } img.onmouseup = function (evt) { - send(code, "U" + evt.offsetX + ";" + evt.offsetY); + var buttons = ["LU", "MU", "RU"]; + send(code, buttons[evt.button] + evt.offsetX + ";" + evt.offsetY); } img.onmousewheel = function (evt) { - send(code, "W" + evt.offsetX + ";" + evt.offsetY + ";" + evt.wheelDelta); + send(code, "WH" + evt.offsetX + ";" + evt.offsetY + ";" + evt.wheelDelta); + return false; } img.onclick = function (evt) { evt.preventDefault(); diff --git a/Sunfish/Sunfish/wx/WebXplorer.cs b/Sunfish/Sunfish/wx/WebXplorer.cs index d46384b..83fd798 100644 --- a/Sunfish/Sunfish/wx/WebXplorer.cs +++ b/Sunfish/Sunfish/wx/WebXplorer.cs @@ -362,7 +362,8 @@ string cmd = GET["cmd"]; if (cmd.Length == 0) return; - string par = cmd.Substring(1); + string cc = cmd.Substring(0, 2); + string par = cmd.Substring(2); int x; int y; string[] pars = par.Split(';'); @@ -370,18 +371,29 @@ int.TryParse(pars[1], out y); Screen scr = Program.MAINFORM.MyScreen; System.Windows.Forms.Cursor.Position = new Point(x + scr.Bounds.X, y + scr.Bounds.Y); - switch (cmd[0]) + switch (cc) { - case 'D': + case "LD": Thread.Sleep(100); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); break; - case 'U': + case "LU": Thread.Sleep(100); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); break; - case 'W': - + case "RD": + Thread.Sleep(100); + mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0); + break; + case "RU": + Thread.Sleep(100); + mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0); + break; + case "WH": + Thread.Sleep(100); + int wheel; + int.TryParse(pars[2], out wheel); + mouse_event(MOUSEEVENTF_WHEEL, 0, 0, wheel, 0); break; } Out.Write("Ok"); @@ -392,6 +404,9 @@ #region WINAPI private const int MOUSEEVENTF_LEFTDOWN = 0x0002; /* left button down */ private const int MOUSEEVENTF_LEFTUP = 0x0004; /* left button up */ + private const int MOUSEEVENTF_RIGHTDOWN = 0x0008; /* left button down */ + private const int MOUSEEVENTF_RIGHTUP = 0x0010; /* left button up */ + private const int MOUSEEVENTF_WHEEL = 0x0800; /* The wheel has been moved, if the mouse has a wheel. The amount of movement is specified in dwData */ [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo); #endregion