I am trying to create a basic macro recorder, which will work on any open application. So I have to specify application that my program will work on.
How can i recognize and select open applications on visual studio's combobox tool?
I am trying to create a basic macro recorder, which will work on any open application. So I have to specify application that my program will work on.
How can i recognize and select open applications on visual studio's combobox tool?
You could use this:
System.Diagnostics.Process[] procArray;
Dictionary<string,int> applications = new Dictionary<string,int>();
procArray = System.Diagnostics.Process.GetProcesses();
for (int i = 0; i < procArray.Length; i++)
{
if (procArray[i].MainWindowTitle.Length > 0)
{
applications.Add(procArray[i].MainWindowTitle, procArray[i].Id);
}
}
foreach (KeyValuePair<string, int> app in applications)
{
comboBox.Items.Add(app.Key);
}
This code will include only the processes that have open windows (if you run task managers in the tab "Applications" you will see those applications). The process Ids can be used to get the handles.