diff --git a/README.md b/README.md index 8c72ffb..9803f79 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,26 @@ -# Clipboard-Cycler -When you paste, it copies the next item in the list. +
+ +# Clipboard Cycler + +[![GitHub license](https://img.shields.io/badge/license-AGPL%203.0-green)](./LICENSE) + + + +
+ +## :inbox_tray: Download + +You can find the lasted compiled executable the [releases](https://github.com/mov-ebx/Clipboard-Cycler/releases/latest). + +Keep in mind, this program only works in Windows. + +## :thinking: What is this program? + +The basic explanation, is its a text clipboard program, but whenever you paste with Ctrl+V, it copies the next item in the list. + +So lets say I have a list with each letter of the alphabet, whenever I press Ctrl+V or hold it, it pastes the next letter. + +### :video_camera: Demonstration + +
+ diff --git a/src/Clipboard Cycler.sln b/src/Clipboard Cycler.sln new file mode 100644 index 0000000..038a364 --- /dev/null +++ b/src/Clipboard Cycler.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31424.327 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Clipboard Cycler", "Clipboard Cycler\Clipboard Cycler.csproj", "{D6689038-7864-4D61-AEC1-019ED0232E80}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D6689038-7864-4D61-AEC1-019ED0232E80}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D6689038-7864-4D61-AEC1-019ED0232E80}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D6689038-7864-4D61-AEC1-019ED0232E80}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D6689038-7864-4D61-AEC1-019ED0232E80}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8C81DAE1-3106-4515-83C5-1CF08F1B1B9C} + EndGlobalSection +EndGlobal diff --git a/src/Clipboard Cycler/App.config b/src/Clipboard Cycler/App.config new file mode 100644 index 0000000..5754728 --- /dev/null +++ b/src/Clipboard Cycler/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/Clipboard Cycler/Clipboard Cycler.csproj b/src/Clipboard Cycler/Clipboard Cycler.csproj new file mode 100644 index 0000000..ace0984 --- /dev/null +++ b/src/Clipboard Cycler/Clipboard Cycler.csproj @@ -0,0 +1,83 @@ + + + + + Debug + AnyCPU + {D6689038-7864-4D61-AEC1-019ED0232E80} + WinExe + Clipboard_Cycler + Clipboard Cycler + v4.7.2 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + Form + + + UI.cs + + + + + UI.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + \ No newline at end of file diff --git a/src/Clipboard Cycler/Program.cs b/src/Clipboard Cycler/Program.cs new file mode 100644 index 0000000..d7b4a59 --- /dev/null +++ b/src/Clipboard Cycler/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Clipboard_Cycler +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new UI()); + } + } +} diff --git a/src/Clipboard Cycler/Properties/AssemblyInfo.cs b/src/Clipboard Cycler/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d31855c --- /dev/null +++ b/src/Clipboard Cycler/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Clipboard Cycler")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Clipboard Cycler")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("d6689038-7864-4d61-aec1-019ed0232e80")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Clipboard Cycler/Properties/Resources.Designer.cs b/src/Clipboard Cycler/Properties/Resources.Designer.cs new file mode 100644 index 0000000..813d756 --- /dev/null +++ b/src/Clipboard Cycler/Properties/Resources.Designer.cs @@ -0,0 +1,70 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +namespace Clipboard_Cycler.Properties +{ + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Clipboard_Cycler.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/src/Clipboard Cycler/Properties/Resources.resx b/src/Clipboard Cycler/Properties/Resources.resx new file mode 100644 index 0000000..ffecec8 --- /dev/null +++ b/src/Clipboard Cycler/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/src/Clipboard Cycler/Properties/Settings.Designer.cs b/src/Clipboard Cycler/Properties/Settings.Designer.cs new file mode 100644 index 0000000..11a863d --- /dev/null +++ b/src/Clipboard Cycler/Properties/Settings.Designer.cs @@ -0,0 +1,29 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +namespace Clipboard_Cycler.Properties +{ + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/src/Clipboard Cycler/Properties/Settings.settings b/src/Clipboard Cycler/Properties/Settings.settings new file mode 100644 index 0000000..abf36c5 --- /dev/null +++ b/src/Clipboard Cycler/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/Clipboard Cycler/UI.Designer.cs b/src/Clipboard Cycler/UI.Designer.cs new file mode 100644 index 0000000..28d7ffd --- /dev/null +++ b/src/Clipboard Cycler/UI.Designer.cs @@ -0,0 +1,283 @@ + +namespace Clipboard_Cycler +{ + partial class UI + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.Fill = new System.Windows.Forms.Panel(); + this.ListHolder = new System.Windows.Forms.Panel(); + ClipboardList = new System.Windows.Forms.ListBox(); + this.Bottom = new System.Windows.Forms.Panel(); + ToggleStatus = new System.Windows.Forms.CheckBox(); + this.ListControls = new System.Windows.Forms.SplitContainer(); + this.Clear = new System.Windows.Forms.Button(); + this.Remove = new System.Windows.Forms.Button(); + this.Top = new System.Windows.Forms.Panel(); + this.ListSet = new System.Windows.Forms.SplitContainer(); + this.TextBox = new System.Windows.Forms.TextBox(); + this.Add = new System.Windows.Forms.Button(); + this.Fill.SuspendLayout(); + this.ListHolder.SuspendLayout(); + this.Bottom.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.ListControls)).BeginInit(); + this.ListControls.Panel1.SuspendLayout(); + this.ListControls.Panel2.SuspendLayout(); + this.ListControls.SuspendLayout(); + this.Top.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.ListSet)).BeginInit(); + this.ListSet.Panel1.SuspendLayout(); + this.ListSet.Panel2.SuspendLayout(); + this.ListSet.SuspendLayout(); + this.SuspendLayout(); + // + // Fill + // + this.Fill.BackColor = System.Drawing.Color.Transparent; + this.Fill.Controls.Add(this.ListHolder); + this.Fill.Controls.Add(this.Bottom); + this.Fill.Dock = System.Windows.Forms.DockStyle.Fill; + this.Fill.Location = new System.Drawing.Point(0, 32); + this.Fill.Name = "Fill"; + this.Fill.Padding = new System.Windows.Forms.Padding(0, 2, 0, 0); + this.Fill.Size = new System.Drawing.Size(234, 229); + this.Fill.TabIndex = 3; + // + // ListHolder + // + this.ListHolder.Controls.Add(ClipboardList); + this.ListHolder.Dock = System.Windows.Forms.DockStyle.Fill; + this.ListHolder.Location = new System.Drawing.Point(0, 2); + this.ListHolder.Margin = new System.Windows.Forms.Padding(3, 6, 3, 0); + this.ListHolder.Name = "ListHolder"; + this.ListHolder.Padding = new System.Windows.Forms.Padding(5, 0, 5, 3); + this.ListHolder.Size = new System.Drawing.Size(234, 172); + this.ListHolder.TabIndex = 7; + // + // ClipboardList + // + ClipboardList.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20))))); + ClipboardList.BorderStyle = System.Windows.Forms.BorderStyle.None; + ClipboardList.Dock = System.Windows.Forms.DockStyle.Fill; + ClipboardList.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); + ClipboardList.ForeColor = System.Drawing.Color.White; + ClipboardList.FormattingEnabled = true; + ClipboardList.ItemHeight = 15; + ClipboardList.Location = new System.Drawing.Point(5, 0); + ClipboardList.Name = "ClipboardList"; + ClipboardList.Size = new System.Drawing.Size(224, 169); + ClipboardList.TabIndex = 0; + // + // Bottom + // + this.Bottom.BackColor = System.Drawing.Color.Transparent; + this.Bottom.Controls.Add(ToggleStatus); + this.Bottom.Controls.Add(this.ListControls); + this.Bottom.Dock = System.Windows.Forms.DockStyle.Bottom; + this.Bottom.Location = new System.Drawing.Point(0, 174); + this.Bottom.Name = "Bottom"; + this.Bottom.Size = new System.Drawing.Size(234, 55); + this.Bottom.TabIndex = 5; + // + // ToggleStatus + // + ToggleStatus.AutoSize = true; + ToggleStatus.ForeColor = System.Drawing.Color.White; + ToggleStatus.Location = new System.Drawing.Point(3, 35); + ToggleStatus.Name = "ToggleStatus"; + ToggleStatus.Size = new System.Drawing.Size(65, 17); + ToggleStatus.TabIndex = 8; + ToggleStatus.Text = "Enabled"; + ToggleStatus.UseVisualStyleBackColor = true; + // + // ListControls + // + this.ListControls.BackColor = System.Drawing.Color.Transparent; + this.ListControls.Dock = System.Windows.Forms.DockStyle.Top; + this.ListControls.IsSplitterFixed = true; + this.ListControls.Location = new System.Drawing.Point(0, 0); + this.ListControls.Name = "ListControls"; + // + // ListControls.Panel1 + // + this.ListControls.Panel1.BackColor = System.Drawing.Color.Transparent; + this.ListControls.Panel1.Controls.Add(this.Clear); + this.ListControls.Panel1.Padding = new System.Windows.Forms.Padding(5, 0, 0, 5); + // + // ListControls.Panel2 + // + this.ListControls.Panel2.BackColor = System.Drawing.Color.Transparent; + this.ListControls.Panel2.Controls.Add(this.Remove); + this.ListControls.Panel2.Padding = new System.Windows.Forms.Padding(0, 0, 5, 5); + this.ListControls.Size = new System.Drawing.Size(234, 34); + this.ListControls.SplitterDistance = 117; + this.ListControls.TabIndex = 7; + // + // Clear + // + this.Clear.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20))))); + this.Clear.Dock = System.Windows.Forms.DockStyle.Fill; + this.Clear.FlatAppearance.BorderSize = 0; + this.Clear.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.Clear.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); + this.Clear.ForeColor = System.Drawing.Color.White; + this.Clear.Location = new System.Drawing.Point(5, 0); + this.Clear.Name = "Clear"; + this.Clear.Size = new System.Drawing.Size(112, 29); + this.Clear.TabIndex = 0; + this.Clear.Text = "Clear all"; + this.Clear.UseVisualStyleBackColor = false; + this.Clear.Click += new System.EventHandler(this.Clear_Click); + // + // Remove + // + this.Remove.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20))))); + this.Remove.Dock = System.Windows.Forms.DockStyle.Fill; + this.Remove.FlatAppearance.BorderSize = 0; + this.Remove.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.Remove.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); + this.Remove.ForeColor = System.Drawing.Color.White; + this.Remove.Location = new System.Drawing.Point(0, 0); + this.Remove.Name = "Remove"; + this.Remove.Size = new System.Drawing.Size(108, 29); + this.Remove.TabIndex = 0; + this.Remove.Text = "Remove"; + this.Remove.UseVisualStyleBackColor = false; + this.Remove.Click += new System.EventHandler(this.Remove_Click); + // + // Top + // + this.Top.BackColor = System.Drawing.Color.Transparent; + this.Top.Controls.Add(this.ListSet); + this.Top.Dock = System.Windows.Forms.DockStyle.Top; + this.Top.Location = new System.Drawing.Point(0, 0); + this.Top.Name = "Top"; + this.Top.Size = new System.Drawing.Size(234, 32); + this.Top.TabIndex = 0; + // + // ListSet + // + this.ListSet.Dock = System.Windows.Forms.DockStyle.Fill; + this.ListSet.IsSplitterFixed = true; + this.ListSet.Location = new System.Drawing.Point(0, 0); + this.ListSet.Name = "ListSet"; + // + // ListSet.Panel1 + // + this.ListSet.Panel1.BackColor = System.Drawing.Color.Transparent; + this.ListSet.Panel1.Controls.Add(this.TextBox); + this.ListSet.Panel1.Padding = new System.Windows.Forms.Padding(5, 5, 0, 5); + // + // ListSet.Panel2 + // + this.ListSet.Panel2.BackColor = System.Drawing.Color.Transparent; + this.ListSet.Panel2.Controls.Add(this.Add); + this.ListSet.Panel2.Padding = new System.Windows.Forms.Padding(0, 5, 5, 5); + this.ListSet.Size = new System.Drawing.Size(234, 32); + this.ListSet.SplitterDistance = 165; + this.ListSet.SplitterWidth = 1; + this.ListSet.TabIndex = 0; + // + // TextBox + // + this.TextBox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20))))); + this.TextBox.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.TextBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.TextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F); + this.TextBox.ForeColor = System.Drawing.Color.White; + this.TextBox.Location = new System.Drawing.Point(5, 5); + this.TextBox.Multiline = true; + this.TextBox.Name = "TextBox"; + this.TextBox.Size = new System.Drawing.Size(160, 22); + this.TextBox.TabIndex = 0; + this.TextBox.WordWrap = false; + // + // Add + // + this.Add.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20))))); + this.Add.Dock = System.Windows.Forms.DockStyle.Fill; + this.Add.FlatAppearance.BorderSize = 0; + this.Add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.Add.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); + this.Add.ForeColor = System.Drawing.Color.White; + this.Add.Location = new System.Drawing.Point(0, 5); + this.Add.Name = "Add"; + this.Add.Size = new System.Drawing.Size(63, 22); + this.Add.TabIndex = 0; + this.Add.Text = "Add"; + this.Add.UseVisualStyleBackColor = false; + this.Add.Click += new System.EventHandler(this.Add_Click); + // + // UI + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30))))); + this.ClientSize = new System.Drawing.Size(234, 261); + this.Controls.Add(this.Fill); + this.Controls.Add(this.Top); + this.ForeColor = System.Drawing.Color.White; + this.MinimumSize = new System.Drawing.Size(250, 300); + this.Name = "UI"; + this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "ClipboardCycler"; + this.Load += new System.EventHandler(this.UI_Load); + this.Fill.ResumeLayout(false); + this.ListHolder.ResumeLayout(false); + this.Bottom.ResumeLayout(false); + this.Bottom.PerformLayout(); + this.ListControls.Panel1.ResumeLayout(false); + this.ListControls.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.ListControls)).EndInit(); + this.ListControls.ResumeLayout(false); + this.Top.ResumeLayout(false); + this.ListSet.Panel1.ResumeLayout(false); + this.ListSet.Panel1.PerformLayout(); + this.ListSet.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.ListSet)).EndInit(); + this.ListSet.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + private System.Windows.Forms.Panel Fill; + private System.Windows.Forms.Panel Bottom; + private System.Windows.Forms.Panel Top; + private System.Windows.Forms.SplitContainer ListSet; + private System.Windows.Forms.TextBox TextBox; + private System.Windows.Forms.Button Add; + private System.Windows.Forms.Panel ListHolder; + private static System.Windows.Forms.CheckBox ToggleStatus; + private System.Windows.Forms.SplitContainer ListControls; + private System.Windows.Forms.Button Clear; + private System.Windows.Forms.Button Remove; + private static System.Windows.Forms.ListBox ClipboardList; + } +} + diff --git a/src/Clipboard Cycler/UI.cs b/src/Clipboard Cycler/UI.cs new file mode 100644 index 0000000..ad7fe6c --- /dev/null +++ b/src/Clipboard Cycler/UI.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Clipboard_Cycler +{ + public partial class UI : Form + { + public UI() { + InitializeComponent(); + } + + #region Clipboard List Actions + + private void Add_Click(object sender, EventArgs e) { + ClipboardList.Items.Add(TextBox.Text); + TextBox.Text = ""; + } + + private void Clear_Click(object sender, EventArgs e) { + ClipboardList.Items.Clear(); + } + + private void Remove_Click(object sender, EventArgs e) { + if (ClipboardList.SelectedIndex >= 0) + ClipboardList.Items.RemoveAt(ClipboardList.SelectedIndex); + } + + + #endregion + + #region Clipboard Handler + + private static int index = -1; + + #region Keyboard Handler + + [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] + private static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId); + [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + private static extern bool UnhookWindowsHookEx(IntPtr hhk); + [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] + private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam); + + private delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam); + + private const int WH_KEYBOARD_LL = 13; + private static LowLevelKeyboardProc _proc = HookCallback; + private static IntPtr _hookId = IntPtr.Zero; + + private void UI_Load(object sender, EventArgs e) { + _hookId = SetWindowsHookEx(WH_KEYBOARD_LL, _proc, IntPtr.Zero, 0); + } + + private static Keys lastKey; + private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam) { + if (nCode >= 0 && wParam == (IntPtr)0x0100 && ToggleStatus.Checked == true) { + Keys key = (Keys)Marshal.ReadInt32(lParam); + if (lastKey == Keys.LControlKey && key == Keys.V) { + index = index < ClipboardList.Items.Count-1 ? index + 1 : 0; + if (ClipboardList.Items.Count >= 1) + Clipboard.SetText(ClipboardList.Items[index].ToString()); + } + else + lastKey = key; + } + return CallNextHookEx(_hookId, nCode, wParam, lParam); + } + + #endregion + + #endregion + } +} diff --git a/src/Clipboard Cycler/UI.resx b/src/Clipboard Cycler/UI.resx new file mode 100644 index 0000000..29dcb1b --- /dev/null +++ b/src/Clipboard Cycler/UI.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file