Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Help turning a script into a proper UDF

$
0
0

So one area I am lacking is "standardization" how the proper way to code, things like how to state variables etc. 

 

Yesterday I came up with what I thought was a neat little script that should be easy to turn into a UDF, and I think the process of learning how to make a UDF will make me better at everything else as I am sure to learn some best practices.

 

This code here is by no means a UDF its like a hybrid of my original code and the half way process that I am at in trying to convert it over.

 

Would anybody be willing to help guide me in the changes and proper ways to get this to where it could be posted and shared?

 

Also dos anybody know what .au3 files the original PixelSearch() is located in, looking that over may be a good self study reference.

 

Regards,

AutoIt         
;This is an enhancement to the PiexelSearch function built into AutoIT in where when the function is called instead of searching the entire screen for your pixel color it searches the specified $range in pixels. ;If the color is found the x & y cordinate values are returned if the color is not found the search is expanded by the $expandrate in pixels and performed again up to the number of times specified in $expandcount. Func PixelSearchRange($searchcolor, $range=50, $expandrate=200, $expandcount=50)     Local $aPOS = MouseGetPos()     Local $lb = $aPOS[0] - $range     Local $tb = $aPOS[1] - $range     Local $rb = $aPOS[0] + $range     Local $bb = $aPOS[1] + $range     $aPix = PixelSearch($lb, $tb, $rb, $bb, $searchcolor)     If Not @Error Then     ;Took out $x & $y just using the array directly probably need a "return" for the function.     ;$x = $aPix[0]     ;$y = $aPix[1]     ;MouseMove is testing/debug actual UDF will return the array for array with x/y cordinates for user to decide what to do with.     MouseMove($aPix[0], $aPix[1], 10)     Else     $Expand = 1     Do     $tb -=$expandrate     $lb -=$expandrate     $rb +=$expandrate     $bb +=$expandrate     $expand +=1     $aPix = PixelSearch($lb, $tb, $rb, $bb, $searchcolor)     If Not @Error Then $Expand = $expandcount     Until $Expand = $expandcount     EndIf     ;Took out $x & $y just using the array directly probably need a "return" for the function.     ;$x = $aPix[0]     ;$y = $aPix[1]     ;MouseMove is testing/debug actual UDF will return the array for array with x/y cordinates for user to decide what to do with.     MouseMove($aPix[0], $aPix[1], 10) EndFunc ;call function for testing PixelSearchRange(000000)

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>