noob questions about windows interaction

Hello people,
Im new in the forum. Not totally new with cplusplus though.
I was programming a couple of things with sfml, managed to get a windows stay on top, have transparent bg and all sort of fancy stuff.
But there are 2 things i need to do and i dont find documentation about:
1- make taskbar background invisible. I already have that by ClassicShell's options, but i'd need my program to do so as well ( not everyone has classic shell right?)
2- open a fresh cmd window, get its handle (to make it borderless and other stuff, included moving it), and then passing it a couple of commands via string. It should then stay opened despite the user typing exit. It should only be closed by terminating the whole application, of which that cmd window would be just a little portion.
Any idea and/or suggestion?
2 is easy.
just write your own dumb console program:

1
2
3
4
5
6
7
8
9
int main()
{
    while(forever)
    {
        cin >> astring;
       if(astring != "exit")  //Handle all these, case insensitive issue, ctrl C, and other exit commands..  
       system(astring);
    }
}

this has many problems, due to the person being able to invoke batch files, other programs, or generally hack this approach. you may or may not choose to limit these things depending on level of trust for the user. Also consider the better versions of "system" .. there are many, many better options that are more secure and have other goodies. System is just the simple example. System lets the user do anything they can do at the console. Often, that can be very destructive in the hands of a skilled bad person or a moron.

A slick approach might be to have this spawn a virtual machine that can't damage the real machine.
Last edited on
"invoke batch files, other programs" well, that would not be an actual issue. What i'm doing has the purpose of having an easily accessible command prompt, the idea is that the user can do with it whatever he wants. Your idea of creating a dumb console program would require way more code than your example (memorizing previous inputs, getting a command's echoed return etcc etcc... that's why i'm trying to use the already existing cmd console.

Regardless of the exit command issue, i've encountered a strange difference in behavior between testing within visual studio and executing the executable:
SetForegroundWindow(prompt_window);
I used this line to make it so that when the cmd window moves on the screen it gets focus (in order to capture keyboard input). It does work when testing in visual studio (still release mode), but when i run it as a stand alone executable the cmd window only gets the caret as if it was in focus, but does not actually capture keyboard input...
Registered users can post here. Sign in or register to post.