how to write to already opened console window
-
Hello All, I want to send cmds to previously opened console application for instance ,sending dir cmd to already opened cmd prompt. I got console window handle like below , HWND hwnd = ::FindWindow("ConsoleWindowClass","cmd.exe"); then how to write dir cmd to console? how to retrieve console handle for input and output ?
not only to get cmd result , i also want to keep it visible.
-
not only to get cmd result , i also want to keep it visible.
I found some samples in the net,where they create their own process and create pipe. my problem is i want to write cmd to previously created console window and i dont know how to create pipe to this console
-
Hello All, I want to send cmds to previously opened console application for instance ,sending dir cmd to already opened cmd prompt. I got console window handle like below , HWND hwnd = ::FindWindow("ConsoleWindowClass","cmd.exe"); then how to write dir cmd to console? how to retrieve console handle for input and output ?
Not sure if it will work, but you might try
AttachConsole()
, followed by one of theWritexxx()
functions. You could easily do this if your program also created the console window.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
-
Not sure if it will work, but you might try
AttachConsole()
, followed by one of theWritexxx()
functions. You could easily do this if your program also created the console window.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
but i can only retrieve consolewindow handle ,how I can utilize handle to attachconsole
-
not only to get cmd result , i also want to keep it visible.
Bilge Kaan, ur post is very interesting. may I ask: (1)what OS do u use for the App? (2)is the console executed (run) by your App? acturally I want to find already opened console window also, but as I tested, the function FindWindow() doesn't work.
A special image tool for C++ programmers, don't miss it! The world unique Software Label Maker is here for you and me ... A nice hyper tool for optimizing your MS html-help contents.
-
Bilge Kaan, ur post is very interesting. may I ask: (1)what OS do u use for the App? (2)is the console executed (run) by your App? acturally I want to find already opened console window also, but as I tested, the function FindWindow() doesn't work.
A special image tool for C++ programmers, don't miss it! The world unique Software Label Maker is here for you and me ... A nice hyper tool for optimizing your MS html-help contents.
1 ) I am using Win2000. 2 ) Console is not executed by my application.I want to write cmds to console created by another appli or manually started it is working proper for me , it is want you need HWND hwnd = ::FindWindow("ConsoleWindowClass","console_title");
-
but i can only retrieve consolewindow handle ,how I can utilize handle to attachconsole
Use
GetWindowThreadProcessId()
.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
-
Use
GetWindowThreadProcessId()
.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
attachconsole is only available for XP and Vista.
-
attachconsole is only available for XP and Vista.
Bilge Kaan wrote:
attachconsole is only available for XP and Vista.
It helps to specify those requirements up front.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
-
1 ) I am using Win2000. 2 ) Console is not executed by my application.I want to write cmds to console created by another appli or manually started it is working proper for me , it is want you need HWND hwnd = ::FindWindow("ConsoleWindowClass","console_title");
My OS is win98 (develop PCs are using win98 for us). I loaded a dos window, whose title is "MS-DOS Prompt" I tested HWND hwnd = ::FindWindow("ConsoleWindowClass","MS-DOS Prompt"); but return value (hwnd) is zero. what is wrong? did u test your code on win98 or other OS (your users may use different OSs)?
A special image tool for C++ programmers, don't miss it! The world unique Software Label Maker is here for you and me ... A nice hyper tool for optimizing your MS html-help contents.