So my question is how to send some comands or input from one (c++) program to another if hi is on hidden mode? For example I want to open some text file in notepad with function WinExec("notepad", 0); and than want to print conetent of file, I make handle to that file, make sendinput with CTRL+P, and the window of printig show up,.... I want to make all that proces hidden from user, is it possible?
There're many ways to do it. You can open notepad on a separate desktop. If you run notepad with SW_HIDDEN it would also not show the window, and then you can use windows hooks to hook the creation of print window and ShowWindow() it to hidden.
But why all the hassle? If you don't need notepad's UI, why not just print the file yourself?
Related
I want a C++ program to execute a function when I close manually the console.
I made a C++ program that test a password and if it isn't correct make the windows to log off.
But if I close the console from the "X" button nothing happens and I want to make windows to log off too if the console is closed from "X" button?
I tried _onexit_t oe() function but it doesn't help me.
So there is a method to do that or to hide the bar which contains the "Minimize", "Maximize" and "Close" buttons?
Assuming you mean the normal textual console window, you can register your own event handler via SetConsoleCtrlHandler and watch for the events CTRL_C_EVENT, CTRL_BREAK_EVENT, CTRL_CLOSE_EVENT, CTRL_LOGOFF_EVENT, CTRL_SHUTDOWN_EVENT, etc.
I'm trying to create a program in C++, which open with him, within the form, the CMD, so that I can run a program within the CMD that is inside the program. As an example, in this photo:
I found some examples, but could not implement them in code, so, I ask your help... To be more precise, I want to create a function in a dll, so I can call this CMD, starting from any language
basically an embedding a Console
I see two methods:
Write your own console widget and pass all entered command to the std::system command
Do what is described in How to open a console window in a Win32 application
I don't know how to make a window when I start up Windows. I just want a simple window that has some text in it, such as a reminder. I don't want to download anything, and I think C++ is the easiest way to do it.
The easiest way to display a window with a message in Windows would be use use VBScript. Create a text file with the following in it.
msgbox("hello world")
Now, name the file MyProgram.vbs or anything else with a .vbs extension.
Double click on the file to run it. The message "hello world" should be shown in a small window on your screen. As seen in the image below.
To run it at start up, just drag it in your Startup folder in your Start Menu.
I need to create a console application (c++ windows) as a subprocess that will accept input both by the user and by the parent parent process. I would like to know if that is feasible and how.
Thanks.
Panagiotis
This should be fairly straightforward:
stdin is the redirected input from the parent process or input pipe
open a file named "CONIN$" to get keyboard input from the console window
I want to open a text file into some text editor say notepad programmatically in c/c++.
Also i want to see real time updation of text into that text file while opening in a editor.
Please suggest.
Most editors accepts the path of the file-to-be-opened as 1st argument. E.g.
notepad.exe c:/foo.txt
Just execute it as a shell/runtime command in your program.
If you're doing something as simple as monitoring a log file, you want a unix program called "tail", or its Windows equivalent.
It will give you a simple Notepad-like Window which displays the contents of a log file in (more or less) real time.
Having the editor (notepad, tail, whatever) continually monitor the file for changes isn't your job as the C++ developer, it's up to the program.
To get the file to open in the default application specified, try this (C#):
System.Diagnostics.Process.Start("text.txt");
To specify an application, try this:
System.Diagnostics.Process.Start( "notepad.exe", "text.txt");
I'm not aware of any way to handle real time updation of the file in the editor however.
After you have it running, see above. you can possibly keep the file updated using SendMessage from the Windows API and sending Ctrl+S(save) to the notepad window.
To see real time update in your editor window try to find editor's window handle (you may use EnumWindows() function). Insert text in the editor's textfield or reread it from the file and call RedrawWindow() after that. However calling it after each letter could give some nasty flickering if the text come from a program.