#include"stdafx.h"#include<stdio.h>#include<Windows.h>intMain () {intShake_time = -;//sleep time, 5 milliseconds intShake_distance =Ten;//10 pixels moved.Rect rect;//A rect is a rectangular structure, equivalent to a four-edge coordinate that holds a rectangle .HWND window = null, Oldwindow = NULL;//Two window handles intx, y, width, height;//variable to hold the window's horizontal and width and height inti; //Shake It 50 times. for(i =0; I <Ten; i++) {window= GetForegroundWindow ();//get the active window if(Window! =Oldwindow) { //gets the location of the specified windowGetWindowRect (window, &rect); X=Rect.left; Y=Rect.top; Width= Rect.right-x; Height= Rect.bottom-y; Oldwindow=window; } movewindow (window, x-Shake_distance, y, width, height, TRUE);//move the window, move the 10 pixels to the left,Sleep (Shake_time);//sleep time milliseconds, thread hibernationMoveWindow (window, x-shake_distance, y-shake_distance, width, height, TRUE); Sleep (Shake_time); MoveWindow (window, x, y-shake_distance, width, height, TRUE); Sleep (Shake_time); MoveWindow (window, x, y, width, height, TRUE); Sleep (Shake_time); } return 0;}
Using C language to realize window jitter