测试代码

This commit is contained in:
辉鸭蛋
2025-01-19 19:32:15 +08:00
parent 0314644892
commit d1fcb9c21d
3 changed files with 36 additions and 4 deletions

View File

@@ -72,7 +72,7 @@ public class KeyMouseRecorderJsonLine
_consumerTask = Task.Run(async () => await ConsumeEventsAsync(_path));
}
public KeyMouseRecorderJsonLine Start()
{
StartTick = Kernel32.GetTickCount();
@@ -124,6 +124,11 @@ public class KeyMouseRecorderJsonLine
public void KeyDown(KeyEventArgsExt e)
{
var time = e.Timestamp - StartTick;
if (e.KeyCode == Keys.F)
{
TaskControl.Logger.LogInformation($"{DateTime.Now:HH:mm:ss.ffff}按下F");
}
AddEvent(_macroEventsChannel, new MacroEvent
{
Type = MacroEventType.KeyDown,
@@ -196,12 +201,12 @@ public class KeyMouseRecorderJsonLine
Time = time
});
}
public void MouseMoveBy(MouseState state, uint tick, bool save = false)
{
User32.GetCursorPos(out var p);
var mEvent = new MacroEvent
{
Type = MacroEventType.MouseMoveBy,

View File

@@ -510,5 +510,8 @@
<!--<ui:Button x:Name="Test" Margin="0,20,0,0" Content="测试" Command="{Binding TestCommand}" />-->
<TextBlock Name="ClockStartBlock">启动时间</TextBlock>
<TextBlock Name="ClockBlock">当前时间</TextBlock>
<TextBlock Name="TickBlock">tickCount</TextBlock>
</StackPanel>
</Page>

View File

@@ -1,4 +1,7 @@
using BetterGenshinImpact.ViewModel.Pages;
using System;
using System.Threading.Tasks;
using BetterGenshinImpact.ViewModel.Pages;
using Vanara.PInvoke;
namespace BetterGenshinImpact.View.Pages
{
@@ -12,6 +15,27 @@ namespace BetterGenshinImpact.View.Pages
InitializeComponent();
// hotKeyPageViewModel 放在这里是为了在首页就初始化热键
Task.Run(async () =>
{
bool first = true;
// 显示当前时间
while (true)
{
Dispatcher.Invoke(() =>
{
if (first)
{
first = false;
ClockStartBlock.Text = DateTime.Now.ToString("HH:mm:ss.fff") + " | " + Kernel32.GetTickCount().ToString();
}
ClockBlock.Text = DateTime.Now.ToString("HH:mm:ss.fff");
TickBlock.Text = Kernel32.GetTickCount().ToString();
});
await Task.Delay(10);
}
});
}
}
}