#Include #Include #Include #Include int getcolor(void); void SendInput(char key_value); void press(char key_value); BYTE scan_code(DWORD pKey) { const DWORD result = MapVirtualKey(pKey, MAPVK_VK_TO_VSC); return static_cast(result); } void press_key(DWORD pKey) { keybd_event(static_cast(pKey), scan_code(pKey), 0, 0); } void release_key(DWORD pKey) { keybd_event(static_cast(pKey), scan_code(pKey), KEYEVENTF_KEYUP, 0); } int main(int argc, char** argv) { HDC hdc; int color; FILETIME beg,end; int dur; char buffer[30]="颜色正常"; while(1) { /* if(!KEYDOWN('A')) { FILETIME beg,end; hdc = GetDC(0); char buffer[30]; color= GetPixel(hdc, 872,1011); keybd_event('E',(BYTE)0, 0 ,0); keybd_event('E', (BYTE)0, KEYEVENTF_KEYUP,0); sendinput('T'); sprintf(buffer,"0x%x",color); MessageBox(0,buffer,"color的值",MB_OK); Sleep(1000); } */ if(!KEYDOWN('R')) { press('T'); } if(!KEYDOWN('E')) { //MessageBox(0,buffer,"color的值",MB_OK); hdc = GetDC(0); color= GetPixel(hdc, 872,1011); if(color==0x622f65) //颜色正常时候 { //MessageBox(0,buffer,"color的值",MB_OK); //SendInput('T'); press('T'); GetSystemTimeAsFileTime(&beg); do { hdc = GetDC(0); color= GetPixel(hdc, 872,1011); GetSystemTimeAsFileTime(&end); dur = 100*(end.dwLowDateTime-beg.dwLowDateTime)/1000000; }while(dur