#include <stdio.h>
#include <windows.h>
int main()
{
RECT rect;//RECT是一个矩形结构体,相当于保存矩形边框的四个坐标
HWND hwnd = NULL, oldhwnd = NULL;//两个窗口句柄
int x, y, width, height;//保存窗口横纵坐标及高度,宽度
int i;
for (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);
}
system("pause");
return 0;
}
#include <stdio.h>
#include <windows.h>
int main()
{
RECT rect;//RECT是一个矩形结构体,相当于保存矩形边框的四个坐标
HWND hwnd = NULL, oldhwnd = NULL;//两个窗口句柄
int x, y, width, height;//保存窗口横纵坐标及高度,宽度
int i;
for (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);
}
system("pause");
return 0;
}