简体   繁体   中英

Execute commands in new window of executed program with c code or batch file

I have a compiled program ( task.exe ). The result of this program is a new cmd window with specific commands there. I need to execute commands just in that cmd window, that is, I need to send keyboard input to that window. I tried to make something like this:

#include <stdio.h>
#include <stdlib.h>

int main()
{
    printf("Start task.exe"); 
    system("task.exe && command ");
    return 0;         
}

Guys, could you please help me with this problem. I think maybe I should somehow get the created process, and then work from there.

You can send keyboard input using the function SendInput .

A better, but more complex approach would be using Microsoft UI Automation .

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