Sign in to follow this  
Followers 0
jaberwacky

AutoIt source code question

6 posts in this topic

I'm somewhat new to programming and AutoIt. I wanted to see the AutoIt source code so that I could get my hands on some real C++ code for learning purposes and to see the code for PixelSearch(). Because as some of you may have seen I am trying to make my own PixelSearch based UDF.

I went to the developer chat. Then I went to the AutoIt Source Code sticky post. I downloaded autoit-docs-v3.3.0.0-src.exe. I double clicked that exe. It then put a folder on my desktop called 'Docs'. But when I go through the folders I see nothing but helpfile stuff.

What have I done wrong?

Any help is appreciated.

Share this post


Link to post
Share on other sites



Notice the name of the file you downloaded -- autoit-docs-v3.3.0.0-src.exe. The last open source version of AutoIt was v3.1.0 (autoit-v3.1.0-src.exe).


[ WinINet.au3 | Array.au3 (Optimized) | _UnixTimeParse() ]

Share this post


Link to post
Share on other sites

Notice the name of the file you downloaded -- autoit-docs-v3.3.0.0-src.exe. The last open source version of AutoIt was v3.1.0 (autoit-v3.1.0-src.exe).

Oh wow! I can't believe that I did that!

Thank you Ultima for your quick reply and helpful answer! =)

Share this post


Link to post
Share on other sites

Oh well, still can't find the code for pixelsearch but it's cool. Thanks for your help!

I believe PixelSearch back then (last open source release) used nothing but the API GetPixel() in a loop. It's since then changed dramatically.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I believe PixelSearch back then (last open source release) used nothing but the API GetPixel() in a loop. It's since then changed dramatically.

I did find this however:

/*
    PixelSearch(  )
    Finds a pixel of certain color within a RECT of pixels
    PixelSearch( <left> ,<top> ,<right> ,<bottom> ,<decimal pixel color> [  , variation ] [  , step ]  )
   
    Variation code from based on cmallet's post on hiddensoft.com forum.
   */
   
   AUT_RESULT AutoIt_Script::F_PixelSearch ( VectorVariant &vParams , Variant &vResult )
   {
       uint     iNumParams = vParams.size(  );
       int          q ,r;
       int          col;
       BYTE     red , green , blue;
       BYTE     red_low , red_high , green_low , green_high , blue_low , blue_high;
       HDC          hdc;
       RECT     relrect;
       int          nVar;
       int          nStep = 1;
       POINT        ptOrigin;
   
       relrect.left = vParams[ 0 ].nValue(  );
       relrect.top = vParams[ 1 ].nValue(  );
       relrect.right = vParams[ 2 ].nValue(  );
       relrect.bottom = vParams[ 3 ].nValue(  );
   
       /// Convert coords to screen/active window/client
       ConvertCoords( m_nCoordPixelMode , ptOrigin );
       relrect.left += ptOrigin.x;
       relrect.top += ptOrigin.y;
       relrect.right += ptOrigin.x;
       relrect.bottom += ptOrigin.y;
   
   
       /// Get the search colour and split into components
       col = vParams[ 4 ].nValue(  );               /// Pixel color to find
       if ( m_bColorModeBGR == false )
           Util_RGBtoBGR( col );                        /// Get RGB color into the standard COLORREF BGR format
   
       red   = GetRValue( col );
       green = GetGValue( col );
       blue  = GetBValue( col );
   
       /// Variation required?
       if ( iNumParams >= 6 )
       {
           nVar = vParams[ 5 ].nValue(  );
           if (  nVar < 0  )
           {
               nVar = 0;
           }
           else if (  nVar > 0xff  )
           {
               nVar = 0xff;
           }
       }
       else
       {
           nVar = 0;
       }
   
       /// Step required?
       if ( iNumParams >= 7 && vParams[ 6 ].nValue(  ) > 1 )
       {
           nStep = vParams[ 6 ].nValue(  );
       }
   
       /// Config the variation code
       if ( nVar == 0 )                             /// Exact match
       {
           red_low   = red_high   = red;
           green_low = green_high = green;
           blue_low  = blue_high  = blue;
       }
       else
       {
           /// Prevent wrap around
           red_low  = ( nVar > red        ) ? 0 : red   - nVar;
           green_low  = ( nVar > green      ) ? 0   : green - nVar;
           blue_low   = ( nVar > blue        ) ? 0  : blue  - nVar;
           red_high   = ( nVar > 0xFF - red   ) ? 0xFF : red   + nVar;
           green_high = ( nVar > 0xFF - green ) ? 0xFF : green + nVar;
           blue_high  = ( nVar > 0xFF - blue  ) ? 0xFF : blue  + nVar;
       }
   
   
       hdc = GetDC( NULL );
   
       for(  q = relrect.left; q <= relrect.right; q = q + nStep )
       {
           for(  r = relrect.top; r <= relrect.bottom; r = r + nStep )
           {
               col   = GetPixel( hdc , q , r );
               red   = GetRValue( col );
               green = GetGValue( col );
               blue  = GetBValue( col );
   
               if ( red >= red_low && red <= red_high && green >= green_low && green <= green_high
                       && blue >= blue_low && blue <= blue_high )
               {
                   /// Match!
                   /// Setup vResult as an Array to hold the 2 values we want to return
                   Variant *pvTemp;
   
                   Util_VariantArrayDim( &vResult , 2 );
   
                   /// Convert coords to screen/active window/client
                   q -= ptOrigin.x;
                   r -= ptOrigin.y;
   
                   pvTemp = Util_VariantArrayGetRef( &vResult , 0 );    ///First element
                   *pvTemp = q; /// X
   
                   pvTemp = Util_VariantArrayGetRef( &vResult , 1 );
                   *pvTemp = r; /// Y
   
                   ReleaseDC( NULL ,hdc );
   
                   return AUT_OK;
               }
           }
       }
       ReleaseDC( NULL ,hdc );
   
       SetFuncErrorCode( 1 ); /// Not found
       return AUT_OK;
   
   <ol><li>} /// PixelSearch(  )</li></ol>

This is pretty awesome. What I see so far is that &vParams contains the PixelSearch() parameters.

Edited by jaberwocky6669

Share this post


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
Sign in to follow this  
Followers 0