VideoHelp Forum
+ Reply to Thread
Results 1 to 6 of 6
Thread
  1. Member
    Join Date
    Mar 2006
    Location
    Denmark
    Search Comp PM
    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
    Search Comp PM
    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. 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
    Search PM
    Google search for "redirect stdout to a textbox"
    Donadagohvi (Cherokee for "Until we meet again")
    Quote Quote  
  5. Member midders's Avatar
    Join Date
    Sep 2008
    Location
    United Kingdom
    Search Comp PM
    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  
  6. Member metis's Avatar
    Join Date
    Jan 2021
    Location
    Spain
    Search Comp PM
    @squadjot

    redirect these output streams to files in a command window are ineffectual
    That's right. Therefore it's better/faster to read from/write to the FFmpeg-Process directly, as shown here:
    http://forum.lazarus.freepascal.org/index.php/topic,43411.0.html
    -> GoTo: "RunFFmpeg".
    This App is written with the Lazarus-Component-Library (LCL) and FreePascal (FPC), but it works the same Way with C++.

    If You want it really nice & fast, You have to open the File via the FFmpeg-Libraries themselves, as shown
    in the ScreenRecorder2FPC-Example, above on the same Site.

    BTW: I saw, that this Thread is really very, very old, but
    it's pending since then, though that Issue is still up-to-date.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!