private Button buildBtn(IWindowEntry win, int setElementWidth, int setElementMargin) { // http://www.bubuko.com/infodetail-2282119.html // https://blog.csdn.net/honantic/article/details/48781543 //https://bbs.csdn.net/topics/392094061 //https://social.msdn.microsoft.com/Forums/vstudio/en-US/99856840-f8ef-4547-9150-c4c46ec2f3df/need-dashed-focus-box?forum=wpf Button btn = new Button(); btn.Width = btn.Height = setElementWidth; btn.Margin = new Thickness(setElementMargin, 0, setElementMargin, 0); var backImg = CoreSearchResult.LoadIcon(win); if (backImg == null && !string.IsNullOrEmpty(win.ProcessName)) { btn.Background = GoToWindow.Plugins.Core.Utils.IconLoader.DrawText(win.ProcessName, null, System.Drawing.Color.White, System.Drawing.Color.Transparent); } else { btn.Background = new ImageBrush(backImg); } btn.BorderBrush = null; btn.GotFocus += Btn_GotFocus; btn.FocusVisualStyle = null; btn.PreviewMouseDown += Btn_PreviewMouseDown; btn.Tag = win; SetHotkey(win); return(btn); }
internal void Show(IWindowEntry windowEntry, Action onExePathWinUpdate) { mEntity = new TbExecutablePathEntity(windowEntry.ProcessName, windowEntry.ExecutablePath); mCallback = onExePathWinUpdate; Show(); ShowDialogAndUpdate(mEntity, true); }
public void Hide(bool hideIfPending, bool requested, MainWindow target) { if (!requested && Settings.Default.KeepOpenOnLostFocus) { Log.Debug("Ignoring hide on focus out because KeepOpenOnLostFocus is active."); return; } lock (_lock) { if (_mainWindow == null || !ReferenceEquals(_mainWindow, target)) { Log.Debug("Ignore hide request because window is already hidden."); return; } try { _mainWindow.Close(); Log.Debug("Window Hidden"); } catch (InvalidOperationException exc) { Log.Warn("Window is still closing", exc); } catch (Exception exc) { Log.Error("Failed hiding window.", exc); } _mainWindow = null; _mainViewModel = null; _mainWindowEntry = null; } }
public bool IsSameWindow(IWindowEntry other) { if (other == null) return false; return ProcessId == other.ProcessId && HWnd == other.HWnd; }
public static void Del(IWindowEntry win) { TbHideWin db = new TbHideWin(); db.Open(); db.ExeSQL(string.Format("delete from {0} where name='{1}' and title='{2}'", db.TB_HIDEWIN, win.ProcessName, win.Title)); db.Close(); }
internal void Show(IWindowEntry win) { mWin = win; BoxInfo.Text = win.ProcessName + " 快捷键:" + (Key)win.hotKey + "\n" + win.Title; BoxInfo.Text += "\n按alt+tab,松开tab,然后按快捷键,即可切换到对应的窗口"; BoxInfo.Text += "\n按Delete,删除当前快捷键"; Show(); }
private void SaveHotKey(IWindowEntry win, Key key) { if (win.hotKey != (int)key) { win.hotKey = (int)key; Database.updateHotkey(win); //win.onHotkeyUpdate(); } }
private void SaveHotKey(IWindowEntry win, Key key) { if (win.hotKey != (int)key) { win.hotKey = (int)key; TbHotkey.updateHotkey(win, string.IsNullOrEmpty(win.ExecutablePath) ? false : true); mCallback(); } }
private static bool IsKnownException(IWindowEntry window) { if (window.ProcessName == "Fiddler" && window.Title == "SSFiddlerMsgWin") { return(true); } return(false); }
public bool IsSameWindow(IWindowEntry other) { if (other == null) { return(false); } return(ProcessId == other.ProcessId && HWnd == other.HWnd); }
public static void Add(IWindowEntry win) { Del(win); TbHideWin db = new TbHideWin(); db.Open(); db.ExeSQL(string.Format("insert into {0} (name,title) values('{1}','{2}')", db.TB_HIDEWIN, win.ProcessName, win.Title)); db.Close(); }
internal void Show(IWindowEntry win, Action onHideWinUpdate) { Show(); if (MessageBox.Show(String.Format("确定隐藏 \n程序名:{0}\n标题:{1} \n 窗口吗?", win.ProcessName, win.Title), "隐藏窗口", MessageBoxButton.OKCancel) == MessageBoxResult.OK) { TbHideWin.Add(win); onHideWinUpdate(); Close(); } }
internal void Show(IWindowEntry win, Action callback) { mWin = win; mCallback = callback; BoxInfo.Text = "请直接输入快捷键\n"; BoxInfo.Text += "\n说明:按alt+tab,松开tab,然后按快捷键,即可切换到对应的窗口"; BoxInfo.Text += "\n\n当前信息:" + win.ProcessName + " 快捷键:" + (Key)win.hotKey + " " + win.Title; BoxInfo.Text += "\n\n按Delete,删除当前快捷键\n按F11进入详细设置"; Show(); }
public static BitmapFrame LoadIcon(IWindowEntry win) { //string executable; //using (var process = Process.GetProcessById((int)win.ProcessId)) //{ // executable = process.GetExecutablePath(); //} return(IconLoader.LoadIcon(win.IconHandle, win.ExecutablePath)); }
private void SetHotkey(IWindowEntry win) { bool find = false; foreach (var item in mListHotkey) { if (win.ProcessName.Equals(item.name)) { win.hotKey = item.key; find = true; break; } } if (!find) { win.hotKey = 0; } }
public void Show() { lock (_lock) { if (_state == GoToWindowState.Shown) { Log.Debug("Sending Tab Again to Main Window."); _mainWindow.ShortcutAgain(); return; } if (_state != GoToWindowState.Hidden) { return; } Log.Debug("Showing Main Window."); _state = GoToWindowState.Showing; } if (Showing != null) { Showing(this, new EventArgs()); } SetAvailableWindowSize(SystemParameters.PrimaryScreenWidth, SystemParameters.PrimaryScreenHeight); _mainWindow.Left = SystemParameters.PrimaryScreenWidth / 2f - _mainViewModel.AvailableWindowWidth / 2f; _mainWindow.Top = SystemParameters.PrimaryScreenHeight / 2f - (_mainViewModel.AvailableWindowHeight + 56) / 2f; _mainWindow.Show(); if (_mainWindowEntry == null) { var interopHelper = new WindowInteropHelper(_mainWindow); _mainWindowEntry = WindowEntryFactory.Create(interopHelper.Handle); Log.DebugFormat("GoToWindow main window created with hWnd {0}", _mainWindowEntry.HWnd); } _mainWindow.SetFocus(); _mainWindowEntry.Focus(); Application.Current.Dispatcher.InvokeAsync(LoadViewModel, DispatcherPriority.Background); }
public static void updateHotkey(IWindowEntry win) { Database db = new Database(); db.Open(); using (var dr = db.ExeQuerySQL(string.Format("select key from {0} where name='{1}'", db.TB_HOTKEY, win.ProcessName))) { // 把原来先设置好的快捷键取消 db.ExeSQL(String.Format("update {0} set key=0 where key={1}", db.TB_HOTKEY, win.hotKey)); if (dr.Read()) { db.ExeSQL(String.Format("update {0} set key={1} where name='{2}'", db.TB_HOTKEY, win.hotKey, win.ProcessName)); } else { db.ExeSQL(string.Format("insert into {0} (name,key) values('{1}',{2})", db.TB_HOTKEY, win.ProcessName, win.hotKey)); } } db.Close(); }
public void Show() { lock (_lock) { if (_mainWindow != null) { Log.Debug("Sending Tab Again to Main Window."); _mainWindow.ShortcutAgain(); return; } _mainViewModel = new MainViewModel(); SetAvailableWindowSize(SystemParameters.PrimaryScreenWidth, SystemParameters.PrimaryScreenHeight); _mainWindow = new MainWindow { DataContext = _mainViewModel }; _mainWindow.Closing += _mainWindow_Closing; _mainViewModel.Close += _mainViewModel_Close; Showing?.Invoke(this, new EventArgs()); _mainWindow.Left = SystemParameters.PrimaryScreenWidth / 2f - _mainViewModel.AvailableWindowWidth / 2f; _mainWindow.Top = SystemParameters.PrimaryScreenHeight / 2f - (_mainViewModel.AvailableWindowHeight + 56) / 2f; _mainWindow.Width = _mainViewModel.AvailableWindowWidth; _mainWindow.Show(); var interopHelper = new WindowInteropHelper(_mainWindow); _mainWindowEntry = WindowEntryFactory.Create(interopHelper.Handle); Log.DebugFormat("GoToWindow main window created with hWnd {0}", _mainWindowEntry.HWnd); _mainWindow.SetFocus(); _mainWindowEntry.Focus(); Application.Current.Dispatcher.InvokeAsync(LoadViewModel, DispatcherPriority.Input); } }
private Button buildBtn(IWindowEntry win, int setElementWidth, int setElementMargin) { // http://www.bubuko.com/infodetail-2282119.html // https://blog.csdn.net/honantic/article/details/48781543 //https://bbs.csdn.net/topics/392094061 //https://social.msdn.microsoft.com/Forums/vstudio/en-US/99856840-f8ef-4547-9150-c4c46ec2f3df/need-dashed-focus-box?forum=wpf Button btn = new Button(); btn.Width = btn.Height = setElementWidth; btn.Margin = new Thickness(setElementMargin, 0, setElementMargin, 0); btn.Background = new ImageBrush(CoreSearchResult.LoadIcon(win)); btn.BorderBrush = null; btn.GotFocus += Btn_GotFocus; btn.FocusVisualStyle = (Style)FindResource("newFocusStyle"); btn.PreviewMouseDown += Btn_PreviewMouseDown; btn.Tag = win; //win.onHotkeyUpdate = OnHotkeyUpdateEvent; SetHotkey(win); return(btn); }
private static void UpdateProcessName(IWindowEntry window) { window.ProcessName = WmiProcessWatcher.GetProcessName(window.ProcessId, () => { using (var process = Process.GetProcessById((int)window.ProcessId)) { //TODO: Windows 10 App Icons /* * try * { * window.ProcessFileName = process.MainModule.FileName; * } * catch (Exception ex) * { * Log.Warn("Could not get the executable name of the process " + window, ex); * } * */ return(process.ProcessName); } }); }
private static bool IsKnownException(IWindowEntry window) { if (window.ProcessName == "Fiddler" && window.Title == "SSFiddlerMsgWin") return true; return false; }
private void switchToWin(IWindowEntry tag) { WindowToForeground.ForceWindowToForeground(tag.HWnd); HideWin(); }
public CoreSearchResult(IWindowEntry entry, Func<UserControl> viewCtor) : base(viewCtor) { _entry = entry; }
private static ISearchResult ConvertWindowEntryToSearchResult(IWindowEntry entry) { return(new CoreSearchResult(entry, () => new BasicListEntry())); }
public CoreSearchResult(IWindowEntry entry, Func <UserControl> viewCtor) : base(viewCtor) { _entry = entry; }
private void showWin(IWindowEntry tag) { ShowWindow(tag.HWnd, 1); SwitchToThisWindow(tag.HWnd, true); HideWin(); }
internal void Show(IWindowEntry win, Action callback) { mCallback = callback; Show(); }
private void AssertExists(IList <IWindowEntry> windows, IWindowEntry expected) { var containsExpected = windows.Any(expected.IsSameWindow); Assert.IsTrue(containsExpected, String.Format("Expected window {0}.\r\nWindows List:\r\n{1}", expected, String.Join("\r\n", windows))); }
public void Show() { lock (_lock) { if (_state == GoToWindowState.Shown) { Log.Debug("Sending Tab Again to Main Window."); _mainWindow.ShortcutAgain(); return; } if (_state != GoToWindowState.Hidden) return; Log.Debug("Showing Main Window."); _state = GoToWindowState.Showing; } if (Showing != null) Showing(this, new EventArgs()); SetAvailableWindowSize(SystemParameters.PrimaryScreenWidth, SystemParameters.PrimaryScreenHeight); _mainWindow.Left = SystemParameters.PrimaryScreenWidth/2f - _mainViewModel.AvailableWindowWidth/2f; _mainWindow.Top = SystemParameters.PrimaryScreenHeight/2f - (_mainViewModel.AvailableWindowHeight + 56)/2f; _mainWindow.Show(); if (_mainWindowEntry == null) { var interopHelper = new WindowInteropHelper(_mainWindow); _mainWindowEntry = WindowEntryFactory.Create(interopHelper.Handle); Log.DebugFormat("GoToWindow main window created with hWnd {0}", _mainWindowEntry.HWnd); } _mainWindow.SetFocus(); _mainWindowEntry.Focus(); Application.Current.Dispatcher.InvokeAsync(LoadViewModel, DispatcherPriority.Background); }
private static void UpdateProcessName(IWindowEntry window) { window.ProcessName = WmiProcessWatcher.GetProcessName(window.ProcessId, () => { using (var process = Process.GetProcessById((int) window.ProcessId)) { //TODO: Windows 10 App Icons /* try { window.ProcessFileName = process.MainModule.FileName; } catch (Exception ex) { Log.Warn("Could not get the executable name of the process " + window, ex); } * */ return process.ProcessName; } }); }
private void AssertExists(IList <IWindowEntry> windows, IWindowEntry expected) { var containsExpected = windows.Any(expected.IsSameWindow); Assert.IsTrue(containsExpected, $"Expected window {expected}.\r\nWindows List:\r\n{string.Join("\r\n", windows)}"); }
private static ISearchResult ConvertWindowEntryToSearchResult(IWindowEntry entry) { return new CoreSearchResult(entry, () => new BasicListEntry()); }
public static void CloseWindow(IWindowEntry win) { // https://blog.csdn.net/hellokandy/article/details/53408799 SendMessageTimeout(win.HWnd, WM_CLOSE, 0, 0, 0, 50, out IntPtr iconHandle); }
public static void updateHotkey(IWindowEntry win, bool isUpdatePath) { var entity = new TbHotKeyEntity(win.ProcessName, win.hotKey, win.ExecutablePath); updateHotkey(entity, isUpdatePath); }
private void AssertExists(IList<IWindowEntry> windows, IWindowEntry expected) { var containsExpected = windows.Any(expected.IsSameWindow); Assert.IsTrue(containsExpected, String.Format("Expected window {0}.\r\nWindows List:\r\n{1}", expected, String.Join("\r\n", windows))); }