Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,678 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I need to intercept/catch the OSK.exe event when it launched or how to call an custom_osk before default one launches without editing the registry.is there any possible way to achieve this.
You can use ManagementEventWatcher and watch Win32_ProcessStartTrace to receive an event when a new process starts.
The following example shows how you can detect when OSK.exe starts:
using System.Management;
using System.Windows;
namespace WpfApp1
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
ManagementEventWatcher watcher;
private void Window_Loaded(object sender, RoutedEventArgs e)
{
watcher = new ManagementEventWatcher(
"Select * From Win32_ProcessStartTrace Where ProcessName = 'osk.exe'");
watcher.EventArrived += new EventArrivedEventHandler(watcher_EventArrived);
watcher.Start();
this.Title = "Waiting for OSK.exe to run ...";
}
void watcher_EventArrived(object sender, EventArrivedEventArgs e)
{
Dispatcher.Invoke(() => this.Title = "OSK.exe is running now.");
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
watcher.Stop();
watcher.Dispose();
}
}
}