Я пытаюсь создать программу, которая сможет управлять другой программой (в Windows).Нажмите на кнопку в другой программе - FindWindow, C#
Я нашел этот код:
// Get a handle to an application window.
[DllImport("USER32.DLL", CharSet = CharSet.Unicode)]
public static extern IntPtr FindWindow(string lpClassName,
string lpWindowName);
// Activate an application window.
[DllImport("USER32.DLL")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
//button event
private void button1_Click(object sender, EventArgs e)
{
// Get a handle to the Calculator application. The window class
// and window name were obtained using the Spy++ tool.
IntPtr calculatorHandle = FindWindow("CalcFrame", "Kalkulačka");
// Verify that Calculator is a running process.
if (calculatorHandle == IntPtr.Zero)
{
MessageBox.Show("Calculator is not running.");
return;
}
// Make Calculator the foreground application and send it
// a set of calculations.
SetForegroundWindow(calculatorHandle);
SendKeys.SendWait("111");
SendKeys.SendWait("*");
SendKeys.SendWait("11");
SendKeys.SendWait("=");
}
ли можно смоделировать нажать на кнопку? Как? Можно ли щелкнуть по программе в фоновом режиме?
Можете ли вы показать мне пример?
да это возможно, я верю, что это может дать вам некоторые идеи -http: //stackoverflow.com/questions/26502035/perform-a-mouse-click-event-on-another-application-using-c-sharp if а затем выполните простой поиск google – MethodMan
возможный дубликат [Управление другим приложением с использованием C#] (http://stackoverflow.com/questions/1134993/control-another-application-using-c-sharp) –
Да, я читал это, но я не знаю, как использовать библиотеку. Я думаю, есть другой способ. – phawresl