SoFunction
Updated on 2025-04-06

C language realizes automatic window shaking to QQ friends

This article shares the specific code for sending window jitter to QQ friends in C language for your reference. The specific content is as follows

1. First, let’s take a simpler one, shake the current window, the code is as follows:

#include <>
#include <>
int main (int argc, char argv[])
{
 HWND hwnd = NULL;
 int x,y,width,height;
 int i;
 RECT rect;
 hwnd = GetForegroundWindow();//Get the current window GetClientRect(hwnd,&rect);//Get the current window area x = ;
 y = ;
 width =  - x;
 height =  - y;
 if(hwnd != NULL)
 {
 for(i=0;i<50;i++)//Just 50 times {
  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);
  Sleep(2000);//Just shake once every half second }
 }
 return 0;
}

This code can cause the current window to jitter every 2 seconds.

2. Come on another complicated point and automatically send window jitter to specified QQ friends

#include <>
#include <>
int main (int argc, char argv[])
{
 HWND hwnd = NULL;
 RECT rect;
 TCHAR pQQName[20]=TEXT("I'm so frightened");//Friends say that first, you need to display the friend window in the task block 
 hwnd = FindWindow(NULL,pQQName);//Get window if(hwnd!=NULL)
 {
 SetForegroundWindow(hwnd);//Set as front-end window GetWindowRect(hwnd, &rect);
 while(1)
 {
  SetCursorPos(103+,390+);
  mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
  mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
  Sleep(10050);
  hwnd = FindWindow(NULL,pQQName);//Get window  SetForegroundWindow(hwnd);//Set as front-end window  GetWindowRect(hwnd, &rect);
 }
 }
 return 0;
}

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.