Skip to content

Instantly share code, notes, and snippets.

@nazarov-yuriy
Last active Mar 12, 2016
Embed
What would you like to do?
#define WINVER 0x0500
#include <windows.h>
#include <stdio.h>
typedef COLORREF (CALLBACK *ABCPTR)(HDC,int,int);
int main()
{
ABCPTR pGetPixel;
HINSTANCE _hGDI = LoadLibrary("gdi32.dll");
if(_hGDI)
{
pGetPixel = (ABCPTR)GetProcAddress(_hGDI, "GetPixel");
HDC _hdc = GetDC(NULL);
if(_hdc)
{
while(1){
Sleep(1);
POINT _cursor;
GetCursorPos(&_cursor);
COLORREF color1 = (*pGetPixel) (_hdc, 968, 406);
COLORREF color2 = (*pGetPixel) (_hdc, 968, 409);
COLORREF color3 = (*pGetPixel) (_hdc, 968, 412);
if((GetBValue(color1)>GetRValue(color1)+55) || (GetBValue(color2)>GetRValue(color2)+55) || (GetBValue(color3)>GetRValue(color3)+55)){
INPUT ip;
ip.type = INPUT_KEYBOARD;
ip.ki.wScan = 0; // hardware scan code for key
ip.ki.time = 0;
ip.ki.dwExtraInfo = 0;
ip.ki.wVk = 0x20; // virtual-key code for the "a" key
ip.ki.dwFlags = 0; // 0 for key press
SendInput(1, &ip, sizeof(INPUT));
// Release the "A" key
ip.ki.dwFlags = KEYEVENTF_KEYUP; // KEYEVENTF_KEYUP for key release
SendInput(1, &ip, sizeof(INPUT));
Sleep(900);
}
}
}
}
FreeLibrary(_hGDI);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment