2017-02-28 21:34:08 +13:00
|
|
|
|
#region License Information (GPL v3)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
ShareX - A program that allows you to take screenshots and share any file type
|
2023-01-10 09:31:02 +13:00
|
|
|
|
Copyright (c) 2007-2023 ShareX Team
|
2017-02-28 21:34:08 +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)
|
|
|
|
|
|
|
|
|
|
using ShareX.HelpersLib;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
|
|
|
|
|
namespace ShareX
|
|
|
|
|
{
|
|
|
|
|
public class CaptureWindow : CaptureBase
|
|
|
|
|
{
|
|
|
|
|
public IntPtr WindowHandle { get; private set; }
|
|
|
|
|
|
|
|
|
|
public CaptureWindow(IntPtr windowHandle)
|
|
|
|
|
{
|
|
|
|
|
WindowHandle = windowHandle;
|
|
|
|
|
|
|
|
|
|
AllowAutoHideForm = WindowHandle != Program.MainForm.Handle;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-12 00:56:42 +13:00
|
|
|
|
protected override TaskMetadata Execute(TaskSettings taskSettings)
|
2017-02-28 21:34:08 +13:00
|
|
|
|
{
|
2018-12-20 00:19:38 +13:00
|
|
|
|
WindowInfo windowInfo = new WindowInfo(WindowHandle);
|
|
|
|
|
|
|
|
|
|
if (windowInfo.IsMinimized)
|
2017-02-28 21:34:08 +13:00
|
|
|
|
{
|
2018-12-20 00:19:38 +13:00
|
|
|
|
windowInfo.Restore();
|
2017-02-28 21:34:08 +13:00
|
|
|
|
}
|
|
|
|
|
|
2018-12-20 00:19:38 +13:00
|
|
|
|
windowInfo.Activate();
|
|
|
|
|
|
2017-02-28 21:34:08 +13:00
|
|
|
|
Thread.Sleep(250);
|
|
|
|
|
|
2021-12-12 00:56:42 +13:00
|
|
|
|
TaskMetadata metadata = new TaskMetadata();
|
|
|
|
|
metadata.UpdateInfo(windowInfo);
|
2017-02-28 21:34:08 +13:00
|
|
|
|
|
|
|
|
|
if (taskSettings.CaptureSettings.CaptureTransparent && !taskSettings.CaptureSettings.CaptureClientArea)
|
|
|
|
|
{
|
2021-12-12 00:56:42 +13:00
|
|
|
|
metadata.Image = TaskHelpers.GetScreenshot(taskSettings).CaptureWindowTransparent(WindowHandle);
|
2017-02-28 21:34:08 +13:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-12-12 00:56:42 +13:00
|
|
|
|
metadata.Image = TaskHelpers.GetScreenshot(taskSettings).CaptureWindow(WindowHandle);
|
2017-02-28 21:34:08 +13:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-12 00:56:42 +13:00
|
|
|
|
return metadata;
|
2017-02-28 21:34:08 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|