I have the script to do the same thing in C++. Exactly the same works fine with notepad, but doesn't work in FreeCell or any other process :s.
#include <windows.h>
LRESULT CALLBACK WndProc(HWND hwnd,
UINT msg,
WPARAM wparam,
LPARAM lparam)
{
switch(msg)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
break;
}
return DefWindowProc(hwnd, msg, wparam, lparam);
}
INT WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd)
{
WNDCLASSEX wc;
MSG msg;
HWND hwnd, hTarget;
HDC hdc;
ZeroMemory(&wc, sizeof(wc));
wc.cbSize = sizeof(WNDCLASSEX);
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.lpfnWndProc = WndProc;
wc.lpszClassName = "BASIC";
wc.lpszMenuName = NULL;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
RegisterClassEx(&wc);
hwnd = CreateWindowEx(NULL,
"BASIC",
"NoScope",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
200,
200,
250,
300,
NULL,
NULL,
hInstance,
NULL);
hTarget = FindWindow(NULL, "FreeCell");
Sleep(500);
hdc = GetDC(hTarget);
if(!hTarget)
return 1;
if(!hdc)
return 1;
while(true)
{
Sleep(1);
Rectangle(hdc, 5, 5, 20, 20);
GetMessage(&msg, NULL, NULL, NULL);
TranslateMessage(&msg);
DispatchMessage(&msg);
if(msg.message == WM_QUIT)
break;
}
}
EDIT: Works in wordpad too