C++自创钉钉直播刷赞器(二)

上次的钉钉刷赞器真的很受大家欢迎,可能是因为特殊时期的原因…

但此程序还是有不足!!

在我朋友的强烈要求下,我添加了半途取消功能。
还是上源码:

#include 
#include 
#include 
#include 
#include 
#include 
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME)& 0x8000 ?1:0))
using namespace std;
void SetSize(unsigned uCol,unsigned uLine)
{
 char cmd[64];
 sprintf(cmd,"mode con cols=%d lines=%d",uCol,uLine);
 system(cmd);
}
template <typename _T>
_T pow2(_T x)
{
    return x * x;
}
DOUBLE Distance(POINT &a,POINT &b) //两点之间的距离 
{
 return sqrt(pow2(a.x - b.x) + pow2(a.y - b.y));
}
VOID KeyPR(BYTE bVk) { //Press && Release
 keybd_event(bVk,0,0,0);
 keybd_event(bVk,0,2,0);
}
VOID Click()
{
 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
}
int main()
{
    int i=0;
 int n=100;  //次数 
 int speed=64; //每秒赞数 
 int ch;
POINT pt,pt2; //鼠标坐标 
LONG maxDsc=30; //鼠标偏移极限距离 
 SetConsoleTitle("钉钉刷赞器");
 SetSize(35,20); 
 flush:
 ch=IDOK; //懒得用do-while了↓
 while(FindWindow("StandardFrame",NULL) == NULL && ch == IDOK){
  ch = MessageBox(GetConsoleWindow(),"没有打开钉钉直播窗口。\n请先打开然后按确定。","提示",MB_ICONEXCLAMATION|MB_OKCANCEL);
 }
 if(ch == IDCANCEL || ch == IDCLOSE)
 {
  cout<<"已取消...";
  Sleep(500);
  exit(0);
 }
 do
 {
  cout<<"输入每秒赞数(1~1000):";
  cin>>speed;
  if(speed < 1 || speed > 1000){
     cout<<"\n不符合范围(1~1000)!\n";
        }
 }while(speed < 1 || speed > 1000);
 do
 {
  cout<<"\n输入次数:";
  cin>>n;
  if(n < 0){
     cout<<"\n不符合范围(>0)!\n";
        }
 }while(n < 0);
 cout<<"\n\n准备就绪。\n马上隐藏此窗口,几秒后\n请在赞上单击鼠标开始刷赞...\n";
 Sleep(3000);
 i=0;
 ShowWindow(GetConsoleWindow(),SW_HIDE);
 if(FindWindow("Msgbox",NULL) != NULL)
     KeyPR(VK_SPACE);
 Sleep(1000);
 while(!KEY_DOWN(MOUSE_MOVED));
GetCursorPos(&pt);
  do{
   if(FindWindow("Msgbox",NULL) == NULL)
      Click();
        else
      KeyPR(VK_SPACE);
   Sleep((DWORD)1000.0 / speed);
   i++;
   if((i * 5) % speed == 0) //每秒检测鼠标五次 
    {
         GetCursorPos(&pt2); //再取一次 
         if(Distance(pt,pt2) > maxDsc)
    { //临时取消
   //就不跳出控制台了,直接退出,这样安全。:)
    exit(-1); 
    } 
  }
  }while(i <= n);
  Sleep(1000);
  if(FindWindow("Msgbox",NULL) != NULL)
     KeyPR(VK_SPACE);
     ShowWindow(GetConsoleWindow(),SW_SHOW);
     cout<<"\n刷赞成功!\n是否继续?(按 1:是/0:否) ";
     int ch2;
     againp:
     ch2=getch();
     switch(ch2)
     {
      case '1':
   cout<<endl;
   system("cls");
   goto flush;
   break;
      case '0':
		exit(0);
   break;
      default:
   goto againp;
   break;
  }
  return 0;
} 

我在里面加了检测鼠标坐标算差值,经调试 30 为最佳值.
取消方法:
很简单,不想再刷时把鼠标狠狠一移就行了。

(警告:千万不要向左移,不要按到“申请连麦”按钮!!!!)
升级版下载地址:https://download.csdn.net/download/cjz2005/12188130

你可能感兴趣的:(C++自创钉钉直播刷赞器(二))