d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Need Some C++ Help With A Very Simple Function
Add Reply New Topic New Poll
Member
Posts: 11,477
Joined: May 28 2006
Gold: Locked
Trader: Scammer
Warn: 20%
Oct 27 2016 01:40am
so ive got this function i wrote to do what autoits pixelsearch function would do basiclly and it is slow AF i mean several seconds to scan a small block...
would prefer it to be able to scan entire screen in under a second

heres what i have so far any help would be greatly appreciated (ps im real new with c++ and im sure my code is hideouse, no need to tell me about it :P )

Code
#include <windows.h>
#include <stdio.h>
#include "resource.h"
#include <iostream>
using namespace std;

int H = 0; int V = 0;
int PCC;
int PixelSearch(int X1, int Y1, int X2, int Y2, int sR, int sG, int sB, int Variation) {
bool PZD = false;
for (int CX = X1; CX <= X2; CX++) {
for (int CY = Y1; CY <= Y2; CY++) {
HDC c = GetDC(0); COLORREF scolor = GetPixel(c,CX,CY); ReleaseDC(0,c);
DWORD cR = BYTE GetRValue(scolor); DWORD cG = BYTE GetGValue(scolor); DWORD cB = BYTE GetBValue(scolor);
if (((cR < (sR-Variation)) || (cR > (sR + Variation))) && ((cG<(sG-Variation)) || (cG>(sG + Variation))) &&
((cB < (sB - Variation)) || (cB > (sB + Variation)))) { }
else { PZD = true; }
}
}
return PZD;
}
int main() {
bool PSEARCH;
PSEARCH = PixelSearch(10,10,25,25,0,0,0,1);
if (PSEARCH == true) { cout << "Color Found" << endl; }
else { cout << "No Match" << endl; }
return 0;
}



This post was edited by Norax912 on Oct 27 2016 01:43am
Member
Posts: 3,939
Joined: Feb 1 2013
Gold: 2,749.09
Warn: 20%
Member
Posts: 11,477
Joined: May 28 2006
Gold: Locked
Trader: Scammer
Warn: 20%
Oct 27 2016 02:17am
Since AutoIt can be used for malicious things, as well as third party programs, it's against the rules to:
Discuss the program
Request download links for it
Anything related to the program (including scripts, advice, etc.)

This applies to any other program similar to AutoIt.

Including, but not limited to:
Automated mouse clickers
Automated key movements
Anything that is able to delete or move a directory/folder on another users device

Please use common sense when it comes to this.

If a program can be used to do the following, then please DO NOT post about it:
Automate game play
Violate the terms of service of games
Be used for malicious things



yeah none of this applies to what i posted i simply stated it was similar to an autoit function for reference... please dont posst on my thread without taking the time to read more then the first few words...
Member
Posts: 3,939
Joined: Feb 1 2013
Gold: 2,749.09
Warn: 20%
Oct 27 2016 03:37am
Quote (Norax912 @ Oct 27 2016 01:17am)
yeah none of this applies to what i posted i simply stated it was similar to an autoit function for reference... please dont posst on my thread without taking the time to read more then the first few words...


Even if it doesn't apply, your question is stupid and you'll be lucky if anyone else takes the time to help. You obviously need to spend some time learning to program before you are ready for this task, go read a few books.

I'll give you one hint: get a local copy of the pixels with BitBlt or something instead of calling GetPixel in an inner loop.
Member
Posts: 11,477
Joined: May 28 2006
Gold: Locked
Trader: Scammer
Warn: 20%
Oct 27 2016 03:57am
Quote (boxboxbox @ Oct 27 2016 04:37am)
Even if it doesn't apply, your question is stupid and you'll be lucky if anyone else takes the time to help. You obviously need to spend some time learning to program before you are ready for this task, go read a few books.

I'll give you one hint: get a local copy of the pixels with BitBlt or something instead of calling GetPixel in an inner loop.


i dont believe i even phrased a question and your kind of being arrogant... bitblt is exactly the direction i wanted to be guided and i thank you, just maybe next time start and finish with your hint :)
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll