Jump to content

PIXEL SEARCH NOT WORKING


ashbeast
 Share

Recommended Posts

Hello ,

Im doing a pixel color search and if color  found do some actions else do some acions here is my code

$aCoord = PixelSearch(214,93 , 226, 109,0xFDCE29 ,$hWhnd)

    If Not @error Then


        MouseMove(252, 201,5)
        Sleep(1000)

        MouseDown($MOUSE_CLICK_LEFT) ; Set the left mouse button state as down.
        Sleep(100)
        MouseUp($MOUSE_CLICK_LEFT) ; Set the left mouse button state as up.
        Sleep(500)
        MouseMove(866, 286,5)
        Sleep(500)
        MouseDown($MOUSE_CLICK_LEFT) ; Set the left mouse button state as down.
        Sleep(100)
        MouseUp($MOUSE_CLICK_LEFT) ; Set the left mouse button state as up.
        $E = True
        ;ExitLoop
    Else
        Sleep(3000)
    EndIf

Problem is its not searching for the pixel whether the color is matched or not matched its exicuting the if part only why ?

 

Link to comment
Share on other sites

Welcome to AutoIt and the forum!
It's a bit hard to tell where the problem is without seeing the whole script or - even better - a screenshot of the application you try to automate.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Welcome to AutoIt and the forum!
It's a bit hard to tell where the problem is without seeing the whole script or - even better - a screenshot of the application you try to automate.

this is my full code

AutoItSetOption("MouseCoordMode", 0)
    AutoItSetOption("PixelCoordMode" ,0)

    
    Sleep(1000)
    Local $hWhnd = WinGetHandle("[CLASS:FIFAKC]")
    WinActivate($hWhnd)



    $aCoord = PixelSearch(274,94 , 291, 118,0xFDCE29,$hWhnd)
If Not @error Then
MouseMove(324, 199,5)
        Sleep(1000)

        MouseDown($MOUSE_CLICK_LEFT) ; Set the left mouse button state as down.
        Sleep(100)
        MouseUp($MOUSE_CLICK_LEFT) ; Set the left mouse button state as up.
        Sleep(500)
        
        MouseMove(866, 286,5)
        Sleep(500)
        MouseDown($MOUSE_CLICK_LEFT) ; Set the left mouse button state as down.
        Sleep(100)
        MouseUp($MOUSE_CLICK_LEFT) ; Set the left mouse button state as up.
        $E = True
        ;ExitLoop
    Else
        Sleep(3000)
    



EndIf

Pixel search should be done respective to the active window not the screen so that even if i move the window it should search according to window 

if i remove $hWhnd in pixel search everything works fine but it searches according to screen pixels not window pixels 

Edited by ashbeast
Link to comment
Share on other sites

Am I correct that you try to automate the "EA SPORTS FIFA" game? That's the only hits I got from Google.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • Moderators

@ashbeast, you seem to have missed the forum rules on your way in. Please review them now, especially the part about game automation, and you will see why this topic is locked. Hope to see you soon with a legitimate question.

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...