forked from yangzhongke/NetAutoGUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWindowExtensions.cs
More file actions
43 lines (38 loc) · 1.18 KB
/
Copy pathWindowExtensions.cs
File metadata and controls
43 lines (38 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using NetAutoGUI.Windows;
using System;
using System.Threading;
using Vanara.PInvoke;
namespace NetAutoGUI
{
public static class WindowExtensions
{
public static void Activate(this Window window)
{
ActiveWindow(window.Id);
}
public static void ActiveWindow(long windowId)
{
//https://stackoverflow.com/questions/2636721/bring-another-processes-window-to-foreground-when-it-has-showintaskbar-false
HWND hwnd = windowId.ToHWND();
if (User32.IsIconic(hwnd))
{
User32.ShowWindow(hwnd, ShowWindowCommand.SW_RESTORE);
}
User32.SetForegroundWindow(hwnd);
}
public static void Maximize(this Window window)
{
HWND hwnd = window.Id.ToHWND();
User32.ShowWindow(hwnd, ShowWindowCommand.SW_MAXIMIZE);
}
public static dynamic GetMainMenu(this Window window)
{
HWND hwnd = window.Id.ToHWND();
return new DynamicMainMenu(hwnd);
}
public static UIElement GetRoot(this Window window)
{
return new UIElement(window.Id);
}
}
}