I would like to deteck if OSK.exe process (On screen keyboard) is open.
It's my code to open the OSK:
Process.Start("C:\\Windows\\System32\\osk.exe");
Do you have any ideas how can check it and prevent to launch twice and more this process ?
I would like to deteck if OSK.exe process (On screen keyboard) is open.
It's my code to open the OSK:
Process.Start("C:\\Windows\\System32\\osk.exe");
Do you have any ideas how can check it and prevent to launch twice and more this process ?
You could get a running process by name as below:
var arrProcs = Process.GetProcessesByName("osk");
if (arrProcs.Length == 0)
{
Process.Start("C:\\Windows\\System32\\osk.exe");
}
There are 2 aspects: 1. Process is already open by your application. In this case you already know the PID. The way to go is to try to see if the process with that PID is running.
Process[] processlist = Process.GetProcesses();
bool proccessRunning = false;
foreach(Process theprocess in processlist){
if( theprocess.Id == yourPID)
{
proccessRunning = true;
break;
}
}
2. Process was started outside of your app. Find the proc by listing all processes and looping o find the process by name