コード例 #1
0
 private void WinEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
 {
     if (eventType == EVENT_SYSTEM_FOREGROUND)
     {
         ActiveWindowChanged?.Invoke(this, hwnd);
     }
 }
コード例 #2
0
        internal ProcessProvider(ActiveWindowChanged callback, string processName)
        {
            action = () =>
            {
                while (loop)
                {
                    var processes = Process.GetProcessesByName(processName);
                    var foregroundWindow = GetForegroundWindow();
                    var windowFound = false;

                    foreach (var window in processes.Select(EnumerateProcessWindowHandles).SelectMany(windows =>
                    {
                        var intPtrs = windows as IntPtr[] ?? windows.ToArray();
                        return intPtrs;
                    }).Where(window => foregroundWindow != hWndLast))
                    {
                        if (foregroundWindow != Process.GetCurrentProcess().MainWindowHandle)
                        {
                            hWndLast = window;
                            callback(foregroundWindow == window, window);
                        }
                    }

                    Thread.Sleep(150);
                }
            };

            Task.Factory.StartNew(action);
        }
コード例 #3
0
ファイル: ModuleHook.cs プロジェクト: Rideu/WinKeys
 public static void WinEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
 {
     var x = GetActiveWindowTitle();
     //if (wink != null)
     {
         ActiveWindowChanged?.Invoke(null, x);
         //wink.Lock = x != "GTA: San Andreas";
     }
 }
コード例 #4
0
        void SetActiveWindow(Window window)
        {
            if (_activeWindow == window)
            {
                return;
            }

            _activeWindow = window;
            ActiveWindowChanged?.Invoke(window, EventArgs.Empty);
        }
コード例 #5
0
 private void WinEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
 {
     switch (eventType)
     {
     case EVENT_SYSTEM_FOREGROUND:
     case EVENT_SYSTEM_MINIMIZESTART:
     case EVENT_SYSTEM_MINIMIZEEND:
         Task.Factory.StartNew(() => {
             ActiveWindowChanged?.Invoke(this, new ActiveWindowChangedEventArgs(hwnd));
         });
         break;
     }
 }
コード例 #6
0
        void SetActiveWindow(Window window)
        {
            if (_activeWindow == window)
            {
                return;
            }

            _activeWindow       = window;
            _activeWindowHandle = window is null
                                ? IntPtr.Zero
                                : WinRT.Interop.WindowNative.GetWindowHandle(window);

            ActiveWindowChanged?.Invoke(window, EventArgs.Empty);
        }
コード例 #7
0
        private async Task CreateVisualComponentAsync(int instanceId)
        {
            var factory   = Services.GetService <IInteractiveWindowComponentContainerFactory>();
            var evaluator = new RInteractiveEvaluator(RSessions, RSession, History, Connections, Services, _settings, Console);

            var window            = factory.Create(instanceId, evaluator, RSessions);
            var interactiveWindow = window.InteractiveWindow;

            interactiveWindow.TextView.Closed += (_, __) => evaluator.Dispose();
            _operations.InteractiveWindow      = interactiveWindow;

            if (!RSessions.HasBroker)
            {
                var connectedToBroker = await Connections.TryConnectToPreviouslyUsedAsync();

                if (!connectedToBroker)
                {
                    var showConnectionsWindow = Connections.RecentConnections.Any();
                    if (!showConnectionsWindow)
                    {
                        var message = Resources.NoLocalR.FormatInvariant(Environment.NewLine + Environment.NewLine,
                                                                         Environment.NewLine);
                        var ui = Services.UI();
                        showConnectionsWindow = ui.ShowMessage(message, MessageButtons.YesNo) == MessageButtons.No;
                    }

                    if (!showConnectionsWindow)
                    {
                        var installer = Services.GetService <IMicrosoftRClientInstaller>();
                        installer.LaunchRClientSetup(Services);
                    }
                    else
                    {
                        var toolWindows = Services.GetService <IRInteractiveWorkflowToolWindowService>();
                        toolWindows.Connections().Show(focus: false, immediate: false);
                    }
                }
            }

            await interactiveWindow.InitializeAsync();

            RSession.RestartOnBrokerSwitch = true;

            ActiveWindow = window;
            ActiveWindow.Container.UpdateCommandStatus(true);
            _visualComponentTcs.SetResult(ActiveWindow);
            ActiveWindowChanged?.Invoke(this, new ActiveWindowChangedEventArgs(window));
        }
コード例 #8
0
ファイル: WindowManager.cs プロジェクト: snetts/Shapeshifter
 protected virtual void OnActiveWindowChanged()
 {
     ActiveWindowChanged?.Invoke(this, EventArgs.Empty);
 }
コード例 #9
0
ファイル: NativeMethods.cs プロジェクト: proqk/OverlayPlugin
 private static void WinEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
 {
     ActiveWindowHandle = hwnd;
     ActiveWindowChanged?.Invoke(null, hwnd);
 }
コード例 #10
0
 private void WinEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild,
                           uint dwEventThread, uint dwmsEventTime)
 {
     ActiveWindowChanged?.Invoke(hwnd);
 }
コード例 #11
0
 private void OnActiveWindowChanged()
 {
     ActiveWindowChanged?.Invoke(this, EventArgs.Empty);
 }
コード例 #12
0
ファイル: ActiveWindow.cs プロジェクト: Zumwani/ShellUtility
 internal static void RaiseActiveWindowChanged() =>
 ActiveWindowChanged?.Invoke();