private static void SendKeyCommand() { User32Dll.ShowWindowAsync(hWnd, User32Dll.SW_SHOW); //SendKeys.SendWait("{ESC}"); //ClickOnPoint(hWnd, new Point(640, 360)); }
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; }
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)); } } } } }
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)); } } }
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); } }
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(); } } }
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); } } }
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(); } }
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)); } } } } }
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); } } }
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); }
internal void DestroyBand() { if (Created) { User32Dll.SendMessage(_bands.Rebar.RebarHwnd, (int)WindowsMessages.RB_DELETEBAND, (uint)BandIndex, 0U); _bands = null; _created = false; } }
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)); }
protected void DestroyFakeWnd() { if (m_FakeWndHandle != IntPtr.Zero) { User32Dll.DestroyWindow(m_FakeWndHandle); m_FakeWndHandle = IntPtr.Zero; User32Dll.UnregisterClass(m_WndClsName, Kernal32Dll.GetModuleHandle(null)); } }
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(); }
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)); }
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); }
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); }
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); } } }
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); }
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); }
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); } } }
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); } }
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; } }
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); }
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); }
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); } } } }