2013-11-03 23:53:49 +13:00
|
|
|
|
#region License Information (GPL v3)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
ShareX - A program that allows you to take screenshots and share any file type
|
2017-01-11 21:39:40 +13:00
|
|
|
|
Copyright (c) 2007-2017 ShareX Team
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
|
|
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#endregion License Information (GPL v3)
|
|
|
|
|
|
2014-12-11 09:25:20 +13:00
|
|
|
|
using ShareX.HelpersLib;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
using System;
|
2014-03-25 14:26:08 +13:00
|
|
|
|
using System.Diagnostics;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
using System.Drawing;
|
|
|
|
|
|
2014-12-11 09:25:20 +13:00
|
|
|
|
namespace ShareX.ScreenCaptureLib
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
public class WindowInfo
|
|
|
|
|
{
|
2016-07-04 18:11:35 +12:00
|
|
|
|
public IntPtr Handle { get; }
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2016-07-04 18:11:35 +12:00
|
|
|
|
public string Text => NativeMethods.GetWindowText(Handle);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2016-07-04 18:11:35 +12:00
|
|
|
|
public string ClassName => NativeMethods.GetClassName(Handle);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2016-07-04 18:11:35 +12:00
|
|
|
|
public Process Process => NativeMethods.GetProcessByWindowHandle(Handle);
|
2014-03-25 14:26:08 +13:00
|
|
|
|
|
2017-03-01 22:44:39 +13:00
|
|
|
|
public string ProcessName
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
using (Process process = Process)
|
|
|
|
|
{
|
|
|
|
|
return process?.ProcessName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-12-18 01:00:20 +13:00
|
|
|
|
|
2016-07-04 18:11:35 +12:00
|
|
|
|
public Rectangle Rectangle => CaptureHelpers.GetWindowRectangle(Handle);
|
2015-12-18 01:00:20 +13:00
|
|
|
|
|
2016-07-04 18:11:35 +12:00
|
|
|
|
public Rectangle ClientRectangle => NativeMethods.GetClientRect(Handle);
|
2014-09-13 18:50:17 +12:00
|
|
|
|
|
2016-10-01 07:21:48 +13:00
|
|
|
|
public WindowStyles Styles => (WindowStyles)NativeMethods.GetWindowLong(Handle, NativeConstants.GWL_STYLE);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2016-07-04 18:11:35 +12:00
|
|
|
|
public Icon Icon => NativeMethods.GetApplicationIcon(Handle);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2016-07-04 18:11:35 +12:00
|
|
|
|
public bool IsMaximized => NativeMethods.IsZoomed(Handle);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2016-07-04 18:11:35 +12:00
|
|
|
|
public bool IsMinimized => NativeMethods.IsIconic(Handle);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2016-10-16 09:41:25 +13:00
|
|
|
|
public bool IsVisible => NativeMethods.IsWindowVisible(Handle) && !IsCloaked;
|
|
|
|
|
|
|
|
|
|
public bool IsCloaked => NativeMethods.IsWindowCloaked(Handle);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2016-07-04 18:11:35 +12:00
|
|
|
|
public bool IsActive => NativeMethods.GetForegroundWindow() == Handle;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
|
|
|
|
public WindowInfo(IntPtr handle)
|
|
|
|
|
{
|
|
|
|
|
Handle = handle;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-25 20:12:03 +12:00
|
|
|
|
public void Activate()
|
|
|
|
|
{
|
|
|
|
|
NativeMethods.ActivateWindow(Handle);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return Text;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|