+ Reply to Thread
Results 1 to 5 of 5
Thread
  1. Member
    Join Date: Mar 2006
    Location: Denmark
    Hi everybody.

    I would like to build a little encoder application that uses CMD line executeables to do the work.
    A problem i havent found a solution to, is how to get the contents of a CMD prompt in progress.

    Alltho i TOTAL noob in C++ , i managed to create another .dll application once for a game, that did something like it. (getting text from game console) and it was using WM_GETTEXT

    So, i'm convinced that i can use WM_GETTEXT in c++ to get the contents of 8any) window.. but i dont' know exaclty how to.. =/


    Code:
    Here's the fundamental stuff of my old similar project
    #include "dll.h"
    #include <windows.h> 
    using namespace std;
    #pragma warning(disable:4129) 
    #define PARENTWND "Console" 
    #define CHILDWND "Edit" 
    #define MAX_BUFFER 16384  
    #define CR 13 
    #define LF 10 
    
    static HWND hwndParent        = NULL; 
    static HWND hwndEdit          = NULL; 
    static HWND hwndConsole       = NULL; 
    void SetWindowHandles(){ 
       hwndParent   = FindWindow(0, PARENTWND); 
       hwndEdit   	= FindWindowEx(hwndParent, NULL, CHILDWND, NULL); 
       hwndConsole   = FindWindowEx(hwndParent, hwndEdit, CHILDWND, NULL); 
       } 
    char* GetTextFromWindow() { 
          SendMessage(hwndConsole, WM_GETTEXT, (WPARAM)sizeof(consolestream), (LPARAM)consolestream);
    return consolestream;
    }
    
    
    int main(){ 
        SetWindowHandles(); 
    }
    Any pointers would be highly apreciated
    Quote Quote  

  2. Member midders's Avatar
    Join Date: Sep 2008
    Location: United Kingdom
    There's a possible solution here, but I'm wondering why it is you want to capture the output in the first place. If you want to show progress, then why not just bring the cmd window into the foreground. Or is it for some other reason?

    Also, if you're going to be using command line tools for all the work, then why not just write a batch file, rather than diving in to C++. Check out the link in my sig for an example.

    Slainte

    midders
    Quote Quote  

  3. Member
    Join Date: Dec 2005
    Location: none
    Originally Posted by midders
    why not just bring the cmd window into the foreground...
    why not just write a batch file...
    Because it's ugly? Ugly doesn't bother me but it bothers many people.
    Quote Quote  

  4. Man of Steel freebird73717's Avatar
    Join Date: Dec 2003
    Location: Smallville, USA
    Google search for "redirect stdout to a textbox"
    Donadagohvi (Cherokee for "Until we meet again")
    My Video Tools :: Free Security Software :: Ubuntu Antivirus Rescue CD
    Quote Quote  

  5. Member midders's Avatar
    Join Date: Sep 2008
    Location: United Kingdom
    Originally Posted by freebird73717
    Google search for "redirect stdout to a textbox"
    Many of the command line tools don't output to stdout or stderr, or at least attempts to redirect these output streams to files in a command window are ineffectual.

    Originally Posted by jagabo
    Because it's ugly? Ugly doesn't bother me but it bothers many people.
    If you say so. I guess beauty is in the eye of the beerholder.

    A quick fix solution would be to run the command line tool in a child window of your main application; then you can move the window around, change it's size and colour etc. however you like.
    Quote Quote  




Similar Threads

  1. wildcards in cmd
    By cL0N31 in forum Computer
    Replies: 6
    Last Post: 3rd Apr 2009, 21:58
  2. a mpg (ffmpeg's mpgs for dvd) joiner app?
    By jboyd in forum ffmpegX general discussion
    Replies: 2
    Last Post: 8th Feb 2008, 18:05
  3. Encoding does not progress/show progress
    By protect-ya-neck in forum ffmpegX general discussion
    Replies: 3
    Last Post: 20th Jul 2005, 15:49
  4. Fire fear prompts Xbox cable swap
    By BJ_M in forum Latest Video News
    Replies: 0
    Last Post: 17th Feb 2005, 12:00
  5. CMD 850
    By Dr_Layne in forum Capturing
    Replies: 0
    Last Post: 25th Jul 2004, 10:55
About   Advertise   Forum   RSS Feeds   Statistics   Tools