一个激情的exe

#include <stdio.h>
#include <windows.h>

int main(int argc, char *argv[])
{
    RECT rect;
    HWND hwnd = NULL, oldhwnd = NULL;
    int x, y, width, height;
    int i;
    while(1)
    //for(int i = 0; i < 50; i++)
    {
        hwnd = GetForegroundWindow();
        if(hwnd != oldhwnd)
        {
            GetWindowRect(hwnd, &rect);
            x = rect.left;
            y = rect.top;
            width = rect.right - x;
            height = rect.bottom - y;
            oldhwnd = hwnd;
        }
        MoveWindow(hwnd, x - 10, y, width, height, TRUE);
        Sleep(5);
        MoveWindow(hwnd, x - 10, y - 10, width, height, TRUE);
        Sleep(5);
        MoveWindow(hwnd, x, y - 10, width, height, TRUE);
        Sleep(5);
        MoveWindow(hwnd, x, y, width, height, TRUE);
        Sleep(5);
    }
    return 0;
}

猜你喜欢

转载自a275909044.iteye.com/blog/1850189