Skip to content

Commit

Permalink
移除 不必要的库Desktop.Robot
Browse files Browse the repository at this point in the history
  • Loading branch information
MakesYT committed Jul 11, 2024
1 parent af9695d commit bb73b4f
Show file tree
Hide file tree
Showing 3 changed files with 212 additions and 215 deletions.
1 change: 0 additions & 1 deletion Core/Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.1.0-rc2"/>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2"/>
<PackageReference Include="Desktop.Robot" Version="1.5.0"/>
<PackageReference Include="FluentAvaloniaUI" Version="2.0.5" />
<PackageReference Include="log4net" Version="2.0.17"/>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1"/>
Expand Down
30 changes: 14 additions & 16 deletions KitopiaAvalonia/Windows/MouseQuickWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,20 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Input;
using Avalonia.Markup.Xaml;
using Avalonia.Threading;
using Avalonia.Xaml.Interactivity;
using Core.ViewModel;
using Desktop.Robot;
using log4net;
using PluginCore;
using SharpHook;
using SharpHook.Native;
using Vanara.PInvoke;
using Key = Desktop.Robot.Key;

namespace KitopiaAvalonia.Windows;

public partial class MouseQuickWindow : Window
{
private static readonly ILog log = LogManager.GetLogger(nameof(MouseQuickWindow));

public MouseQuickWindow()
{
InitializeComponent();
Expand All @@ -47,16 +45,16 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
User32.GetWindowInfo(TryGetPlatformHandle().Handle, ref windowinfo);

int Left, Top;
if (pos.X + windowinfo.rcClient.Width<monitorInfo.rcMonitor.Right)
if (pos.X + windowinfo.rcClient.Width < monitorInfo.rcMonitor.Right)
{
Left = pos.X;
}
else
{
Left = pos.X - windowinfo.rcClient.Width;
}


if (pos.Y + windowinfo.rcClient.Height < monitorInfo.rcMonitor.Bottom)
{
Top = pos.Y;
Expand All @@ -75,13 +73,12 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
}


var robot = new Robot();
robot.AutoDelay = 1;
robot.KeyDown(Key.Control);
robot.KeyDown(Key.C);
Task.Delay(200);
robot.KeyUp(Key.C);
robot.KeyUp(Key.Control);
var eventSimulator = new EventSimulator();
eventSimulator.SimulateKeyPress(KeyCode.VcLeftControl);
eventSimulator.SimulateKeyPress(KeyCode.VcC);
Task.Delay(100).GetAwaiter().GetResult();
eventSimulator.SimulateKeyRelease(KeyCode.VcC);
eventSimulator.SimulateKeyRelease(KeyCode.VcLeftControl);

Dispatcher.UIThread.InvokeAsync(() =>
{
Expand All @@ -91,7 +88,8 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
{
((MouseQuickWindowViewModel)DataContext).SelectedItem = new SelectedItem()
{ type = FileType.文本, obj = s };
//log.Info(Clipboard.GetText());

log.Info(s);
}

if (text != null)
Expand Down
Loading

0 comments on commit bb73b4f

Please sign in to comment.