level 8
Sail丶Man
楼主
用这个 程序 用来 启动某个 游戏很好~
——————————————————
程序是:在窗口内找到随机出现的红点并把鼠标移过去。
在程序运行的瞬间请不要移动鼠标否则会破坏效果。
红点只有一个像素,要仔细看。
——————————————————
# include <graphics.h>
# include <conio.h>
# include <time.h>
int main(void)
{int cx = GetSystemMetrics(SM_CXFIXEDFRAME);
int cy = GetSystemMetrics(SM_CYFIXEDFRAME) + GetSystemMetrics(SM_CYCAPTION);
initgraph(640,480);
HWND hwnd = GetHWnd();
DWORD* p = GetImageBuffer();
POINT point;srand( (unsigned)time( NULL ) );
putpixel(rand() % 640, rand() % 480 ,RED);
RECT rect;for(int i = 0; i < 640 * 480; i++)
if (p[i] == BGR(RED) )
{point.y = i / (640 * 1.0);
point.x = i - point.y * 640 ;
GetWindowRect(hwnd,&rect);
SetCursorPos(cx + rect.left + point.x, cy + rect.top + point.y);
} getch();
return 0;}
可以多运行几次试试效果。
2013年09月11日 14点09分
1
——————————————————
程序是:在窗口内找到随机出现的红点并把鼠标移过去。
在程序运行的瞬间请不要移动鼠标否则会破坏效果。
红点只有一个像素,要仔细看。
——————————————————
# include <graphics.h>
# include <conio.h>
# include <time.h>
int main(void)
{int cx = GetSystemMetrics(SM_CXFIXEDFRAME);
int cy = GetSystemMetrics(SM_CYFIXEDFRAME) + GetSystemMetrics(SM_CYCAPTION);
initgraph(640,480);
HWND hwnd = GetHWnd();
DWORD* p = GetImageBuffer();
POINT point;srand( (unsigned)time( NULL ) );
putpixel(rand() % 640, rand() % 480 ,RED);
RECT rect;for(int i = 0; i < 640 * 480; i++)
if (p[i] == BGR(RED) )
{point.y = i / (640 * 1.0);
point.x = i - point.y * 640 ;
GetWindowRect(hwnd,&rect);
SetCursorPos(cx + rect.left + point.x, cy + rect.top + point.y);
} getch();
return 0;}
可以多运行几次试试效果。