Sail丶Man Sail丶Man
只有回忆将化作为丶永恒丨
关注数: 8 粉丝数: 21 发帖数: 568 关注贴吧数: 17
找色 第三个问题~~~~~~~~~~~~~~ 这次仅仅 限制了while(l<3)只循环3次 发现按Y后 鼠标并不会移过去。 但改成while(l<5)只循环5次 按Y后鼠标就会移过去。也就是说找之前找3遍都没找到色 必须找5遍以上才行。为什么? # include <graphics.h> # include <stdio.h> int start(void); void Quit(void); void CaptureDesktop(IMAGE *pimg) {int w = GetSystemMetrics(SM_CXSCREEN) ; int h = GetSystemMetrics(SM_CYSCREEN) ; Resize(pimg, w, h);HDC aa = GetDC(NULL); HDC dstDC = GetImageHDC(pimg); BitBlt(dstDC, 0, 0, w, h, aa, 0, 0, SRCCOPY);} int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {COLORREF cr;cr = start(); initgraph(200,60); TCHAR s2[20]; sprintf(s2, _T("%#x"), cr); TCHAR s1[30]="已确定你要找的颜色值为:"; outtextxy(0, 0, s1); outtextxy(0, 20, s2); TCHAR s[30]="按Y键开始找色,按B键退出"; outtextxy(0, 40, s); int w = GetSystemMetrics(SM_CXSCREEN) ; int h = GetSystemMetrics(SM_CYSCREEN) ; while (true){if (GetAsyncKeyState('Y')) {closegraph();break;}Quit();} int l=0; while (l<3) { l++; IMAGE img; CaptureDesktop(&img); saveimage(_T("f:\\testq1.bmp"), &img); /*initgraph(640, 480);putimage(0, 0, &img);*/ loadimage(&img, "f:\\testq1.bmp"); DWORD* p = GetImageBuffer(&img); POINT point;for(int i = 0; i < w * h; i++) if (p[i] == BGR(cr) ){point.y = i / (w * 1.0); point.x = i - point.y * w ;Sleep(100); SetCursorPos(point.x, point.y);break;} DeleteFile("f:\\testq1.bmp");Quit();}return 0;} int start(void){initgraph(150,80); HDC hdc = GetDC(NULL);COLORREF cr; POINT point;TCHAR s[20];TCHAR s1[20]="横坐标:";TCHAR s2[20]="纵坐标:"; TCHAR s3[20]="颜色值:"; TCHAR s4[30]="按A键确定,按B键退出"; while(true){GetCursorPos(&point); sprintf(s, _T("%05d"), point.x); outtextxy(0, 0, s1);outtextxy(55, 0, s); sprintf(s, _T("%05d"), point.y);outtextxy(0, 20, s2); outtextxy(55, 20, s);Sleep(10); cr = GetPixel(hdc, point.x, point.y); sprintf(s, _T("%#x"), cr);outtextxy(0, 40, s3); outtextxy(55, 40, s);outtextxy(0, 60, s4); if (GetAsyncKeyState('A')){closegraph();ReleaseDC(NULL,hdc);return cr;}Quit();}} void Quit(void){if(GetAsyncKeyState('B')) {if(MessageBox(NULL, "你确定要退出吗?","提示", MB_YESNO) == IDYES) exit(0);}return ;}
找色 第二个问题~~~~~~~~~~~~~~~~~~~~~~~ 这次仅仅去掉了saveimage(_T("f:\\testq1.bmp"), &img);loadimage(&img, "f:\\testq1.bmp");程序就识别不了这个img 就找不到色 ,就是 按Y 后 没反应了。 —————————————————————————— # include <graphics.h> # include <stdio.h> int start(void); void Quit(void); void CaptureDesktop(IMAGE *pimg) {int w = GetSystemMetrics(SM_CXSCREEN) ; int h = GetSystemMetrics(SM_CYSCREEN) ; Resize(pimg, w, h);HDC aa = GetDC(NULL); HDC dstDC = GetImageHDC(pimg); BitBlt(dstDC, 0, 0, w, h, aa, 0, 0, SRCCOPY);} int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {COLORREF cr;cr = start(); initgraph(200,60); TCHAR s2[20]; sprintf(s2, _T("%#x"), cr); TCHAR s1[30]="已确定你要找的颜色值为:"; outtextxy(0, 0, s1); outtextxy(0, 20, s2); TCHAR s[30]="按Y键开始找色,按B键退出"; outtextxy(0, 40, s); int w = GetSystemMetrics(SM_CXSCREEN) ; int h = GetSystemMetrics(SM_CYSCREEN) ; while (true){if (GetAsyncKeyState('Y')) {closegraph();break;}Quit();} while (true) {IMAGE img; CaptureDesktop(&img); /*initgraph(640, 480);putimage(0, 0, &img);*/ DWORD* p = GetImageBuffer(&img); POINT point;for(int i = 0; i < w * h; i++) if (p[i] == BGR(cr) ){point.y = i / (w * 1.0); point.x = i - point.y * w ;Sleep(100); SetCursorPos(point.x, point.y);break;} DeleteFile("f:\\testq1.bmp");Quit();}return 0;} int start(void){initgraph(150,80); HDC hdc = GetDC(NULL);COLORREF cr; POINT point;TCHAR s[20];TCHAR s1[20]="横坐标:";TCHAR s2[20]="纵坐标:"; TCHAR s3[20]="颜色值:"; TCHAR s4[30]="按A键确定,按B键退出"; while(true){GetCursorPos(&point); sprintf(s, _T("%05d"), point.x); outtextxy(0, 0, s1);outtextxy(55, 0, s); sprintf(s, _T("%05d"), point.y);outtextxy(0, 20, s2); outtextxy(55, 20, s);Sleep(10); cr = GetPixel(hdc, point.x, point.y); sprintf(s, _T("%#x"), cr);outtextxy(0, 40, s3); outtextxy(55, 40, s);outtextxy(0, 60, s4); if (GetAsyncKeyState('A')){closegraph();ReleaseDC(NULL,hdc);return cr;}Quit();}} void Quit(void){if(GetAsyncKeyState('B')) {if(MessageBox(NULL, "你确定要退出吗?","提示", MB_YESNO) == IDYES) exit(0);}return ;}
找色 第一个问题~~~~~~~~~~~~~~~~~~~~ while(true){IMAGE img; 去掉后 只找一次色 按逻辑看应该可以 但实验证明 这一次的桌面截图是全黑的。为什么?截图是黑的就无法找色了。当然按Y之前程序正常运行,因为程序还没跑到这里来。 这次代码 我已经去掉while() 去掉DeleteFile("f:\\testq1.bmp");在f盘 你就能找到这一次的截图效果 是全黑的。又加上了initgraph(640, 480);putimage(0, 0, &img);多了while(!(GetAsyncKeyState(VK_ESCAPE) & 0x8000))你也会看到这一次的截图 是全黑的。 ———————————————————————————————— # include <graphics.h> # include <stdio.h> int start(void); void Quit(void); void CaptureDesktop(IMAGE *pimg){int w = GetSystemMetrics(SM_CXSCREEN) ;int h = GetSystemMetrics(SM_CYSCREEN) ;Resize(pimg, w, h);HDC aa = GetDC(NULL);HDC dstDC = GetImageHDC(pimg);BitBlt(dstDC, 0, 0, w, h, aa, 0, 0, SRCCOPY);}int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){COLORREF cr;cr = start();initgraph(200,60);TCHAR s2[20];sprintf(s2, _T("%#x"), cr);TCHAR s1[30]="已确定你要找的颜色值为:";outtextxy(0, 0, s1);outtextxy(0, 20, s2);TCHAR s[30]="按Y键开始找色,按B键退出";outtextxy(0, 40, s);int w = GetSystemMetrics(SM_CXSCREEN) ;int h = GetSystemMetrics(SM_CYSCREEN) ;while (true){if (GetAsyncKeyState('Y')){closegraph();break;}Quit();} IMAGE img;CaptureDesktop(&img);saveimage(_T("f:\\testq1.bmp"), &img);initgraph(640, 480);putimage(0, 0, &img);loadimage(&img, "f:\\testq1.bmp");DWORD* p = GetImageBuffer(&img);POINT point;for(int i = 0; i < w * h; i++)if (p[i] == BGR(cr) ){point.y = i / (w * 1.0);point.x = i - point.y * w ;Sleep(100);SetCursorPos(point.x, point.y);break;};Quit();while(!(GetAsyncKeyState(VK_ESCAPE) & 0x8000))Sleep(20); return 0;}int start(void){initgraph(150,80);HDC hdc = GetDC(NULL);COLORREF cr;POINT point;TCHAR s[20];TCHAR s1[20]="横坐标:";TCHAR s2[20]="纵坐标:";TCHAR s3[20]="颜色值:";TCHAR s4[30]="按A键确定,按B键退出";while(true){GetCursorPos(&point);sprintf(s, _T("%05d"), point.x);outtextxy(0, 0, s1);outtextxy(55, 0, s);sprintf(s, _T("%05d"), point.y);outtextxy(0, 20, s2);outtextxy(55, 20, s);Sleep(10);cr = GetPixel(hdc, point.x, point.y);sprintf(s, _T("%#x"), cr);outtextxy(0, 40, s3);outtextxy(55, 40, s);outtextxy(0, 60, s4);if (GetAsyncKeyState('A')){closegraph();ReleaseDC(NULL,hdc);return cr;}Quit();}}void Quit(void){if(GetAsyncKeyState('B')){if(MessageBox(NULL, "你确定要退出吗?","提示", MB_YESNO) == IDYES)exit(0);}return ;} ——————————————————————————————
自动跳舞 外 挂~~!!!! 主要通过 找色实现,程序很简单可自己看懂。 ———————————————————————— 大家可以先玩一下这个小游戏:http://tieba.baidu.com/mo/q/checkurl?url=http%3A%2F%2Fzy.anjian.com%2Flab%2Fcontent_01.html&urlrefer=44a5f28aa92fd49be72afe121aa0f729 ———————————————————————— 以下是我为这个程序写的一个外挂: (按Esc可退出)若一次不成功可多试几次。 ———————————————————————— # include <graphics.h> POINT ZhaoSe(COLORREF c); void CaptureDesktop(IMAGE *); void Quit(void); int DianJi(int,int,int,int,int,int,int,int); int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {while (true) {DianJi(324,117, 322,74 , 335,88, 293,86); DianJi(223,117 , 221,74, 234,88, 192,86); DianJi(122,117, 120,74, 133,88, 91,86 ); if (!(DianJi(21 ,117, 19 , 74, 32 ,88, (-9) ,86))) {keybd_event(32,0,0,0);keybd_event(32,0,KEYEVENTF_KEYUP,0);//Spacebar }Sleep(1350); Quit(); /*while(GetAsyncKeyState(VK_ESCAPE)){Sleep(20);exit(0);}*/} return 0;} void CaptureDesktop(IMAGE *pimg) {int w = GetSystemMetrics(SM_CXSCREEN) ; int h = GetSystemMetrics(SM_CYSCREEN) ; Resize(pimg, w, h);HDC aa = GetDC(NULL); HDC dstDC = GetImageHDC(pimg); BitBlt(dstDC, 0, 0, w, h, aa, 0, 0, SRCCOPY);} POINT ZhaoSe(COLORREF c) {POINT point;IMAGE img; int w = GetSystemMetrics(SM_CXSCREEN) ; int h = GetSystemMetrics(SM_CYSCREEN) ; while(true) {CaptureDesktop(&img);saveimage(_T("f:\\testq1.bmp"), &img); loadimage(&img, "f:\\testq1.bmp"); DWORD* p = GetImageBuffer(&img); for(int i = 0; i < w * h; i++)if (p[i] == BGR(c) ) {point.y = i / (w * 1.0); point.x = i - point.y * w ; break;}DeleteFile("f:\\testq1.bmp"); if (point.x>=0 && point.y>=0)break;}return point;} int DianJi(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) {POINT point;point = ZhaoSe(0xa57836); HDC hdc = GetDC(NULL); COLORREF c;COLORREF c1; COLORREF c2;COLORREF c3; c = GetPixel(hdc, point.x - x1, point.y - y1); c1 = GetPixel(hdc, point.x - x2, point.y - y2); c2 = GetPixel(hdc, point.x - x3, point.y - y3); c3 = GetPixel(hdc, point.x - x4, point.y - y4); if (0x3399ff == c) {keybd_event(40,0,0,0);keybd_event(40,0,KEYEVENTF_KEYUP,0);//下 }if (0x3399ff == c1){keybd_event(38,0,0,0);keybd_event(38,0,KEYEVENTF_KEYUP,0);//上 }if (0x3399ff == c2){keybd_event(39,0,0,0);keybd_event(39,0,KEYEVENTF_KEYUP,0);//右 }if (0x3399ff == c3){keybd_event(37,0,0,0);keybd_event(37,0,KEYEVENTF_KEYUP,0);//左 }return 0;} void Quit(void) {if(GetAsyncKeyState(VK_ESCAPE)){if(MessageBox(NULL, "你确定要退出吗?","提示", MB_YESNO) == IDYES)exit(0);} return ;} ——————————————————————————————————
自动找点 外 挂~~!!!! 找色这个工具真的太强大了,用这个可变相的实现一个网页游戏的自动打怪。 ———————————————————————— 大家先玩一下这个小游戏:http://tieba.baidu.com/mo/q/checkurl?url=http%3A%2F%2Fzy.anjian.com%2Flab%2Fcontent_07.html&urlrefer=0499b908bb339559142b14095159475e 看你能打到第几关。 以下是这个小游戏的 外挂。按Esc 可退出程序。程序很简单可自己看懂。 ———————————————————————— # include <graphics.h> POINT ZhaoSe(COLORREF c);//找色 void CaptureDesktop(IMAGE *);//配合上面那个函数构成找色工具。 void dianji(COLORREF ); void Quit(void); int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { while (true) { dianji(0x2b2bc4);//红 dianji(0xc6c66a);//天蓝色 dianji(0x319ce4);//黄色 dianji(0x8327c0);//紫色 dianji(0xcf4f4f);//蓝色 dianji(0x1db6b6);//柠檬色 Quit(); } return 0;} void CaptureDesktop(IMAGE *pimg) { int w = GetSystemMetrics(SM_CXSCREEN) ; int h = GetSystemMetrics(SM_CYSCREEN) ; Resize(pimg, w, h);HDC aa = GetDC(NULL); HDC dstDC = GetImageHDC(pimg); BitBlt(dstDC, 0, 0, w, h, aa, 0, 0, SRCCOPY); } POINT ZhaoSe(COLORREF c) { POINT point; int w = GetSystemMetrics(SM_CXSCREEN) ; int h = GetSystemMetrics(SM_CYSCREEN) ; IMAGE img;CaptureDesktop(&img); saveimage(_T("f:\\testq1.bmp"), &img); loadimage(&img, "f:\\testq1.bmp"); DWORD* p = GetImageBuffer(&img); for(int i = 0; i < w * h; i++) if (p[i] == BGR(c) ) { point.y = i / (w * 1.0); point.x = i - point.y * w ; break; } DeleteFile("f:\\testq1.bmp"); return point; } void dianji(COLORREF c) { POINT point;point = ZhaoSe(c); if (point.x >= 0 && point.y >= 0) { SetCursorPos(point.x, point.y); mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 ); }} void Quit(void) { if(GetAsyncKeyState(VK_ESCAPE)) { if(MessageBox(NULL, "你确定要退出吗?","提示", MB_YESNO) == IDYES) exit(0); } return ;} ——————————————————————————————————
自动补血 外 挂~~!!!! 呵呵, 自从上回写出了找色 这个程序 真的发现它是越来越强大了。 —————————————————————— 大家先玩玩这个小游戏。手速要快的补血小游戏。 http://tieba.baidu.com/mo/q/checkurl?url=http%3A%2F%2Fzy.anjian.com%2Flab%2Fcontent_02.html&urlrefer=37021b4662eddfa5ea0441566530c8b9 —————————————————————— 以下是我为这个小游戏写的一个外挂。Esc可退出程序。 # include <graphics.h> # include <stdio.h> POINT ZhaoSe(COLORREF c);//找色要配合下面那个函数 void CaptureDesktop(IMAGE *);//找色工具配合这个一起用 构成 找色工具 void Quit(void);//退出程序 int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)//主函数 { POINT point; COLORREF c; COLORREF c1; COLORREF c2; COLORREF c3; COLORREF c4; COLORREF c5; HDC hdc = GetDC(NULL);//获取桌面hdc while (true) { point = ZhaoSe(0x81511f); c = GetPixel(hdc, point.x - 312, point.y - 335);//血低于这个点时 按q c1 = GetPixel(hdc, point.x - 312, point.y - 291); c2 = GetPixel(hdc, point.x - 353, point.y - 108); c3 = GetPixel(hdc, point.x - 265, point.y - 108); c4 = GetPixel(hdc, point.x - 100, point.y - 126); c5 = GetPixel(hdc, point.x - 15, point.y - 120);//以上同理 if (0xaeaeae == c)//空血条的背景颜色 ,血低于这个点时 按q 以下同理。 { keybd_event(81,0,0,0); keybd_event(81,0,KEYEVENTF_KEYUP,0); } if (0xaeaeae == c1) { keybd_event(87,0,0,0); keybd_event(87,0,KEYEVENTF_KEYUP,0); } if (0xffffff == c2) { keybd_event(65,0,0,0); keybd_event(65,0,KEYEVENTF_KEYUP,0); } if (0xffffff == c3) { keybd_event(83,0,0,0); keybd_event(83,0,KEYEVENTF_KEYUP,0); } if (0xe6e6e6 == c4) { keybd_event(68,0,0,0); keybd_event(68,0,KEYEVENTF_KEYUP,0); } if (0xe6e6e6 == c5) { keybd_event(70,0,0,0); keybd_event(70,0,KEYEVENTF_KEYUP,0); }Quit(); /*while(GetAsyncKeyState(VK_ESCAPE)){Sleep(20);exit(0);}*/} return 0;} void CaptureDesktop(IMAGE *pimg) { int w = GetSystemMetrics(SM_CXSCREEN) ; int h = GetSystemMetrics(SM_CYSCREEN) ; Resize(pimg, w, h); HDC aa = GetDC(NULL); HDC dstDC = GetImageHDC(pimg); BitBlt(dstDC, 0, 0, w, h, aa, 0, 0, SRCCOPY);} POINT ZhaoSe(COLORREF c) {POINT point; int w = GetSystemMetrics(SM_CXSCREEN) ; int h = GetSystemMetrics(SM_CYSCREEN) ; IMAGE img; CaptureDesktop(&img); saveimage(_T("f:\\testq1.bmp"), &img); //这部不是多余的,不要会出莫名其妙的问题。 loadimage(&img, "f:\\testq1.bmp");//这部不是多余的,不要会出莫名其妙的问题。 DWORD* p = GetImageBuffer(&img); for(int i = 0; i < w; i++) { for(int j = 0; j < h; j++)if (p[j * w + i] == BGR(c) ) { point.x = i; point.y = j; break; } if (point.x>=0 && point.y>=0) break; } DeleteFile("f:\\testq1.bmp"); return point; } void Quit(void) { if(GetAsyncKeyState(VK_ESCAPE)) { if(MessageBox(NULL, "你确定要退出吗?","提示", MB_YESNO) == IDYES) exit(0); } return ;} ————————————————————————————- 补血 自动 按键非常好写,但最大的问题就是 每个人打开的窗口位置不同, 依然要找准每罐血要到底时就非常难了,找色就很好地解决了这个问题, 因为 它用的不是绝对位置,而是相对位置,例如这个游戏中我找的参考点就是 按键精灵这几个字。 我先用找色工具找到 “按”字 的左上角坐标 再相对于这个坐标来决定某个(血快要完点)点位置比如point.x - 312这样无论你窗口怎么动 都可以找准这个点了。 我也不知道你们听懂没,程序很简单可以自己看懂。 呵呵,我觉得EasyX完全可以考虑把这个找色工具列入教程了~~。 说真心话这个工具用处真的太大了。
1 下一页