mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 18:57:28 -07:00
BUG-2108: a change in ToForeground which should fix another issue, involved a key press, which "disables" the context menu in this use-case.
This commit is contained in:
parent
19802d54c8
commit
73bdd0f405
2 changed files with 17 additions and 10 deletions
|
@ -1250,11 +1250,13 @@ namespace GreenshotPlugin.Core {
|
|||
size = result ? new Size((int)windowInfo.cxWindowBorders, (int)windowInfo.cyWindowBorders) : Size.Empty;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Set the window as foreground window
|
||||
/// </summary>
|
||||
public static void ToForeground(IntPtr handle)
|
||||
/// <param name="handle">hWnd of the window to bring to the foreground</param>
|
||||
/// <param name="workaround">bool with true to use a trick to really bring the window to the foreground</param>
|
||||
public static void ToForeground(IntPtr handle, bool workaround = true)
|
||||
{
|
||||
// Do nothing if the window is already in the foreground
|
||||
if (User32.GetForegroundWindow() == handle)
|
||||
|
@ -1266,10 +1268,14 @@ namespace GreenshotPlugin.Core {
|
|||
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);
|
||||
// See https://msdn.microsoft.com/en-us/library/windows/desktop/ms633539(v=vs.85).aspx
|
||||
if (workaround)
|
||||
{
|
||||
// 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);
|
||||
|
@ -1278,8 +1284,9 @@ namespace GreenshotPlugin.Core {
|
|||
/// <summary>
|
||||
/// Set the window as foreground window
|
||||
/// </summary>
|
||||
public void ToForeground() {
|
||||
ToForeground(Handle);
|
||||
/// <param name="workaround">true to use a workaround, otherwise the window might only flash</param>
|
||||
public void ToForeground(bool workaround = true) {
|
||||
ToForeground(Handle, workaround);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue