简体   繁体   中英

SendKeys or Send keystroke in 2 application at the same time

I am planning to make a simple program that I can use in my daily life.

My goal is to create a program that can sendkeys into 2 applications like Notepad and Word or notepad1 and notepad2 at the same time. I don't have yet a code because I don't know how and where should I start.

I would like to use .net or C# or C++.

// import the function in your class
[DllImport ("User32.dll")]
static extern int SetForegroundWindow(IntPtr point);

Process[] ps = Process.GetProcessesByName("notepad");
foreach (Process p in ps)
{
    IntPtr h = p.MainWindowHandle;
    SetForegroundWindow(h);
    SendKeys.SendWait("TEXT TO SEND");
}

Source: C# using Sendkey function to send a key to another application

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM