Need help
-
I want to develop a tool which is similar with test automation tool. This tool launches a cmd window and writes some command lines in that window. Now I am able to get cmd window handle, but I don't know how to write the lines. Could anyone help me and I will appreciate it. Here is the code I have done. WinExec("cmd.exe", SW_SHOW); CWnd* pDeskWnd = CWnd::GetDesktopWindow(); CWnd* pPrevWnd = pDeskWnd->GetWindow(GW_CHILD); while (pPrevWnd) { CString s; pPrevWnd->GetWindowText(s); if (s.CompareNoCase("C:\\WINDOWS\\System32\\cmd.exe") == 0) { if (pPrevWnd->IsIconic()) pPrevWnd->ShowWindow(SW_RESTORE); pPrevWnd->SetForegroundWindow(); pPrevWnd->GetLastActivePopup()->SetForegroundWindow(); CWnd* pCmd = pPrevWnd->GetActiveWindow(); // CPoint id = pPrevWnd->GetActiveWindow();// GetDlgCtrlID(); // pPrevWnd->SetDlgItemText(id, "A command"); /* CDC* pDC = pPrevWnd->GetDC(); pDC->TextOut(0, 100, "A command I want to issue:)");*/ return; } pPrevWnd = pPrevWnd->GetWindow(GW_HWNDNEXT); }
-
I want to develop a tool which is similar with test automation tool. This tool launches a cmd window and writes some command lines in that window. Now I am able to get cmd window handle, but I don't know how to write the lines. Could anyone help me and I will appreciate it. Here is the code I have done. WinExec("cmd.exe", SW_SHOW); CWnd* pDeskWnd = CWnd::GetDesktopWindow(); CWnd* pPrevWnd = pDeskWnd->GetWindow(GW_CHILD); while (pPrevWnd) { CString s; pPrevWnd->GetWindowText(s); if (s.CompareNoCase("C:\\WINDOWS\\System32\\cmd.exe") == 0) { if (pPrevWnd->IsIconic()) pPrevWnd->ShowWindow(SW_RESTORE); pPrevWnd->SetForegroundWindow(); pPrevWnd->GetLastActivePopup()->SetForegroundWindow(); CWnd* pCmd = pPrevWnd->GetActiveWindow(); // CPoint id = pPrevWnd->GetActiveWindow();// GetDlgCtrlID(); // pPrevWnd->SetDlgItemText(id, "A command"); /* CDC* pDC = pPrevWnd->GetDC(); pDC->TextOut(0, 100, "A command I want to issue:)");*/ return; } pPrevWnd = pPrevWnd->GetWindow(GW_HWNDNEXT); }
-
But the cmd.exe window is not listening.
-
I want to develop a tool which is similar with test automation tool. This tool launches a cmd window and writes some command lines in that window. Now I am able to get cmd window handle, but I don't know how to write the lines. Could anyone help me and I will appreciate it. Here is the code I have done. WinExec("cmd.exe", SW_SHOW); CWnd* pDeskWnd = CWnd::GetDesktopWindow(); CWnd* pPrevWnd = pDeskWnd->GetWindow(GW_CHILD); while (pPrevWnd) { CString s; pPrevWnd->GetWindowText(s); if (s.CompareNoCase("C:\\WINDOWS\\System32\\cmd.exe") == 0) { if (pPrevWnd->IsIconic()) pPrevWnd->ShowWindow(SW_RESTORE); pPrevWnd->SetForegroundWindow(); pPrevWnd->GetLastActivePopup()->SetForegroundWindow(); CWnd* pCmd = pPrevWnd->GetActiveWindow(); // CPoint id = pPrevWnd->GetActiveWindow();// GetDlgCtrlID(); // pPrevWnd->SetDlgItemText(id, "A command"); /* CDC* pDC = pPrevWnd->GetDC(); pDC->TextOut(0, 100, "A command I want to issue:)");*/ return; } pPrevWnd = pPrevWnd->GetWindow(GW_HWNDNEXT); }
Creating a Child Process with Redirected Input and Output[^] Stability. What an interesting concept. -- Chris Maunder