mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-29 17:02:05 +13:00
Screen region form won't steal focus when doing last region or active window recording
This commit is contained in:
parent
d3a7b0e7f9
commit
e898e73690
5 changed files with 32 additions and 7 deletions
|
@ -47,6 +47,7 @@ protected override void SetVisibleCore(bool value)
|
|||
value = false;
|
||||
CreateHandle();
|
||||
}
|
||||
|
||||
base.SetVisibleCore(value);
|
||||
}
|
||||
|
||||
|
@ -56,6 +57,7 @@ protected override void Dispose(bool disposing)
|
|||
{
|
||||
components.Dispose();
|
||||
}
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ private static void CreatePortable()
|
|||
|
||||
List<string> files = new List<string>();
|
||||
|
||||
string[] endsWith = new string[] { "ShareX.exe", "ShareX.exe.config", ".dll", ".css", ".txt" };
|
||||
string[] endsWith = new string[] { "ShareX.exe", "ShareX.exe.config", ".dll", ".css", ".txt", "Screen Capture Recorder setup.exe" };
|
||||
string[] ignoreEndsWith = new string[] { };
|
||||
|
||||
foreach (string filepath in Directory.GetFiles(releaseDir))
|
||||
|
|
|
@ -203,7 +203,7 @@ public void StartRecording(ScreenRecordOutput outputType, TaskSettings taskSetti
|
|||
|
||||
float duration = taskSettings.CaptureSettings.ScreenRecordFixedDuration ? taskSettings.CaptureSettings.ScreenRecordDuration : 0;
|
||||
|
||||
regionForm = ScreenRegionForm.Show(captureRectangle, StopRecording, duration);
|
||||
regionForm = ScreenRegionForm.Show(captureRectangle, StopRecording, startMethod == ScreenRecordStartMethod.Region, duration);
|
||||
regionForm.RecordResetEvent = new ManualResetEvent(false);
|
||||
|
||||
TaskEx.Run(() =>
|
||||
|
|
1
ShareX/Forms/ScreenRegionForm.Designer.cs
generated
1
ShareX/Forms/ScreenRegionForm.Designer.cs
generated
|
@ -83,7 +83,6 @@ private void InitializeComponent()
|
|||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
||||
this.Name = "ScreenRegionForm";
|
||||
this.ShowInTaskbar = false;
|
||||
this.TopMost = true;
|
||||
this.Shown += new System.EventHandler(this.ScreenRegionForm_Shown);
|
||||
this.pInfo.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
|
|
@ -47,11 +47,14 @@ public partial class ScreenRegionForm : Form
|
|||
private Color borderColor = Color.Red;
|
||||
private Rectangle borderRectangle;
|
||||
private Rectangle borderRectangle0Based;
|
||||
private bool activateWindow;
|
||||
|
||||
public ScreenRegionForm(Rectangle regionRectangle)
|
||||
public ScreenRegionForm(Rectangle regionRectangle, bool activateWindow = true)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.activateWindow = activateWindow;
|
||||
|
||||
borderRectangle = regionRectangle.Offset(1);
|
||||
borderRectangle0Based = new Rectangle(0, 0, borderRectangle.Width, borderRectangle.Height);
|
||||
|
||||
|
@ -76,9 +79,30 @@ public ScreenRegionForm(Rectangle regionRectangle)
|
|||
Timer = new Stopwatch();
|
||||
}
|
||||
|
||||
protected override bool ShowWithoutActivation
|
||||
{
|
||||
get
|
||||
{
|
||||
return !activateWindow;
|
||||
}
|
||||
}
|
||||
|
||||
protected override CreateParams CreateParams
|
||||
{
|
||||
get
|
||||
{
|
||||
CreateParams createParams = base.CreateParams;
|
||||
createParams.ExStyle |= (int)WindowStyles.WS_EX_TOPMOST;
|
||||
return createParams;
|
||||
}
|
||||
}
|
||||
|
||||
private void ScreenRegionForm_Shown(object sender, EventArgs e)
|
||||
{
|
||||
this.ShowActivate();
|
||||
if (activateWindow)
|
||||
{
|
||||
this.ShowActivate();
|
||||
}
|
||||
}
|
||||
|
||||
protected void OnStopRequested()
|
||||
|
@ -89,9 +113,9 @@ protected void OnStopRequested()
|
|||
}
|
||||
}
|
||||
|
||||
public static ScreenRegionForm Show(Rectangle captureRectangle, Action stopRequested, float duration = 0)
|
||||
public static ScreenRegionForm Show(Rectangle captureRectangle, Action stopRequested, bool activateWindow, float duration = 0)
|
||||
{
|
||||
ScreenRegionForm regionForm = new ScreenRegionForm(captureRectangle);
|
||||
ScreenRegionForm regionForm = new ScreenRegionForm(captureRectangle, activateWindow);
|
||||
|
||||
Thread thread = new Thread(() =>
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue