Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Need help

Need help

Scheduled Pinned Locked Moved C / C++ / MFC
helptestingtoolstutorial
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Aigledefer
    wrote on last edited by
    #1

    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); }

    _ M 2 Replies Last reply
    0
    • A Aigledefer

      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); }

      _ Offline
      _ Offline
      _foo
      wrote on last edited by
      #2

      Use Pipe Functions

      A 1 Reply Last reply
      0
      • _ _foo

        Use Pipe Functions

        A Offline
        A Offline
        Aigledefer
        wrote on last edited by
        #3

        But the cmd.exe window is not listening.

        1 Reply Last reply
        0
        • A Aigledefer

          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); }

          M Offline
          M Offline
          Mike Dimmick
          wrote on last edited by
          #4

          Creating a Child Process with Redirected Input and Output[^] Stability. What an interesting concept. -- Chris Maunder

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups