예제 #1
0
        private static void SendKeyCommand()
        {
            User32Dll.ShowWindowAsync(hWnd, User32Dll.SW_SHOW);
            //SendKeys.SendWait("{ESC}");

            //ClickOnPoint(hWnd, new Point(640, 360));
        }
예제 #2
0
        private static void ClickOnPoint(IntPtr wndHandle, Point clientPoint, KeyCommandType command)
        {
            uint buttonDown, buttonUp = 0;

            if (command == KeyCommandType.LeftClick)
            {
                buttonDown = User32Dll.MOUSEEVENTF_LEFTDOWN;
                buttonUp   = User32Dll.MOUSEEVENTF_LEFTUP;
            }
            else if (command == KeyCommandType.RightClick)
            {
                buttonDown = User32Dll.MOUSEEVENTF_RIGHTDOWN;
                buttonUp   = User32Dll.MOUSEEVENTF_RIGHTUP;
            }
            else
            {
                return;
            }

            var oldPos = Cursor.Position;

            /// get screen coordinates
            User32Dll.ClientToScreen(wndHandle, ref clientPoint);

            /// set cursor on coords, and press mouse
            Cursor.Position = new Point(clientPoint.X, clientPoint.Y);
            User32Dll.mouse_event(buttonDown, 0, 0, 0, UIntPtr.Zero);
            User32Dll.mouse_event(buttonUp, 0, 0, 0, UIntPtr.Zero);

            /// return mouse
            Cursor.Position = oldPos;
        }
예제 #3
0
 protected void UpdateImageList()
 {
     if (_rebar != null)
     {
         REBARINFO RBInfo = new REBARINFO();
         RBInfo.cbSize = (uint)Marshal.SizeOf(RBInfo);
         RBInfo.fMask  = (uint)RebarImageListConstants.RBIM_IMAGELIST;
         if (_imageList == null)
         {
             RBInfo.himl = IntPtr.Zero;
         }
         else
         {
             RBInfo.himl = _imageList.Handle;
         }
         if (User32Dll.SendMessage(_rebar.Handle,
                                   (int)WindowsMessages.RB_SETBARINFO,
                                   0, ref RBInfo) == 0)
         {
             int LastErr = Marshal.GetHRForLastWin32Error();
             try
             {
                 Marshal.ThrowExceptionForHR(LastErr);
             }
             catch (Exception ex)
             {
                 System.Diagnostics.Debug.WriteLine(LastErr + " " + ex.Message);
                 if (_throwExceptions)
                 {
                     throw(new Exception("Error Setting Imagelist.", ex));
                 }
             }
         }
     }
 }
예제 #4
0
 private static void ActivateWindow()
 {
     if (SystemInfoRiderPlugin.OperatingSystemFamily == OperatingSystemFamily.Windows)
     {
         try
         {
             var process = GetRiderProcess();
             if (process != null)
             {
                 // Collect top level windows
                 var topLevelWindows = User32Dll.GetTopLevelWindowHandles();
                 // Get process main window title
                 var windowHandle = topLevelWindows.FirstOrDefault(hwnd => User32Dll.GetWindowProcessId(hwnd) == process.Id);
                 Debug.Log("[Rider] ActivateWindow: " + process.Id + " " + windowHandle);
                 if (windowHandle != IntPtr.Zero)
                 {
                     //User32Dll.ShowWindow(windowHandle, 9); //SW_RESTORE = 9
                     User32Dll.SetForegroundWindow(windowHandle);
                 }
             }
         }
         catch (Exception e)
         {
             Debug.Log("[Rider] " + ("Exception on ActivateWindow: " + e));
         }
     }
 }
예제 #5
0
        private void ActivateWindow(int?processId = null)
        {
            if (myPluginSettings.OperatingSystemFamilyRider != OperatingSystemFamilyRider.Windows)
            {
                return;
            }

            try
            {
                var process = processId == null?GetRiderProcess() : Process.GetProcessById((int)processId);

                if (process == null)
                {
                    return;
                }

                // Collect top level windows
                var topLevelWindows = User32Dll.GetTopLevelWindowHandles();
                // Get process main window title
                var windowHandle = topLevelWindows.FirstOrDefault(hwnd => User32Dll.GetWindowProcessId(hwnd) == process.Id);
                myLogger.Verbose("ActivateWindow: {0} {1}", process.Id, windowHandle);
                if (windowHandle != IntPtr.Zero)
                {
                    //User32Dll.ShowWindow(windowHandle, 9); //SW_RESTORE = 9
                    User32Dll.SetForegroundWindow(windowHandle);
                }
            }
            catch (Exception e)
            {
                myLogger.Warn("Exception on ActivateWindow: " + e);
            }
        }
예제 #6
0
 protected void UpdateStyle()
 {
     if (_rebar != null)
     {
         if (User32Dll.SetWindowLongPtr(_rebar.Handle, (int)WindowLongConstants.GWL_STYLE, (IntPtr)Style).ToInt32() == 0)
         {
             int LastErr = Marshal.GetHRForLastWin32Error();
             try
             {
                 Marshal.ThrowExceptionForHR(LastErr);
             }
             catch (Exception ex)
             {
                 System.Diagnostics.Debug.WriteLine(LastErr + " " + ex.Message);
                 if (_throwExceptions)
                 {
                     throw(new Exception("Error Updating Styles.", ex));
                 }
             }
         }
         else
         {
             this.Invalidate();
             this.Refresh();
         }
     }
 }
예제 #7
0
 private static void ActivateWindow()
 {
     if (SystemInfoRiderPlugin.operatingSystemFamily == OperatingSystemFamily.Windows)
     {
         try
         {
             var process = GetRiderProcess();
             if (process != null)
             {
                 // Collect top level windows
                 var topLevelWindows = User32Dll.GetTopLevelWindowHandles();
                 // Get process main window title
                 var windowHandle = topLevelWindows.FirstOrDefault(hwnd => User32Dll.GetWindowProcessId(hwnd) == process.Id);
                 Log(LoggingLevel.Info, string.Format("ActivateWindow: {0} {1}", process.Id, windowHandle));
                 if (windowHandle != IntPtr.Zero)
                 {
                     //User32Dll.ShowWindow(windowHandle, 9); //SW_RESTORE = 9
                     User32Dll.SetForegroundWindow(windowHandle);
                 }
             }
         }
         catch (Exception e)
         {
             Log(LoggingLevel.Warning, "Exception on ActivateWindow: " + e);
         }
     }
 }
예제 #8
0
        protected void UpdateChild()
        {
            if (Created)
            {
                REBARBANDINFO rbBand = new REBARBANDINFO();
                rbBand.cbSize = (uint)Marshal.SizeOf(rbBand);
                rbBand.fMask  = (uint)RebarBandInfoConstants.RBBIM_CHILD;
                if (_child == null)
                {
                    rbBand.hwndChild = IntPtr.Zero;
                }
                else
                {
                    rbBand.hwndChild = _child.Handle;
                }

                if (User32Dll.SendMessage(_bands.Rebar.RebarHwnd, (int)WindowsMessages.RB_SETBANDINFOA, BandIndex, ref rbBand) == 0)
                {
                    int LastErr = Marshal.GetHRForLastWin32Error();
                    try
                    {
                        Marshal.ThrowExceptionForHR(LastErr);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(LastErr + " " + ex.Message);
                        if (_throwExceptions)
                        {
                            throw(new Exception("Error Updating Child.", ex));
                        }
                    }
                }
                UpdateMinimums();
            }
        }
예제 #9
0
        protected void UpdateStyles()
        {
            if (Created)
            {
                REBARBANDINFO rbBand = new REBARBANDINFO();
                rbBand.cbSize = (uint)Marshal.SizeOf(rbBand);
                rbBand.fMask  = (uint)RebarBandInfoConstants.RBBIM_STYLE;
                rbBand.fStyle = (uint)Style;

                if (User32Dll.SendMessage(_bands.Rebar.RebarHwnd, (int)WindowsMessages.RB_SETBANDINFOA, BandIndex, ref rbBand) == 0)
                {
                    int LastErr = Marshal.GetHRForLastWin32Error();
                    try
                    {
                        Marshal.ThrowExceptionForHR(LastErr);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(LastErr + " " + ex.Message);
                        if (_throwExceptions)
                        {
                            throw(new Exception("Error Updating Styles.", ex));
                        }
                    }
                }
            }
        }
예제 #10
0
 public void Minimize()
 {
     if (Created)
     {
         User32Dll.SendMessage(_bands.Rebar.RebarHwnd, (int)WindowsMessages.RB_MINIMIZEBAND, (uint)BandIndex, (uint)_idealWidth);
     }
 }
        // This is required to be called to help frontend Focus itself
        private void AllowSetForegroundWindow(int?processId = null)
        {
            if (myPluginSettings.OperatingSystemFamilyRider != OperatingSystemFamilyRider.Windows)
            {
                return;
            }

            try
            {
                var process = processId == null?GetRiderProcess() : Process.GetProcessById((int)processId);

                if (process == null)
                {
                    return;
                }

                if (process.Id > 0)
                {
                    User32Dll.AllowSetForegroundWindow(process.Id);
                }
            }
            catch (Exception e)
            {
                myLogger.Warn("Exception on AllowSetForegroundWindow: " + e);
            }
        }
        /// <summary>
        /// Performs the QuickFix, inserts the configured modifier into the location specified by the violation.
        /// </summary>
        /// <param name="solution">
        /// Current Solution.
        /// </param>
        /// <param name="textControl">
        /// Current Text Control to modify.
        /// </param>
        public void Execute(ISolution solution, ITextControl textControl)
        {
            JetBrains.DataFlow.LifetimeDefinition definition = JetBrains.DataFlow.Lifetimes.Define(solution.GetLifetime());
            JetBrains.DataFlow.Lifetime           lifetime   = definition.Lifetime;
            try
            {
                unsafe
                {
                    ChangeInspectionSeverityDialog dialog = new ChangeInspectionSeverityDialog(lifetime, this.commonIconsComponent);
                    IContextBoundSettingsStore     contextBoundSettingsStore =
                        this.settingsStore.BindToContextTransient(ContextRange.Smart(textControl.Document.ToDataContext()));
                    ConfigurableSeverityItem item = this.highlightingSettingsManager.GetSeverityItem(this.HighlightID);

                    dialog.Severity             = this.highlightingSettingsManager.GetConfigurableSeverity(this.HighlightID, solution);
                    dialog.SeverityOptionsTitle = string.Format(item.FullTitle + ":");
                    dialog.CanBeError           = !item.SolutionAnalysisRequired;

                    if (dialog.ShowDialog(User32Dll.GetForegroundWindow()) == true)
                    {
                        IContextBoundSettingsStore store = contextBoundSettingsStore;
                        if (dialog.SelectedSettingsLayer != null)
                        {
                            store = dialog.SelectedSettingsLayer.Model.SettingsStoreContext;
                        }

                        store.SetIndexedValue(HighlightingSettingsAccessor.InspectionSeverities, this.HighlightID, dialog.Severity);
                    }
                }
            }
            finally
            {
                definition.Terminate();
            }
        }
        private static void ActivateWindow()
        {
            var process = Process.GetProcesses().FirstOrDefault(p =>
            {
                string processName;
                try
                {
                    processName = p.ProcessName; // some processes like kaspersky antivirus throw exception on attempt to get ProcessName
                }
                catch (Exception)
                {
                    return(false);
                }

                return(!p.HasExited && processName.Contains("Rider"));
            });

            if (process != null)
            {
                // Collect top level windows
                var topLevelWindows = User32Dll.GetTopLevelWindowHandles();
                // Get process main window title
                var windowHandle = topLevelWindows.FirstOrDefault(hwnd => User32Dll.GetWindowProcessId(hwnd) == process.Id);
                if (windowHandle != IntPtr.Zero)
                {
                    User32Dll.SetForegroundWindow(windowHandle);
                }
            }
        }
예제 #14
0
        IntPtr CtrlWndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam)
        {
            if (!m_WndProcMap.ContainsKey(hWnd))
            {
                return(m_DefWndProcDelegate(hWnd, msg, wParam, lParam));
            }

            IntPtr nRet = User32Dll.CallWindowProc(m_WndProcMap[hWnd], hWnd, msg, wParam, lParam);

            switch (msg)
            {
            case WindowsMessage.WM_PAINT:
            case WindowsMessage.WM_CTLCOLOREDIT:
            case WindowsMessage.WM_CTLCOLORBTN:
            case WindowsMessage.WM_CTLCOLORSTATIC:
            case WindowsMessage.WM_CTLCOLORMSGBOX:
            case WindowsMessage.WM_CTLCOLORDLG:
            case WindowsMessage.WM_CTLCOLORLISTBOX:
            case WindowsMessage.WM_CTLCOLORSCROLLBAR:
            case WindowsMessage.WM_CAPTURECHANGED:
                RefreshFakeWnd();
                break;

            default:
                break;
            }

            return(nRet);
        }
예제 #15
0
 internal void DestroyBand()
 {
     if (Created)
     {
         User32Dll.SendMessage(_bands.Rebar.RebarHwnd, (int)WindowsMessages.RB_DELETEBAND, (uint)BandIndex, 0U);
         _bands   = null;
         _created = false;
     }
 }
예제 #16
0
        public Rectangle GetWindowRectangle(IntPtr hwnd)
        {
            RECT rect = new RECT();

            if (!User32Dll.GetWindowRect(hwnd, rect))
            {
                throw new Exception("Task Bar couldn't be found");
            }
            return(RectWinToRectangle(rect));
        }
예제 #17
0
        protected void DestroyFakeWnd()
        {
            if (m_FakeWndHandle != IntPtr.Zero)
            {
                User32Dll.DestroyWindow(m_FakeWndHandle);
                m_FakeWndHandle = IntPtr.Zero;

                User32Dll.UnregisterClass(m_WndClsName, Kernal32Dll.GetModuleHandle(null));
            }
        }
예제 #18
0
        void OnDlgMove(object sender, EventArgs e)
        {
            if (!User32Dll.IsWindow(m_FakeWndHandle))
            {
                return;
            }

            User32Dll.MoveWindow(m_FakeWndHandle, this.Left, this.Top, this.Width, this.Height, false);
            RefreshFakeWnd();
        }
예제 #19
0
 private void UpdateReBarPosition(IntPtr reBarHwnd, Rectangle rectReBar)
 {
     User32Dll.SetWindowPos(reBarHwnd,
                            (IntPtr)WindowZOrderConstants.HWND_TOP,
                            rectReBar.X,
                            rectReBar.Y,
                            rectReBar.Width,
                            rectReBar.Height,
                            (uint)(SetWindowPosConstants.SWP_NOSENDCHANGING));
 }
예제 #20
0
        public Rectangle ClientToScreen(IntPtr hWnd, Rectangle clientRect)
        {
            Point pt = new Point(clientRect.X, clientRect.Y);

            if (User32Dll.ClientToScreen(hWnd, ref pt))
            {
                clientRect.X = pt.X;
                clientRect.Y = pt.Y;
            }
            return(clientRect);
        }
예제 #21
0
        public Rectangle ScreenToClient(IntPtr hWnd, Rectangle screenRect)
        {
            Point pt = new Point(screenRect.X, screenRect.Y);

            if (User32Dll.ScreenToClient(hWnd, ref pt))
            {
                screenRect.X = pt.X;
                screenRect.Y = pt.Y;
            }
            return(screenRect);
        }
예제 #22
0
 private void _listQueries_Layout(object sender, System.Windows.Forms.LayoutEventArgs e)
 {
     _columnHeader.Width = _listQueries.Width - 6;
     if (_listQueries.Items.Count > 0)
     {
         int itemHeight = _listQueries.Items [0].Bounds.Height;
         if (itemHeight * _listQueries.Items.Count > _listQueries.ClientSize.Height)
         {
             _columnHeader.Width -= User32Dll.GetSystemMetrics((int)SystemMetricsCodes.SM_CXVSCROLL);
         }
     }
 }
예제 #23
0
        public TaskbarHost(Control control)
        {
            _control = control;

            var helper = ServiceLocator.GetTaskbarHelper();

            _desiredOffset = (int)(helper.TaskBarPosition.IsVertical() ? _control.Height : _control.Width);

            WM_APPDIRECT_NATIVE_UPDATE_OFFSET    = User32Dll.RegisterWindowMessage(MessageNameNativeUpdateOffset);
            WM_APPDIRECT_MANAGED_REBAR_UPDATED   = User32Dll.RegisterWindowMessage(MessageNameManagedReBarUpdated);
            WM_APPDIRECT_MANAGED_TASKBAR_UPDATED = User32Dll.RegisterWindowMessage(MessageNameManagedTaskBarUpdated);
            WM_APPDIRECT_MANAGED_SHUTDOWN        = User32Dll.RegisterWindowMessage(MessageNameManagedCloseApplication);
        }
예제 #24
0
파일: SplashScreen.cs 프로젝트: mo5h/omeo
 protected override unsafe void WndProc(ref Message m)
 {
     switch ((WindowsMessages)m.Msg)
     {
     case WindowsMessages.WM_ERASEBKGND:
         var  hdc      = (void *)m.WParam;
         RECT rcClient = ClientRectangle;
         User32Dll.FillRect(hdc, &rcClient, Gdi32Dll.GetStockObject((int)StockLogicalObjects.WHITE_BRUSH));
         m.Result = (IntPtr)1;                 // Did it
         return;
     }
     base.WndProc(ref m);
 }
예제 #25
0
        private static void ActivateWindow()
        {
            var process = Process.GetProcesses().FirstOrDefault(b => !b.HasExited && b.ProcessName.Contains("Rider"));

            if (process != null)
            {
                // Collect top level windows
                var topLevelWindows = User32Dll.GetTopLevelWindowHandles();
                // Get process main window title
                var windowHandle = topLevelWindows.FirstOrDefault(hwnd => User32Dll.GetWindowProcessId(hwnd) == process.Id);
                if (windowHandle != IntPtr.Zero)
                {
                    User32Dll.SetForegroundWindow(windowHandle);
                }
            }
        }
예제 #26
0
        protected void UpdateColors()
        {
            if (Created && _rebar != null)
            {
                COLORSCHEME CSInfo = new COLORSCHEME();
                CSInfo.dwSize          = (uint)Marshal.SizeOf(CSInfo);
                CSInfo.clrBtnHighlight = new COLORREF(_embossHighlight);
                CSInfo.clrBtnShadow    = new COLORREF(_embossShadow);
                User32Dll.SendMessage(_rebar.Handle, (int)WindowsMessages.RB_SETCOLORSCHEME, 0, ref CSInfo);

                COLORREF color = new COLORREF(this.ForeColor);
                User32Dll.SendMessage(_rebar.Handle, (int)WindowsMessages.RB_SETTEXTCOLOR, 0, color);
                color = new COLORREF(this.BackColor);
                User32Dll.SendMessage(_rebar.Handle, (int)WindowsMessages.RB_SETBKCOLOR, 0, color);
            }
        }
예제 #27
0
        public void ProcessKeyCommand(KeyCommandType command, string customCommand = "")
        {
            User32Dll.ShowWindowAsync(hWnd, User32Dll.SW_SHOW);
            switch (command)
            {
            case KeyCommandType.Escape:
                SendKeys.SendWait("{ESC}");
                break;

            case KeyCommandType.Key_W:
                SendKeys.SendWait("wwwwwwwwww");
                break;

            case KeyCommandType.Key_A:
                SendKeys.SendWait("aaaaaaaaaa");
                break;

            case KeyCommandType.Key_S:
                SendKeys.SendWait("ssssssssss");
                break;

            case KeyCommandType.Key_D:
                SendKeys.SendWait("dddddddddd");
                break;

            case KeyCommandType.LeftClick:
                break;

            case KeyCommandType.RightClick:
                break;

            case KeyCommandType.LookUp:
                break;

            case KeyCommandType.LookDown:
                break;

            case KeyCommandType.LookLeft:
                break;

            case KeyCommandType.LookRight:
                break;

            case KeyCommandType.Custom:
                break;
            }
        }
예제 #28
0
        private void UpdateIconPosition(Rectangle rectIcon, Rectangle rectScreen)
        {
            var flagsIcon = (uint)(0
                                   | SetWindowPosConstants.SWP_SHOWWINDOW
                                   | SetWindowPosConstants.SWP_NOOWNERZORDER
                                   | SetWindowPosConstants.SWP_NOACTIVATE);

            User32Dll.SetWindowPos(_hwndSource.Handle,
                                   (IntPtr)WindowZOrderConstants.HWND_TOP,
                                   rectIcon.X,
                                   rectIcon.Y,
                                   rectIcon.Width,
                                   rectIcon.Height,
                                   flagsIcon);

            _taskBarControl.SetAllowedSize(rectIcon.Width, rectIcon.Height);
        }
예제 #29
0
        private static int GetIdleSeconds()
        {
            int idleTime      = 0;
            var lastInputInfo = new LASTINPUTINFO();

            lastInputInfo.cbSize = (uint)Marshal.SizeOf(lastInputInfo);
            lastInputInfo.dwTime = 0;

            var envTicks = Environment.TickCount;

            if (User32Dll.GetLastInputInfo(ref lastInputInfo))
            {
                uint lastInputTick = lastInputInfo.dwTime;
                idleTime = envTicks - (int)lastInputTick;
            }

            return((idleTime > 0) ? (idleTime / 1000) : 0);
        }
예제 #30
0
        private static void ExpandMinimizedUnityWindow()
        {
            if (PluginSettings.SystemInfoRiderPlugin.operatingSystemFamily == OperatingSystemFamilyRider.Windows)
            {
                var topLevelWindows = User32Dll.GetTopLevelWindowHandles();
                var windowHandles   = topLevelWindows
                                      .Where(hwnd => User32Dll.GetWindowProcessId(hwnd) == Process.GetCurrentProcess().Id).ToArray();

                foreach (var windowHandle in windowHandles)
                {
                    if (User32Dll.IsIconic(windowHandle))
                    {
                        User32Dll.ShowWindow(windowHandle, 9);
                        User32Dll.SetForegroundWindow(windowHandle);
                    }
                }
            }
        }