Results 1 to 9 of 9
  1. #1
    258456's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    ghjghj
    Posts
    1,222
    Reputation
    18
    Thanks
    300
    My Mood
    Relaxed

    [HELP (as usual)] Any faster Method than GetPixel()?

    Well, as you can see from the title i am having major problems with GetPixel(). It's the worst method to use if you want to scan the whole screen. I have made a pixel aimbot lately but it just won't scan the screen fast enough. I researched the topic and found out about multi threading. So i multithreaded, oh i multi threaded the crap out of my program, here is the full source code of the program so that you don't think i am just bluffing. [Nevermind it won't let me post it cuz too many words, i will upload it to MPGH].


    I am pretty sure i went overboard with multi threading, but even with that it's not scanning fast enough. I even made it skip every other pixel and still not fast enough. If anyone has a better way please tell me. Thanks.

  2. The Following User Says Thank You to 258456 For This Useful Post:

    lbw0514 (11-13-2013)

  3. #2
    'Bruno's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Portugal
    Posts
    2,883
    Reputation
    290
    Thanks
    1,036
    My Mood
    Busy
    I don't know what code you have there but..

    Try multi-threading just small amounts of the screen in each thread.
    Don't scan every pixel, jump a few... And if you find a certain pixel, dont RE-scan the whole screen again, but just the area around that pixel.
    Light travels faster than sound. That's why most people seem bright until you hear them speak.

  4. #3
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    DirectX is always faster. Per-pixel scanning is impossibly slow. Your much better off temporarily storing the entire image in memory, and reading it there rather then making thousands of API calls per frame, which impossibly slow.

    API calls are notoriously slow in general, but screen GUI function are even slower, since Hardware components such as the screen buffer, must go through the kernel level due to the HAL (Hardware Abstraction Layer). DirectX is the only way I know to directly access the screen buffer.

    So best solution would be either to access the entire screen in one call rather then calling a thousand times for each pixel, and using DirectX to check the screen buffer rather then the Windows GUI.

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

  5. The Following User Says Thank You to why06 For This Useful Post:

    258456 (11-09-2010)

  6. #4
    258456's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    ghjghj
    Posts
    1,222
    Reputation
    18
    Thanks
    300
    My Mood
    Relaxed
    i don't really have experience in directx so i don't know what function to use. If you could just tell me the function i guess that would be enough and i can just figure it out from there. Thanks for your reply

  7. #5
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    Save a frame as a bmp and look through the pixels using a loop.

  8. The Following User Says Thank You to Void For This Useful Post:

    258456 (11-09-2010)

  9. #6
    Auxilium's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,518
    Reputation
    445
    Thanks
    609
    My Mood
    Happy
    Quote Originally Posted by Void View Post
    Save a frame image as a bmp format and look through the pixels using a loop.
    Seems laggy.

  10. #7
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    Quote Originally Posted by Koreans View Post


    Seems laggy.
    Calling a function once and scanning using a loop and if statements is better than calling a function 1024x768 times. \:

  11. The Following 4 Users Say Thank You to Void For This Useful Post:

    258456 (11-09-2010),Hell_Demon (11-08-2010),Jason (11-07-2010),why06 (11-08-2010)

  12. #8
    -Raz0r-'s Avatar
    Join Date
    Aug 2010
    Gender
    male
    Location
    Australia
    Posts
    117
    Reputation
    15
    Thanks
    38
    My Mood
    Lurking
    derp
    /tooshort
    Languages: C, C++, x86 ASM, PHP, Lua

  13. #9
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    Quote Originally Posted by 258456 View Post
    i don't really have experience in directx so i don't know what function to use. If you could just tell me the function i guess that would be enough and i can just figure it out from there. Thanks for your reply
    It depends on the game really, for exactly what you want to do. I don't want to tell you a DirectX method for a OpenGL game, or Use OpenGL when its a Browser game using Windows GUI, etc.

    EDIT: Okay I did a bit of googling and found exactly what your looking for:

    THis is where the magic happens GetDIBits
    Code:
    int CaptureAnImage(HWND hWnd)
    {
        HDC hdcScreen;
        HDC hdcWindow;
        HDC hdcMemDC = NULL;
        HBITMAP hbmScreen = NULL;
        BITMAP bmpScreen;
    
        // Retrieve the handle to a display device context for the client 
        // area of the window. 
        hdcScreen = GetDC(NULL);
        hdcWindow = GetDC(hWnd);
    
        // Create a compatible DC which is used in a BitBlt from the window DC
        hdcMemDC = CreateCompatibleDC(hdcWindow); 
    
        if(!hdcMemDC)
        {
            MessageBox(hWnd, L"CreateCompatibleDC has failed",L"Failed", MB_OK);
            goto done;
        }
    
        // Get the client area for size calculation
        RECT rcClient;
        GetClientRect(hWnd, &rcClient);
    
        //This is the best stretch mode
        SetStretchBltMode(hdcWindow,HALFTONE);
    
        //The source DC is the entire screen and the destination DC is the current window (HWND)
        if(!StretchBlt(hdcWindow, 
                   0,0, 
                   rcClient.right, rcClient.bottom, 
                   hdcScreen, 
                   0,0,
                   GetSystemMetrics (SM_CXSCREEN),
                   GetSystemMetrics (SM_CYSCREEN),
                   SRCCOPY))
        {
            MessageBox(hWnd, L"StretchBlt has failed",L"Failed", MB_OK);
            goto done;
        }
        
        // Create a compatible bitmap from the Window DC
        hbmScreen = CreateCompatibleBitmap(hdcWindow, rcClient.right-rcClient.left, rcClient.bottom-rcClient.top);
        
        if(!hbmScreen)
        {
            MessageBox(hWnd, L"CreateCompatibleBitmap Failed",L"Failed", MB_OK);
            goto done;
        }
    
        // Select the compatible bitmap into the compatible memory DC.
        SelectObject(hdcMemDC,hbmScreen);
        
        // Bit block transfer into our compatible memory DC.
        if(!BitBlt(hdcMemDC, 
                   0,0, 
                   rcClient.right-rcClient.left, rcClient.bottom-rcClient.top, 
                   hdcWindow, 
                   0,0,
                   SRCCOPY))
        {
            MessageBox(hWnd, L"BitBlt has failed", L"Failed", MB_OK);
            goto done;
        }
    
        // Get the BITMAP from the HBITMAP
        GetObject(hbmScreen,sizeof(BITMAP),&bmpScreen);
         
        BITMAPFILEHEADER   bmfHeader;    
        BITMAPINFOHEADER   bi;
         
        bi.biSize = sizeof(BITMAPINFOHEADER);    
        bi.biWidth = bmpScreen.bmWidth;    
        bi.biHeight = bmpScreen.bmHeight;  
        bi.biPlanes = 1;    
        bi.biBitCount = 32;    
        bi.biCompression = BI_RGB;    
        bi.biSizeImage = 0;  
        bi.biXPelsPerMeter = 0;    
        bi.biYPelsPerMeter = 0;    
        bi.biClrUsed = 0;    
        bi.biClrImportant = 0;
    
        DWORD dwBmpSize = ((bmpScreen.bmWidth * bi.biBitCount + 31) / 32) * 4 * bmpScreen.bmHeight;
    
        // Starting with 32-bit Windows, GlobalAlloc and LocalAlloc are implemented as wrapper functions that 
        // call HeapAlloc using a handle to the process's default heap. Therefore, GlobalAlloc and LocalAlloc 
        // have greater overhead than HeapAlloc.
        HANDLE hDIB = GlobalAlloc(GHND,dwBmpSize); 
        char *lpbitmap = (char *)GlobalLock(hDIB);    
    
        // Gets the "bits" from the bitmap and copies them into a buffer 
        // which is pointed to by lpbitmap.
        GetDIBits(hdcWindow, hbmScreen, 0,
            (UINT)bmpScreen.bmHeight,
            lpbitmap,
            (BITMAPINFO *)&bi, DIB_RGB_COLORS);
    
        // A file is created, this is where we will save the screen capture.
        HANDLE hFile = CreateFile(L"captureqwsx.bmp",
            GENERIC_WRITE,
            0,
            NULL,
            CREATE_ALWAYS,
            FILE_ATTRIBUTE_NORMAL, NULL);   
        
        // Add the size of the headers to the size of the bitmap to get the total file size
        DWORD dwSizeofDIB = dwBmpSize + sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
     
        //Offset to where the actual bitmap bits start.
        bmfHeader.bfOffBits = (DWORD)sizeof(BITMAPFILEHEADER) + (DWORD)sizeof(BITMAPINFOHEADER); 
        
        //Size of the file
        bmfHeader.bfSize = dwSizeofDIB; 
        
        //bfType must always be BM for Bitmaps
        bmfHeader.bfType = 0x4D42; //BM   
     
        DWORD dwBytesWritten = 0;
        WriteFile(hFile, (LPSTR)&bmfHeader, sizeof(BITMAPFILEHEADER), &dwBytesWritten, NULL);
        WriteFile(hFile, (LPSTR)&bi, sizeof(BITMAPINFOHEADER), &dwBytesWritten, NULL);
        WriteFile(hFile, (LPSTR)lpbitmap, dwBmpSize, &dwBytesWritten, NULL);
        
        //Unlock and Free the DIB from the heap
        GlobalUnlock(hDIB);    
        GlobalFree(hDIB);
    
        //Close the handle for the file that was created
        CloseHandle(hFile);
           
        //Clean up
    done:
        DeleteObject(hbmScreen);
        DeleteObject(hdcMemDC);
        ReleaseDC(NULL,hdcScreen);
        ReleaseDC(hWnd,hdcWindow);
    
        return 0;
    }
    https://msdn.microsof*****m/en-us/libr...=VS.85%29.aspx This Code Should save the current screen image or just the selected window, regardless of rather your using DirectX or OpenGL, though I would reccommend doing you own searching and using DirectX if your able to, because it should be faster.
    Last edited by why06; 11-08-2010 at 05:41 AM.

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

  14. The Following User Says Thank You to why06 For This Useful Post:

    258456 (11-09-2010)

Similar Threads

  1. Any Injectors Other Than Faith?[SOLVED]
    By omg12156 in forum CrossFire Help
    Replies: 2
    Last Post: 07-29-2010, 09:12 AM
  2. [Help]Is there any hacks for singleplayer?
    By PvtParts in forum Battlefield Bad Company 2 (BFBC2) Hacks
    Replies: 3
    Last Post: 07-28-2010, 10:45 AM
  3. HELP THREAD(post ANY questions here)
    By Obama in forum Combat Arms Hacks & Cheats
    Replies: 1490
    Last Post: 08-23-2009, 11:31 AM
  4. trading m60 or m249 retail code for any account greater than lv 11
    By tribunal4555 in forum Trade Accounts/Keys/Items
    Replies: 2
    Last Post: 03-11-2008, 12:09 PM
  5. Any dupe method?
    By marquimrlz in forum Knight Online Hacks
    Replies: 7
    Last Post: 10-17-2007, 06:55 PM