/// <summary> /// Creates global keyboard listener. /// </summary> public KeyboardListener(frmSuperPutty form, GlobalHotkeys hotkeys) { this.hotkeys = hotkeys; this.form = form; // Dispatcher thread handling the KeyDown/KeyUp events. this.dispatcher = Dispatcher.CurrentDispatcher; // We have to store the LowLevelKeyboardProc, so that it is not garbage collected runtime hookedLowLevelKeyboardProc = (WinAPI.LowLevelKeyboardProc)LowLevelKeyboardProc; // Set the hook hookId = InterceptKeys.SetHook(hookedLowLevelKeyboardProc); // Assign the asynchronous callback event hookedKeyboardCallbackAsync = new KeyboardCallbackAsync(KeyboardListener_KeyboardCallbackAsync); }
public frmSuperPutty(string[] args) { this.children = new ConcurrentDictionary<IntPtr, bool>(); m_panelMapping = new ConcurrentDictionary<IntPtr, ctlPuttyPanel>(); m_hotkeys = new GlobalHotkeys(); m_keyboard = new KeyboardListener(this, m_hotkeys); m_titleTracker = new WindowTitleTracker(this); //m_outputDetector = new MinttyOutputDetector(this, m_outputMapping); registerHotkeys(); // Check SQLite Database openOrCreateSQLiteDatabase(); this.AddChild(this.Handle); #region Exe Paths // Get putty executable path if (File.Exists(this.m_db.GetKey("putty_exe"))) { PuttyExe = this.m_db.GetKey("putty_exe"); } // Get pscp executable path if (File.Exists(this.m_db.GetKey("pscp_exe"))) { PscpExe = this.m_db.GetKey("pscp_exe"); } // Get mintty executable path if (File.Exists(this.m_db.GetKey("mintty_exe"))) { MinttyExe = this.m_db.GetKey("mintty_exe"); } if (String.IsNullOrEmpty(PuttyExe)) { editLocations(); } if (String.IsNullOrEmpty(PuttyExe)) { MessageBox.Show("Cannot find PuTTY installation. Please visit http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html to download a copy", "PuTTY Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); System.Environment.Exit(1); } #endregion InitializeComponent(); #if DEBUG menuStrip1.BackColor = Color.Pink; // Only show the option for the debug log viewer when we're compiled with DEBUG defined. debugLogToolStripMenuItem.Visible = true; #endif //Activate PasswordChar for passwordfield in connectbar PasswordTextBox.TextBox.UseSystemPasswordChar = true; //Select protocol SSH ProtocolBox.SelectedItem = ProtocolBox.Items[0]; dockPanel1.ActiveDocumentChanged += dockPanel1_ActiveDocumentChanged; dockPanel1.LostFocus += dockPanel1_ActiveDocumentChanged; /* * Open the session treeview and dock it on the right */ m_Sessions = new SessionTreeview(this, dockPanel1); if(Classes.Database.GetBooleanKey("ShowSessionTreeview", true)) { ShowSessionTreeview(); } if (!Classes.Database.GetBooleanKey("ShowQuickConnectBar", true)) { this.ConnectToolStrip.Hide(); this.quickConnectToolStripMenuItem.Checked = false; } if (!Classes.Database.GetBooleanKey("ShowTopMenu", true)) { this.menuStrip1.Hide(); } /* * Parsing CL Arguments */ ParseClArguments(args); // First time automatic update check firstTimeAutomaticUpdateCheck(); // Set automatic update check menu item setAutomaticUpdateCheckMenuItem(); // Set addtional timing menu item setAdditionalTimingMenuItem(); // Check for updates. checkForUpdate(true); // Set window state and size setWindowStateAndSize(); focusHacks(); }
private void selectTab(GlobalHotkeys.Purpose tabPosition) { int tabs = this.children.Count - 1; if (tabs > 1) { int index = ((int)tabPosition) % ((int)GlobalHotkeys.Purpose.Tab1); if (tabPosition == GlobalHotkeys.Purpose.LastTab) { index = this.dockPanel1.Contents.Count - 1; } selectTab(index); } }