Reputation: 45
Is it possible to have a command line interface like the command prompt constantly running on the Windows desktop, instead of a wallpaper for example? This to achieve a kind of MS-DOS experience, but with all the usual Windows features.
Upvotes: 1
Views: 84
Reputation: 104589
While I suspect someone has done a more formalized version of this before, you could riff on the following code:
#include <windows.h>
#include <string>
#include <iostream>
HWND g_hwndTarget;
BOOL CALLBACK EnumCallback(HWND hwnd, LPARAM lParam)
{
wchar_t szText[MAX_PATH] = {};
GetWindowTextW(hwnd, szText, MAX_PATH);
std::wstring strTitle = szText;
if (strTitle.find(L"cmd.exe") != std::string::npos)
{
g_hwndTarget = hwnd;
return FALSE;
}
return TRUE;
}
int main()
{
EnumDesktopWindows(NULL, EnumCallback, 0);
RECT rect = {};
SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0);
if (g_hwndTarget)
{
LONG style = GetWindowLong(g_hwndTarget, GWL_STYLE);
style &= ~WS_BORDER;
style &= ~WS_OVERLAPPEDWINDOW;
SetWindowLong(g_hwndTarget, GWL_STYLE, style);
SetWindowPos(g_hwndTarget, HWND_BOTTOM, 0, 0, rect.right, rect.bottom, 0);
}
return 0;
}
Compile the above and run it from an existing console window. What the code does is this:
Find a console window (first window with cmd.exe in its title bar). With this window handle it does the following.
Removes the title bar and top level button/menus
Sticks it at the bottom of the window stack
Resizes it full screen.
The result is that you have a pseudo "command line desktop"
It's far from robust. And it might make sense to have a background process constantly ensuring it exists and is positioned/styled correctly. But it's a start. You'll have to take it to the next level to meet your needs.
Upvotes: 1