Water was sprayed on my 19" monitor and damaged some parts of it. I need a solution that will let me specify the screen area to be used by Windows, as if it was a smaller monitor. Its default menu doesn't have this option.
3 Answers
What model is your monitor? It may have a "1:1 pixel mode" or something like that in the settings. With that option set, you can specify a lower screen resolution on the computer, and the monitor will only use that number of pixels, instead of scaling the image to full screen.
- 8,981
This simple C program does the job.
It sets the so called 'Work Area' rectangle that is used by Win OS to bound maximized and aligned windows.
Optionally you can limit the mouse from going out as well.
It also tries to retrieve OS description for error codes, to better troubleshoot the unexpected and unheard!
I tried to put it in a single file to ease saving and using:
#define APP_TITLE L"Set_Work_Area"
#define USAGE L"Usage: Set_Work_Area [ Work Area [ Cursor Clipping ] ]\nEach is a rectangle specified as: Left Top Right Bottom\nThe right and bottom are exclusive (that is, one pixel out. MS's design).\n\nExample: Set_Work_Area 245 40 1366 568\nSets Work Area for a 1366x768 monitor with 245 unusable columns in the left and\n200 unusable rows in the bottom, which has a 40 rows Taskbar in the top.\n\nExample: Set_Work_Area 245 40 1366 568 245 0 1366 568\nFor the above example, also limits the mouse to the Work Area and the Taskbar.\n\nNote: Both are reset by Win OS in lock-screen(and in full-screen Start Menu for\nCursor Clipping). Putting in Start Menu and Scheduled Tasks seems good.\n\nFor multi-monitor systems, this is relative to the whole desktop, and is only\nset for the monitor that contains the specified rectangle.\n\nWork Area is a rectangle used by Win OS to horizontally/vertically bound\napp windows when they'r maximized, vertically-expanded (like by double-clicking\nthe horizontal edge), or left/right-aligned (by Win+Left/Win+Right hotkeys).\nCursor Clipping is a procedure used by Win OS to restrict the mouse cursor."
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <shellapi.h>
#include <stdint.h>
#include <stdio.h>
int error(WCHAR *context);
int WINAPI WinMain(HINSTANCE in_hInstance, HINSTANCE hPrevInstance, LPSTR CmdLine, int CmdShow)
{
int argc;
WCHAR argv = CommandLineToArgvW(GetCommandLineW(), &argc);
if (argc != 4 && argc != 8)
return error(L"Incorrect number of arguments.");
LONG c[4];
for (int i = 0; i < 4; i++)
c[i] = wcstol(argv[i], (WCHAR )NULL, 10);
if (c[2] < c[0] + 200 || c[3] < c[1] + 200)
return error(L"The specified Work Area has less than 200 pixels in width or height.");
if (!SystemParametersInfoW(SPI_SETWORKAREA, 0, c, SPIF_SENDCHANGE))
return error(L"SPI_SETWORKAREA error.");
if (argc == 8)
{
RECT r = (RECT )c;
for (int i = 0; i < 4; i++)
c[i] = wcstol(argv[i + 4], (WCHAR **)NULL, 10);
if (!ClipCursor(r))
return error(L"ClipCursor error.");
}
return 0;
}
int error(WCHAR context)
{
uint32_t last_error = GetLastError();
WCHAR desc[0x21000] = {0};
WCHAR out[0x22000];
if (last_error)
if (!FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, last_error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (WCHAR )&(desc), 0, NULL))
snwprintf(desc, 0x21000, L"Could not retrieve error description; Error number=%d", last_error);
snwprintf(out, 0x22000, L"Error: %s%s%s\n\n%s", context ? context : L"",
desc[0] ? L"\nMore description: " : L"", desc, USAGE);
if (desc[0])
LocalFree(desc);
MessageBoxW(NULL, out, APP_TITLE, MB_OK);
return 1;
}
How to use:
- Save as
Set_Work_Area.Cand compile using:gcc -mwindows -x c -std=c99 Set_Work_Area.C -o Set_Work_Area.exe - Find out your desired Work Area. You can achieve this by resizing a window to fit the desired portion of the screen and doing a PrintScreen (If experiencing difficulty resizing a window with mouse, you can use Alt+Space, then S for Size, then one arrow key to select the corresponding window edge, then arrow keys to move that edge, then Enter to set).
- Paste in an image editor and get the window's left, top, right and bottom dimensions.
- Run
Set_Work_Area.exe left right top bottom. Full description is provided inUSAGEtext when running the program with no arguments. - Open any program, hit Win+Up to maximize, (or Win+Left or Win+Right to align) and enjoy.
In case you set an undesired Work Area rectangle, bring lockscreen by Win+L to reset.
A copy of the USAGE text, in case someone has inconvenience viewing the MessageBox:
Usage:
Set_Work_Area [ Work Area [ Cursor Clipping ] ]
Each is a rectangle specified as:Left Top Right Bottom
The right and bottom are exclusive (that is, one pixel out. MS's design).
Example:Set_Work_Area 245 40 1366 568
Sets Work Area for a1366x768monitor with245unusable columns in the left and200unusable rows in the bottom, which has a40rows Taskbar in the top.
Example:Set_Work_Area 245 40 1366 568 245 0 1366 568
For the above example, also limits the mouse to the Work Area and the Taskbar.
Note: Both are reset by Win OS in lock-screen(and in full-screen Start Menu for Cursor Clipping). A Start Menu shortcut (and maybe a Scheduled Task) is handy.
For multi-monitor systems, this is relative to the whole desktop, and is only set for the monitor that contains the specified rectangle.
Work Area is a rectangle used by Win OS to horizontally/vertically bound app windows when they'r maximized, vertically-expanded (like by double-clicking the horizontal edge), or left/right-aligned (by Win+Left/Win+Right hotkeys).
Cursor Clipping is a procedure used by Win OS to restrict the mouse cursor.
- 266