mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-11-27 14:59:16 +08:00
[MouseJump]Bring back telemetry events (#35582)
This commit is contained in:
parent
133aa85f2b
commit
a0138cec5e
@ -91,6 +91,10 @@ namespace winrt::PowerToys::Interop::implementation
|
|||||||
{
|
{
|
||||||
return CommonSharedConstants::MOUSE_JUMP_SHOW_PREVIEW_EVENT;
|
return CommonSharedConstants::MOUSE_JUMP_SHOW_PREVIEW_EVENT;
|
||||||
}
|
}
|
||||||
|
hstring Constants::TerminateMouseJumpSharedEvent()
|
||||||
|
{
|
||||||
|
return CommonSharedConstants::TERMINATE_MOUSE_JUMP_SHARED_EVENT;
|
||||||
|
}
|
||||||
hstring Constants::AwakeExitEvent()
|
hstring Constants::AwakeExitEvent()
|
||||||
{
|
{
|
||||||
return CommonSharedConstants::AWAKE_EXIT_EVENT;
|
return CommonSharedConstants::AWAKE_EXIT_EVENT;
|
||||||
|
@ -26,6 +26,7 @@ namespace winrt::PowerToys::Interop::implementation
|
|||||||
static hstring ShowPowerOCRSharedEvent();
|
static hstring ShowPowerOCRSharedEvent();
|
||||||
static hstring TerminatePowerOCRSharedEvent();
|
static hstring TerminatePowerOCRSharedEvent();
|
||||||
static hstring MouseJumpShowPreviewEvent();
|
static hstring MouseJumpShowPreviewEvent();
|
||||||
|
static hstring TerminateMouseJumpSharedEvent();
|
||||||
static hstring AwakeExitEvent();
|
static hstring AwakeExitEvent();
|
||||||
static hstring ShowPeekEvent();
|
static hstring ShowPeekEvent();
|
||||||
static hstring TerminatePeekEvent();
|
static hstring TerminatePeekEvent();
|
||||||
|
@ -23,6 +23,7 @@ namespace PowerToys
|
|||||||
static String ShowPowerOCRSharedEvent();
|
static String ShowPowerOCRSharedEvent();
|
||||||
static String TerminatePowerOCRSharedEvent();
|
static String TerminatePowerOCRSharedEvent();
|
||||||
static String MouseJumpShowPreviewEvent();
|
static String MouseJumpShowPreviewEvent();
|
||||||
|
static String TerminateMouseJumpSharedEvent();
|
||||||
static String AwakeExitEvent();
|
static String AwakeExitEvent();
|
||||||
static String ShowPeekEvent();
|
static String ShowPeekEvent();
|
||||||
static String TerminatePeekEvent();
|
static String TerminatePeekEvent();
|
||||||
|
@ -81,6 +81,8 @@ namespace CommonSharedConstants
|
|||||||
// Path to the events used by Mouse Jump
|
// Path to the events used by Mouse Jump
|
||||||
const wchar_t MOUSE_JUMP_SHOW_PREVIEW_EVENT[] = L"Local\\MouseJumpEvent-aa0be051-3396-4976-b7ba-1a9cc7d236a5";
|
const wchar_t MOUSE_JUMP_SHOW_PREVIEW_EVENT[] = L"Local\\MouseJumpEvent-aa0be051-3396-4976-b7ba-1a9cc7d236a5";
|
||||||
|
|
||||||
|
const wchar_t TERMINATE_MOUSE_JUMP_SHARED_EVENT[] = L"Local\\TerminateMouseJumpEvent-252fa337-317f-4c37-a61f-99464c3f9728";
|
||||||
|
|
||||||
// Path to the event used by RegistryPreview
|
// Path to the event used by RegistryPreview
|
||||||
const wchar_t REGISTRY_PREVIEW_TRIGGER_EVENT[] = L"Local\\RegistryPreviewEvent-4C559468-F75A-4E7F-BC4F-9C9688316687";
|
const wchar_t REGISTRY_PREVIEW_TRIGGER_EVENT[] = L"Local\\RegistryPreviewEvent-4C559468-F75A-4E7F-BC4F-9C9688316687";
|
||||||
|
|
||||||
|
@ -62,9 +62,12 @@ private:
|
|||||||
|
|
||||||
Hotkey m_hotkey;
|
Hotkey m_hotkey;
|
||||||
|
|
||||||
// Handle to event used to invoke PowerOCR
|
// Handle to event used to invoke MouseJump
|
||||||
HANDLE m_hInvokeEvent;
|
HANDLE m_hInvokeEvent;
|
||||||
|
|
||||||
|
// Handle to event used to terminate MouseJump
|
||||||
|
HANDLE m_hTerminateEvent;
|
||||||
|
|
||||||
void parse_hotkey(PowerToysSettings::PowerToyValues& settings)
|
void parse_hotkey(PowerToysSettings::PowerToyValues& settings)
|
||||||
{
|
{
|
||||||
auto settingsObject = settings.get_raw_json();
|
auto settingsObject = settings.get_raw_json();
|
||||||
@ -154,6 +157,7 @@ public:
|
|||||||
{
|
{
|
||||||
LoggerHelpers::init_logger(MODULE_NAME, L"ModuleInterface", LogSettings::mouseJumpLoggerName);
|
LoggerHelpers::init_logger(MODULE_NAME, L"ModuleInterface", LogSettings::mouseJumpLoggerName);
|
||||||
m_hInvokeEvent = CreateDefaultEvent(CommonSharedConstants::MOUSE_JUMP_SHOW_PREVIEW_EVENT);
|
m_hInvokeEvent = CreateDefaultEvent(CommonSharedConstants::MOUSE_JUMP_SHOW_PREVIEW_EVENT);
|
||||||
|
m_hTerminateEvent = CreateDefaultEvent(CommonSharedConstants::TERMINATE_MOUSE_JUMP_SHARED_EVENT);
|
||||||
init_settings();
|
init_settings();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -245,6 +249,8 @@ public:
|
|||||||
if (m_enabled)
|
if (m_enabled)
|
||||||
{
|
{
|
||||||
ResetEvent(m_hInvokeEvent);
|
ResetEvent(m_hInvokeEvent);
|
||||||
|
SetEvent(m_hTerminateEvent);
|
||||||
|
WaitForSingleObject(m_hProcess, 1500);
|
||||||
TerminateProcess(m_hProcess, 1);
|
TerminateProcess(m_hProcess, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,6 +166,7 @@ internal sealed partial class MainForm : Form
|
|||||||
|
|
||||||
// move mouse pointer
|
// move mouse pointer
|
||||||
Logger.LogInfo($"clicked location = {clickedLocation}");
|
Logger.LogInfo($"clicked location = {clickedLocation}");
|
||||||
|
Microsoft.PowerToys.Telemetry.PowerToysTelemetry.Log.WriteEvent(new Telemetry.MouseJumpTeleportCursorEvent());
|
||||||
MouseHelper.SetCursorPosition(clickedLocation);
|
MouseHelper.SetCursorPosition(clickedLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,6 +203,8 @@ internal sealed partial class MainForm : Form
|
|||||||
|
|
||||||
stopwatch.Stop();
|
stopwatch.Stop();
|
||||||
|
|
||||||
|
Microsoft.PowerToys.Telemetry.PowerToysTelemetry.Log.WriteEvent(new Telemetry.MouseJumpShowEvent());
|
||||||
|
|
||||||
// we have to activate the form to make sure the deactivate event fires
|
// we have to activate the form to make sure the deactivate event fires
|
||||||
this.Activate();
|
this.Activate();
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ using System.Windows.Threading;
|
|||||||
using Common.UI;
|
using Common.UI;
|
||||||
using ManagedCommon;
|
using ManagedCommon;
|
||||||
using Microsoft.PowerToys.Settings.UI.Library;
|
using Microsoft.PowerToys.Settings.UI.Library;
|
||||||
|
using Microsoft.PowerToys.Telemetry;
|
||||||
using MouseJumpUI.Helpers;
|
using MouseJumpUI.Helpers;
|
||||||
using PowerToys.Interop;
|
using PowerToys.Interop;
|
||||||
|
|
||||||
@ -20,6 +21,8 @@ namespace MouseJumpUI;
|
|||||||
|
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
|
private static CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The main entry point for the application.
|
/// The main entry point for the application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -27,6 +30,7 @@ internal static class Program
|
|||||||
private static void Main(string[] args)
|
private static void Main(string[] args)
|
||||||
{
|
{
|
||||||
Logger.InitializeLogger("\\MouseJump\\Logs");
|
Logger.InitializeLogger("\\MouseJump\\Logs");
|
||||||
|
ETWTrace etwTrace = new ETWTrace();
|
||||||
|
|
||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
@ -62,13 +66,10 @@ internal static class Program
|
|||||||
|
|
||||||
Logger.LogInfo($"Mouse Jump started from the PowerToys Runner. Runner pid={runnerPid}");
|
Logger.LogInfo($"Mouse Jump started from the PowerToys Runner. Runner pid={runnerPid}");
|
||||||
|
|
||||||
var cancellationTokenSource = new CancellationTokenSource();
|
|
||||||
|
|
||||||
RunnerHelper.WaitForPowerToysRunner(runnerPid, () =>
|
RunnerHelper.WaitForPowerToysRunner(runnerPid, () =>
|
||||||
{
|
{
|
||||||
Logger.LogInfo("PowerToys Runner exited. Exiting Mouse Jump");
|
Logger.LogInfo("PowerToys Runner exited.");
|
||||||
cancellationTokenSource.Cancel();
|
TerminateApp();
|
||||||
Application.Exit();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var settingsHelper = new SettingsHelper();
|
var settingsHelper = new SettingsHelper();
|
||||||
@ -80,7 +81,21 @@ internal static class Program
|
|||||||
Dispatcher.CurrentDispatcher,
|
Dispatcher.CurrentDispatcher,
|
||||||
cancellationTokenSource.Token);
|
cancellationTokenSource.Token);
|
||||||
|
|
||||||
|
NativeEventWaiter.WaitForEventLoop(
|
||||||
|
Constants.TerminateMouseJumpSharedEvent(),
|
||||||
|
TerminateApp,
|
||||||
|
Dispatcher.CurrentDispatcher,
|
||||||
|
cancellationTokenSource.Token);
|
||||||
|
|
||||||
Application.Run();
|
Application.Run();
|
||||||
|
etwTrace?.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void TerminateApp()
|
||||||
|
{
|
||||||
|
Logger.LogInfo("Exiting Mouse Jump.");
|
||||||
|
cancellationTokenSource.Cancel();
|
||||||
|
Application.Exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MouseJumpSettings ReadSettings()
|
private static MouseJumpSettings ReadSettings()
|
||||||
|
Loading…
Reference in New Issue
Block a user