mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Added key press and mouse wheel simulate methods
This commit is contained in:
parent
448e9cc294
commit
d6243d0582
4 changed files with 74 additions and 27 deletions
|
@ -146,4 +146,11 @@ public enum RegionShape
|
|||
Triangle,
|
||||
Diamond
|
||||
}
|
||||
|
||||
public enum ScrollingCaptureScrollMethod
|
||||
{
|
||||
SendMessageScroll,
|
||||
KeyPressPageDown,
|
||||
MouseWheel
|
||||
}
|
||||
}
|
|
@ -34,6 +34,8 @@ private void InitializeComponent()
|
|||
this.tcScrollingCapture = new System.Windows.Forms.TabControl();
|
||||
this.tpCapture = new System.Windows.Forms.TabPage();
|
||||
this.tpOutput = new System.Windows.Forms.TabPage();
|
||||
this.btnResetCombine = new System.Windows.Forms.Button();
|
||||
this.btnGuessCombineAdjustments = new System.Windows.Forms.Button();
|
||||
this.btnProcess = new System.Windows.Forms.Button();
|
||||
this.btnGuessEdges = new System.Windows.Forms.Button();
|
||||
this.btnCombine = new System.Windows.Forms.Button();
|
||||
|
@ -53,8 +55,8 @@ private void InitializeComponent()
|
|||
this.nudTrimRight = new System.Windows.Forms.NumericUpDown();
|
||||
this.pOutput = new System.Windows.Forms.Panel();
|
||||
this.pbOutput = new System.Windows.Forms.PictureBox();
|
||||
this.btnGuessCombineAdjustments = new System.Windows.Forms.Button();
|
||||
this.btnResetCombine = new System.Windows.Forms.Button();
|
||||
this.cbScrollMethod = new System.Windows.Forms.ComboBox();
|
||||
this.lblScrollMethod = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudScrollDelay)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudMaximumScrollCount)).BeginInit();
|
||||
this.tcScrollingCapture.SuspendLayout();
|
||||
|
@ -93,7 +95,7 @@ private void InitializeComponent()
|
|||
// btnCapture
|
||||
//
|
||||
this.btnCapture.Enabled = false;
|
||||
this.btnCapture.Location = new System.Drawing.Point(12, 106);
|
||||
this.btnCapture.Location = new System.Drawing.Point(16, 128);
|
||||
this.btnCapture.Name = "btnCapture";
|
||||
this.btnCapture.Size = new System.Drawing.Size(152, 23);
|
||||
this.btnCapture.TabIndex = 2;
|
||||
|
@ -107,7 +109,7 @@ private void InitializeComponent()
|
|||
//
|
||||
// nudScrollDelay
|
||||
//
|
||||
this.nudScrollDelay.Location = new System.Drawing.Point(140, 46);
|
||||
this.nudScrollDelay.Location = new System.Drawing.Point(136, 68);
|
||||
this.nudScrollDelay.Maximum = new decimal(new int[] {
|
||||
5000,
|
||||
0,
|
||||
|
@ -121,7 +123,7 @@ private void InitializeComponent()
|
|||
//
|
||||
// nudMaximumScrollCount
|
||||
//
|
||||
this.nudMaximumScrollCount.Location = new System.Drawing.Point(140, 70);
|
||||
this.nudMaximumScrollCount.Location = new System.Drawing.Point(136, 92);
|
||||
this.nudMaximumScrollCount.Name = "nudMaximumScrollCount";
|
||||
this.nudMaximumScrollCount.Size = new System.Drawing.Size(80, 20);
|
||||
this.nudMaximumScrollCount.TabIndex = 4;
|
||||
|
@ -131,7 +133,7 @@ private void InitializeComponent()
|
|||
// lblScrollDelay
|
||||
//
|
||||
this.lblScrollDelay.AutoSize = true;
|
||||
this.lblScrollDelay.Location = new System.Drawing.Point(12, 50);
|
||||
this.lblScrollDelay.Location = new System.Drawing.Point(16, 72);
|
||||
this.lblScrollDelay.Name = "lblScrollDelay";
|
||||
this.lblScrollDelay.Size = new System.Drawing.Size(64, 13);
|
||||
this.lblScrollDelay.TabIndex = 5;
|
||||
|
@ -140,7 +142,7 @@ private void InitializeComponent()
|
|||
// lblMaximumScrollCount
|
||||
//
|
||||
this.lblMaximumScrollCount.AutoSize = true;
|
||||
this.lblMaximumScrollCount.Location = new System.Drawing.Point(12, 74);
|
||||
this.lblMaximumScrollCount.Location = new System.Drawing.Point(16, 96);
|
||||
this.lblMaximumScrollCount.Name = "lblMaximumScrollCount";
|
||||
this.lblMaximumScrollCount.Size = new System.Drawing.Size(111, 13);
|
||||
this.lblMaximumScrollCount.TabIndex = 6;
|
||||
|
@ -159,6 +161,8 @@ private void InitializeComponent()
|
|||
//
|
||||
// tpCapture
|
||||
//
|
||||
this.tpCapture.Controls.Add(this.lblScrollMethod);
|
||||
this.tpCapture.Controls.Add(this.cbScrollMethod);
|
||||
this.tpCapture.Controls.Add(this.btnSelectHandle);
|
||||
this.tpCapture.Controls.Add(this.lblMaximumScrollCount);
|
||||
this.tpCapture.Controls.Add(this.lblControlText);
|
||||
|
@ -192,6 +196,27 @@ private void InitializeComponent()
|
|||
this.tpOutput.Text = "Output";
|
||||
this.tpOutput.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// btnResetCombine
|
||||
//
|
||||
this.btnResetCombine.Location = new System.Drawing.Point(696, 16);
|
||||
this.btnResetCombine.Name = "btnResetCombine";
|
||||
this.btnResetCombine.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnResetCombine.TabIndex = 11;
|
||||
this.btnResetCombine.Text = "Reset";
|
||||
this.btnResetCombine.UseVisualStyleBackColor = true;
|
||||
this.btnResetCombine.Click += new System.EventHandler(this.btnResetCombine_Click);
|
||||
//
|
||||
// btnGuessCombineAdjustments
|
||||
//
|
||||
this.btnGuessCombineAdjustments.Enabled = false;
|
||||
this.btnGuessCombineAdjustments.Location = new System.Drawing.Point(312, 40);
|
||||
this.btnGuessCombineAdjustments.Name = "btnGuessCombineAdjustments";
|
||||
this.btnGuessCombineAdjustments.Size = new System.Drawing.Size(376, 23);
|
||||
this.btnGuessCombineAdjustments.TabIndex = 10;
|
||||
this.btnGuessCombineAdjustments.Text = "2. Guess combine adjustments";
|
||||
this.btnGuessCombineAdjustments.UseVisualStyleBackColor = true;
|
||||
this.btnGuessCombineAdjustments.Click += new System.EventHandler(this.btnGuessCombineAdjustments_Click);
|
||||
//
|
||||
// btnProcess
|
||||
//
|
||||
this.btnProcess.Location = new System.Drawing.Point(312, 88);
|
||||
|
@ -413,26 +438,23 @@ private void InitializeComponent()
|
|||
this.pbOutput.TabIndex = 0;
|
||||
this.pbOutput.TabStop = false;
|
||||
//
|
||||
// btnGuessCombineAdjustments
|
||||
// cbScrollMethod
|
||||
//
|
||||
this.btnGuessCombineAdjustments.Enabled = false;
|
||||
this.btnGuessCombineAdjustments.Location = new System.Drawing.Point(312, 40);
|
||||
this.btnGuessCombineAdjustments.Name = "btnGuessCombineAdjustments";
|
||||
this.btnGuessCombineAdjustments.Size = new System.Drawing.Size(376, 23);
|
||||
this.btnGuessCombineAdjustments.TabIndex = 10;
|
||||
this.btnGuessCombineAdjustments.Text = "2. Guess combine adjustments";
|
||||
this.btnGuessCombineAdjustments.UseVisualStyleBackColor = true;
|
||||
this.btnGuessCombineAdjustments.Click += new System.EventHandler(this.btnGuessCombineAdjustments_Click);
|
||||
this.cbScrollMethod.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cbScrollMethod.FormattingEnabled = true;
|
||||
this.cbScrollMethod.Location = new System.Drawing.Point(136, 44);
|
||||
this.cbScrollMethod.Name = "cbScrollMethod";
|
||||
this.cbScrollMethod.Size = new System.Drawing.Size(176, 21);
|
||||
this.cbScrollMethod.TabIndex = 7;
|
||||
//
|
||||
// btnResetCombine
|
||||
// lblScrollMethod
|
||||
//
|
||||
this.btnResetCombine.Location = new System.Drawing.Point(696, 16);
|
||||
this.btnResetCombine.Name = "btnResetCombine";
|
||||
this.btnResetCombine.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnResetCombine.TabIndex = 11;
|
||||
this.btnResetCombine.Text = "Reset";
|
||||
this.btnResetCombine.UseVisualStyleBackColor = true;
|
||||
this.btnResetCombine.Click += new System.EventHandler(this.btnResetCombine_Click);
|
||||
this.lblScrollMethod.AutoSize = true;
|
||||
this.lblScrollMethod.Location = new System.Drawing.Point(16, 48);
|
||||
this.lblScrollMethod.Name = "lblScrollMethod";
|
||||
this.lblScrollMethod.Size = new System.Drawing.Size(74, 13);
|
||||
this.lblScrollMethod.TabIndex = 8;
|
||||
this.lblScrollMethod.Text = "Scroll method:";
|
||||
//
|
||||
// ScrollingCaptureForm
|
||||
//
|
||||
|
@ -500,5 +522,7 @@ private void InitializeComponent()
|
|||
private Button btnProcess;
|
||||
private Button btnGuessCombineAdjustments;
|
||||
private Button btnResetCombine;
|
||||
private Label lblScrollMethod;
|
||||
private ComboBox cbScrollMethod;
|
||||
}
|
||||
}
|
|
@ -54,6 +54,8 @@ public ScrollingCaptureForm(ScrollingCaptureOptions options)
|
|||
{
|
||||
Options = options;
|
||||
InitializeComponent();
|
||||
cbScrollMethod.Items.AddRange(Enum.GetNames(typeof(ScrollingCaptureScrollMethod)));
|
||||
cbScrollMethod.SelectedIndex = (int)Options.ScrollMethod;
|
||||
nudScrollDelay.Value = Options.ScrollDelay;
|
||||
nudMaximumScrollCount.Value = Options.MaximumScrollCount;
|
||||
}
|
||||
|
@ -190,7 +192,19 @@ private void captureTimer_Tick(object sender, EventArgs e)
|
|||
StopCapture();
|
||||
}
|
||||
|
||||
NativeMethods.SendMessage(selectedWindow.Handle, (int)WindowsMessages.VSCROLL, (int)ScrollBarCommands.SB_PAGEDOWN, 0);
|
||||
switch (Options.ScrollMethod)
|
||||
{
|
||||
case ScrollingCaptureScrollMethod.SendMessageScroll:
|
||||
NativeMethods.SendMessage(selectedWindow.Handle, (int)WindowsMessages.VSCROLL, (int)ScrollBarCommands.SB_PAGEDOWN, 0);
|
||||
break;
|
||||
case ScrollingCaptureScrollMethod.KeyPressPageDown:
|
||||
InputHelpers.SendKeyPress(VirtualKeyCode.NEXT);
|
||||
//NativeMethods.SendMessage(selectedWindow.Handle, (int)WindowsMessages.KEYDOWN, (int)VirtualKeyCode.NEXT, 0);
|
||||
break;
|
||||
case ScrollingCaptureScrollMethod.MouseWheel:
|
||||
InputHelpers.SendMouseWheel(120);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void nudScrollDelay_ValueChanged(object sender, EventArgs e)
|
||||
|
@ -317,7 +331,7 @@ private Image CombineImages()
|
|||
|
||||
if (images.Count == 1)
|
||||
{
|
||||
return images[0];
|
||||
return (Image)images[0].Clone();
|
||||
}
|
||||
|
||||
List<Image> output = new List<Image>();
|
||||
|
|
|
@ -23,6 +23,7 @@ You should have received a copy of the GNU General Public License
|
|||
|
||||
#endregion License Information (GPL v3)
|
||||
|
||||
using ShareX.ScreenCaptureLib;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -32,7 +33,8 @@ namespace ShareX
|
|||
{
|
||||
public class ScrollingCaptureOptions
|
||||
{
|
||||
public int ScrollDelay { get; set; } = 1000;
|
||||
public ScrollingCaptureScrollMethod ScrollMethod { get; set; } = ScrollingCaptureScrollMethod.SendMessageScroll;
|
||||
public int ScrollDelay { get; set; } = 250;
|
||||
public int MaximumScrollCount { get; set; } = 20;
|
||||
public int TrimLeftEdge { get; set; } = 0;
|
||||
public int TrimTopEdge { get; set; } = 0;
|
||||
|
|
Loading…
Reference in a new issue