diff --git a/SuperPutty/Utils/CommandData.cs b/SuperPutty/Utils/CommandData.cs index f5e3eef0..6438ec99 100644 --- a/SuperPutty/Utils/CommandData.cs +++ b/SuperPutty/Utils/CommandData.cs @@ -22,6 +22,11 @@ public CommandData(KeyEventArgs e) public KeyEventArgs KeyData { get; private set; } public void SendToTerminal(int handle) + { + SendToTerminal(handle, true); + } + + public void SendToTerminal(int handle, bool enter) { if (!string.IsNullOrEmpty(this.Command)) { @@ -30,7 +35,10 @@ public void SendToTerminal(int handle) { NativeMethods.SendMessage(handle, NativeMethods.WM_CHAR, (int)c, 0); } - NativeMethods.SendMessage(handle, NativeMethods.WM_CHAR, (int)Keys.Enter, 0); + if (enter) + { + NativeMethods.SendMessage(handle, NativeMethods.WM_CHAR, (int)Keys.Enter, 0); + } } else if (this.KeyData != null) { @@ -44,7 +52,7 @@ public void SendToTerminal(int handle) if (this.KeyData.Shift) { NativeMethods.PostMessage(handle, NativeMethods.WM_KEYUP, NativeMethods.VK_SHIFT, 0); } if (this.KeyData.Control) { NativeMethods.PostMessage(handle, NativeMethods.WM_KEYUP, NativeMethods.VK_CONTROL, 0); } } - else + else if (enter) { NativeMethods.SendMessage(handle, NativeMethods.WM_CHAR, (int)Keys.Enter, 0); } diff --git a/SuperPutty/frmSuperPutty.cs b/SuperPutty/frmSuperPutty.cs index c3055faf..7907e83e 100644 --- a/SuperPutty/frmSuperPutty.cs +++ b/SuperPutty/frmSuperPutty.cs @@ -1007,7 +1007,7 @@ private void tsSendCommandCombo_KeyDown(object sender, KeyEventArgs e) else if (e.KeyCode == Keys.Enter) { // send commands - TrySendCommandsFromToolbar(new CommandData(this.tsSendCommandCombo.Text), !this.tbBtnMaskText.Checked); + TrySendCommandsFromToolbar(new CommandData(this.tsSendCommandCombo.Text), !this.tbBtnMaskText.Checked, !e.Shift); e.Handled = true; e.SuppressKeyPress = true; } @@ -1047,10 +1047,20 @@ private void tbBtnMaskText_Click(object sender, EventArgs e) int TrySendCommandsFromToolbar(bool saveHistory) { - return TrySendCommandsFromToolbar(new CommandData(this.tsSendCommandCombo.Text), saveHistory); + return TrySendCommandsFromToolbar(new CommandData(this.tsSendCommandCombo.Text), saveHistory, true); + } + + int TrySendCommandsFromToolbar(bool saveHistory, bool enter) + { + return TrySendCommandsFromToolbar(new CommandData(this.tsSendCommandCombo.Text), saveHistory, enter); } int TrySendCommandsFromToolbar(CommandData command, bool saveHistory) + { + return TrySendCommandsFromToolbar(command, saveHistory, true); + } + + int TrySendCommandsFromToolbar(CommandData command, bool saveHistory, bool enter) { int sent = 0; if (this.DockPanel.DocumentsCount > 0) @@ -1063,7 +1073,7 @@ int TrySendCommandsFromToolbar(CommandData command, bool saveHistory) int handle = puttyPanel.AppPanel.AppWindowHandle.ToInt32(); Log.InfoFormat("SendCommand: session={0}, command=[{1}], handle={2}", puttyPanel.Session.SessionId, command, handle); - command.SendToTerminal(handle); + command.SendToTerminal(handle, enter); sent++; }