Some Windows Function Magic Here...
Posted: Sun Feb 23, 2014 4:15 am
I'm still working on it, but I thought I might as well share what I have so far with others since this exists nowhere else online. Here's a small and very simple windows c++ executable I have been working on that allows you to lock programs to the desktop and/or modify the desktop workspace so that fullscreen windows don't cover your apps. These are both things that you cannot currently do inside of LC.
To lock a window to the desktop, send it a single argument of the window's id like "wSet 6312879" (no quotes). It will run in the background and ensure that the window doesn't move up in ordering (it might flicker when clicked sometimes though if your refresh rate is very high).
To change the workspace, send the rect of the desired new workspace as four seperate arguments on the command line. Using "wSet 50 0 1366 768" (no quotes) will reserve the space 50 pixels from the left side of the screen for a 1366x768 monitor and adjust all currently open windows to fit in the new area. Rerun it with the original values obtained from "the windowboundingrect" to revert the changes before closing.
You can try out the executable I attached or just compile the code below with the proper includes (windows, time, iostream).
If anyone can help me get these functions set up as externals to call from inside LC I would be very happy.
Have fun making things that were impossible before.
To lock a window to the desktop, send it a single argument of the window's id like "wSet 6312879" (no quotes). It will run in the background and ensure that the window doesn't move up in ordering (it might flicker when clicked sometimes though if your refresh rate is very high).
To change the workspace, send the rect of the desired new workspace as four seperate arguments on the command line. Using "wSet 50 0 1366 768" (no quotes) will reserve the space 50 pixels from the left side of the screen for a 1366x768 monitor and adjust all currently open windows to fit in the new area. Rerun it with the original values obtained from "the windowboundingrect" to revert the changes before closing.
You can try out the executable I attached or just compile the code below with the proper includes (windows, time, iostream).
Code: Select all
#include "stdafx.h"
using namespace std;
bool downLevel(HWND WindowID)
{
if (!IsWindowVisible(WindowID))
return false;
if (SetWindowPos(WindowID, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING | SWP_NOSIZE | SWP_NOREDRAW | SWP_NOREPOSITION))
return true;
else
return false;
}
bool setRect(long left, long top, long right, long bottom)
{
RECT workarea;
//Set up new work area size
workarea.left = left;
workarea.top = top;
workarea.right = right;
workarea.bottom = bottom;
//Set the new work area and broadcast the change to all running applications
if (SystemParametersInfo(SPI_SETWORKAREA, 0, &workarea, SPIF_SENDCHANGE))
return true;
else
return false;
}
int main(int argc, char* argv[])
{
if (argc == 2)
{
HWND tWindowID = (HWND)atoi(argv[1]);
//Check if window can be set
if (!IsWindowVisible(tWindowID))
{
cout << "ERROR: Invalid Window ID!";
return 0;
}
//Lock window
while (downLevel(tWindowID)) { Sleep(2); }
cout << "Process Lost.";
return 0;
}
else if (argc == 5)
{
if (!(setRect(atoi(argv[1]), atoi(argv[2]), atoi(argv[3]), atoi(argv[4]))))
cout << "ERROR: Failed to edit system parameters.";
return 0;
}
else
{
cout << "ERROR: Incorrect number of parameters!";
return 0;
}
}
Have fun making things that were impossible before.