Skip to content

Commit

Permalink
optimized auto read clipboard experience #165
Browse files Browse the repository at this point in the history
  • Loading branch information
jitwxs committed Mar 26, 2023
1 parent 8fc6407 commit 7eab27b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion MusicLyricApp/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions MusicLyricApp/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Linq;
using System.Net;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -36,6 +37,9 @@ public partial class MainForm : MusicLyricForm
private ShortcutForm _shortcutForm;

private BlurForm _blurForm;

[DllImport("user32.dll")]
private static extern IntPtr GetActiveWindow();

public MainForm()
{
Expand Down Expand Up @@ -749,11 +753,14 @@ private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
File.WriteAllText(Constants.SettingPath, _globalSearchInfo.SettingBean.ToJson(), Encoding.UTF8);
}

private void MainForm_MouseEnter(object sender, EventArgs e)
private void Search_Text_MouseEnter(object sender, EventArgs e)
{
if (_globalSearchInfo.SettingBean.Config.AutoReadClipboard)
if (GetActiveWindow() == Handle)
{
Search_Text.Text = Clipboard.GetText();
if (_globalSearchInfo.SettingBean.Config.AutoReadClipboard)
{
Search_Text.Text = Clipboard.GetText();
}
}
}

Expand Down

0 comments on commit 7eab27b

Please sign in to comment.