Jump to content

Please help me find the problem


Go to solution Solved by water,

Recommended Posts

After some hours I reached a point where there is nothing more than I can try to resolve this problem. I would appreciate your help guys.

 

#include <AutoItConstants.au3>
#RequireAdmin
#include <MsgBoxConstants.au3>

Local $aCoord
Local $options
Local $actions = 2
Local $1C = 141
Local $2C = 109
Local $3C = 143
Local $4C = 113
Local $Actx = 155
Local $Acty = 71
Local $Act
Local $1Act = 4
Local $2Act = 2

For $x = 1 To $actions
    For $i = 2 To 6 
        $aCoord = PixelSearch($1C, $2C,$3C, $4C,0x00AEEF)
        $2C +=  19
        $4C +=  19

        If  @error Then 
            $options = $i
            ExitLoop
        EndIf
    Next

    If $x = 1 Then
        $Act = $1Act
    ElseIf $x = 2 Then
        $Act = $2Act
    EndIf
    
    $Acty = $Acty + ($options - $Act) * 19
    MouseClick($MOUSE_CLICK_LEFT, $Actx, $Acty, 1,0)
    $Actx += 117
    $Acty = 71
    $1C +=  117
    $3C +=  117
    $2C = 109
    $4C = 113
Next

On the first iteration when $x = 1 everything is working perfectly but on the second one the Pixel Search doesnt recognize the color. The strange thing is when I put 

MsgBox($MB_SYSTEMMODAL, "Title", $1C&$2C&$3C&$4C, 10)

this code exactly before Pixel Search and check the coordinates without changing anything else in the code, everything is working as it should. 

Link to post
Share on other sites

Are you aware that on the second loop you're not resetting the values of $1C, $2C, $3C, $4C to their original states? It may be intended but on two loops you're searching these pixels:

Quote

PixelSearch(141, 109, 143, 113, 0x00AEEF)
PixelSearch(141, 128, 143, 132, 0x00AEEF)
PixelSearch(141, 147, 143, 151, 0x00AEEF)
PixelSearch(141, 166, 143, 170, 0x00AEEF)
PixelSearch(141, 185, 143, 189, 0x00AEEF)
PixelSearch(258, 109, 260, 113, 0x00AEEF)
PixelSearch(258, 128, 260, 132, 0x00AEEF)
PixelSearch(258, 147, 260, 151, 0x00AEEF)
PixelSearch(258, 166, 260, 170, 0x00AEEF)
PixelSearch(258, 185, 260, 189, 0x00AEEF)

If that's not what you're intending, try setting the variable back to the default values:

For $x = 1 To $actions
    $1C = 141
    $2C = 109
    $3C = 143
    $4C = 113
    For $i = 2 To 6

This was a stab in the dark but maybe it'll help lol. :D

Edit: Snipped the bit about @error because increment a variable doesn't reset @error.

Edited by Luke94
Link to post
Share on other sites
  • Solution

Can you please tell us which program you try to automate?
Pixelsearch and Mouseclick aren't very reliable as they depend on screen resolution, window position etc.
 

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 post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...