Is there a way to check if an event is fired when a mouse is clicked in a windows foreground application?
It can be operated in an application running on a desktop made with wpf method or uwp method or java framework. For example, there are applications such as calculator and notepad.
I want to create a method that handles something when an event occurs in the foreground application.
using System;
using System.Management;
class Program
{
static void Main(string[] args)
{
// Create a WMI query to monitor the creation of a new process with the name "calc.exe"
string query = "SELECT * FROM __InstanceCreationEvent WITHIN 2 " +
"WHERE TargetInstance ISA 'Win32_Process' " +
"AND TargetInstance.Name = 'calc.exe'";
// Create a ManagementEventWatcher with the WMI query
ManagementEventWatcher watcher = new ManagementEventWatcher(query);
// Start listening for events
watcher.Start();
Console.WriteLine("Monitoring for calculatorApp...");
while (true)
{
// Wait for the next event
ManagementBaseObject e = watcher.WaitForNextEvent();
// Get the process ID of the new process
uint processId = (uint)(e["TargetInstance"] as ManagementBaseObject)["ProcessId"];
Console.WriteLine($"calculatorApp (process ID {processId}) has been started.");
}
}
}
I try to use ManagementEventWatcher but hard to check event(ex button clicked) invoked.
I was only able to check that the process was started.