mirror of
https://github.com/greenshot/greenshot
synced 2025-07-16 10:03:44 -07:00
FEATURE-992: Fixing a problem with the editor not becoming the foreground window. [skip ci]
This commit is contained in:
parent
4f289d838a
commit
eabe6a18be
3 changed files with 22 additions and 1 deletions
|
@ -176,6 +176,7 @@ namespace Greenshot {
|
||||||
Text = _surface.CaptureDetails.Title + " - " + Language.GetString(LangKey.editor_title);
|
Text = _surface.CaptureDetails.Title + " - " + Language.GetString(LangKey.editor_title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Activate();
|
||||||
WindowDetails.ToForeground(Handle);
|
WindowDetails.ToForeground(Handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1254,7 +1254,25 @@ namespace GreenshotPlugin.Core {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set the window as foreground window
|
/// Set the window as foreground window
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void ToForeground(IntPtr handle) {
|
public static void ToForeground(IntPtr handle)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Do nothing if the window is already in the foreground
|
||||||
|
if (User32.GetForegroundWindow() == handle)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const byte ALT = 0xA4;
|
||||||
|
const int EXTENDEDKEY = 0x1;
|
||||||
|
const int KEYUP = 0x2;
|
||||||
|
|
||||||
|
// Simulate an "ALT" key press.
|
||||||
|
User32.keybd_event(ALT, 0x45, EXTENDEDKEY | 0, 0);
|
||||||
|
// Simulate an "ALT" key release.
|
||||||
|
User32.keybd_event(ALT, 0x45, EXTENDEDKEY | KEYUP, 0);
|
||||||
|
|
||||||
|
// Show window in forground.
|
||||||
User32.SetForegroundWindow(handle);
|
User32.SetForegroundWindow(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,8 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
||||||
|
|
||||||
#region DllImports
|
#region DllImports
|
||||||
[DllImport("user32", SetLastError = true)]
|
[DllImport("user32", SetLastError = true)]
|
||||||
|
public static extern bool keybd_event(byte bVk, byte bScan, uint dwFlags, int dwExtraInfo);
|
||||||
|
[DllImport("user32", SetLastError = true)]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
public static extern bool IsWindowVisible(IntPtr hWnd);
|
public static extern bool IsWindowVisible(IntPtr hWnd);
|
||||||
[DllImport("user32", SetLastError = true)]
|
[DllImport("user32", SetLastError = true)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue