//----------------------------------------------------------------- public void AddChild (ISystemWindow sysWindow, ShadowCanvas canvas) { lock (_childEntries) { _childEntries.Add(new ChildEntry() { ChildWindow = sysWindow, Canvas = canvas }); } if (sysWindow.IsPositionGlobal) { _hasPopupChild = true; } else { _hasEmbeddedChild = true; } ZindexRecount(); if (!_focusTrackerEnabled && sysWindow.NeedFocusTracking && canvas.FocusEventsTracking) { Thread t = new Thread(FocusTracker); t.IsBackground = true; t.Start(); } if (canvas.KeyboardEventsTracking) { if (OnKeyEvent == null) { OnKeyEvent += KeyboardTracker; EnableKeyboardHookProc(); } else { OnKeyEvent += KeyboardTracker; } } _lastFocusHandle = (IntPtr) (-1); CorrectOrderPopup(); CorrectOrderEmbedded(); }
//----------------------------------------------------------------- public void RemoveChild (ISystemWindow sysWindow) { lock (_childEntries) { _childEntries.RemoveAll(ce => ce.ChildWindow.Handle == sysWindow.Handle); if (_childEntries.Count > 0) { _hasPopupChild = _childEntries.Any(c => c.ChildWindow.IsPositionGlobal); _hasEmbeddedChild = _childEntries.Any(c => !c.ChildWindow.IsPositionGlobal); } else { _hasPopupChild = false; _hasEmbeddedChild = false; } } ZindexRecount(); lock (_childEntries) { if (_focusTrackerEnabled && sysWindow.NeedFocusTracking && _childEntries.All(ce => !ce.ChildWindow.NeedFocusTracking && !ce.Canvas.FocusEventsTracking)) { _focusTrackerEnabled = false; } if (_childEntries.All(ce => !ce.Canvas.KeyboardEventsTracking)) { try { OnKeyEvent -= KeyboardTracker; } catch { } } } _lastFocusHandle = (IntPtr) (-1); }
public static void Apply(this CorrectTargetRegionData data, ISystemWindow window, ref Rectangle region) { var expand = Size.Subtract(window.Position.Size, window.ClientRectangle.Size); var offset = new Point(-expand.Width / 2, 0); region.Offset(offset); region.Size = Size.Add(region.Size, new Size(expand.Width, 0)); }
public Rule GetRuleForWindow(ISystemWindow window) { var result = Rules.FirstOrDefault(rule => (rule.Conditions.Any() && rule.Conditions.All(c => c.Check(window)))) ?? Rules.FirstOrDefault(rule => rule.Name == "Default"); if (result == null) { throw new KeyNotFoundException("Compatibility rule 'Default' is missing"); } return(result); }
private Rectangle SelectSuitableRegion(ISystemWindow window) { if (Methods.GetCursorPos(out NativePoint point)) { Logger.Info($"cursor position: {point}"); var region = _regionsManager.Regions.FirstOrDefault(r => r.Contains((int)point.X, (int)point.Y)); return(region); } Marshal.ThrowExceptionForHR(Marshal.GetLastWin32Error()); return(default);
public void Initialize(IPluginContext2 context) { _Context = context; _ExportQueriesButton = (_Context.MainMenu.Items["MMTools"] as ToolStripDropDownButton) .DropDownItems.Add("Export Selected Queries") as ToolStripMenuItem; _QueriesWindow = _Context.SystemWindows .Where <ISystemWindow>(w => w.Text == "Queries") .FirstOrDefault(); _ExportQueriesButton.Click += _ExportQueriesButton_Click; }
public static void Apply(this IActionData data, ISystemWindow window, ref Rectangle region) { var type = data.GetType(); if (_methods.TryGetValue(type, out var method)) { var parameters = new object[] { data, window, region }; method.Invoke(null, parameters); region = (Rectangle)parameters[2]; } else { throw new ArgumentException($"Not found suitable method for '{type}' type"); } }
private bool FilterWindows(ISystemWindow window) { if (!window.Visible) { return(false); } if (window.Position.Size == default)//HACK: костыль для окон с замороженным интерфейсом https://stackoverflow.com/questions/9537171/automationelement-fromhandle-execution-time-is-intermittently-slow { return(false); } if (!window.Style.HasFlag(WindowStyle.PopupWindow) && window.Style.HasFlag(WindowStyle.Popup)) { return(false); } return(true); }
private void OnWindowClosed(ISystemWindow window) { try { Logger.Info($"Window '{window.CachedTitle}'({window.Handle}) closed."); var windowElement = AutomationElement.FromHandle(window.Handle); if (windowElement != null) { Automation.RemoveAutomationPropertyChangedEventHandler(windowElement, Window_VisualStateChanged); } Logger.Info($"Window '{window.CachedTitle}'({window.Handle}) handlers removed."); } catch (Exception e) { Logger.Error(e, $"Window '{window.CachedTitle}'({window.Handle}) cant remove handlers."); } }
//--------------------------------------------------------------------- public void Init (IntPtr dependentWindowHandle, Window window, EmbeddingOptions options = EmbeddingOptions.BestPerformance) { IntPtr handle = (new WindowInteropHelper(window)).Handle; if (_childDispatchers.All(fhs => fhs.Handle != handle)) { _childDispatcher = new ChildWindowsDispatcher(handle, window); _childDispatchers.Add(_childDispatcher); HwndSource source = PresentationSource.FromVisual(window) as HwndSource; source.AddHook(_childDispatcher.WndProc); } else { _childDispatcher = _childDispatchers.First(fhs => fhs.Handle == handle); } if (_systemWindow != null && _grabbed) { Release(); _systemWindow = SystemWindow.GetSystemWindow(dependentWindowHandle, options); Grab(); } else { _systemWindow = SystemWindow.GetSystemWindow(dependentWindowHandle, options); } }
private void OnWindowOpened(ISystemWindow window) { try { Logger.Info($"Window '{window.CachedTitle}'({window.Handle}) opened."); //_windowsFactory.SetRule(window); var windowElement = AutomationElement.FromHandle(window.Handle); if (windowElement != null) { //Automation.AddAutomationPropertyChangedEventHandler(windowElement, TreeScope.Element, this.handlePropertyChange, AutomationElement.ItemStatusProperty); Automation.AddAutomationPropertyChangedEventHandler(windowElement, TreeScope.Element, Window_VisualStateChanged, WindowPattern.WindowVisualStateProperty); } Logger.Info($"Window '{window.CachedTitle}'({window.Handle}) handlers added."); } catch (Exception e) { Logger.Error(e, $"Window '{window.CachedTitle}'({window.Handle}) cant add handlers."); } }
protected override string GetValue(ISystemWindow window) { return(window.Title); }
protected override string GetValue(ISystemWindow window) { return(window.WindowClass); }
public static void Apply(this User32PostMessageData data, ISystemWindow window, ref Rectangle region) { Methods.PostMessage(window.Handle, data.Message, default, default);
public static void Apply(this User32MoveWindowData data, ISystemWindow window, ref Rectangle region) { Methods.MoveWindow(window.Handle, region.Left, region.Top, region.Width, region.Height, data.ShouldRepaint); }
public static void Apply(this ModifyTargetRegionData data, ISystemWindow window, ref Rectangle region) { region.Offset(new Point(data.Left, data.Top)); region.Size = Size.Add(region.Size, new Size(data.Right - data.Left, data.Bottom - data.Top)); }
public bool Equals(ISystemWindow other) { return(other != null && Handle == other.Handle); }
public sealed override bool Check(ISystemWindow window) { return(TargetValue == GetValue(window)); }