Jump to content

Autopix


Recommended Posts

Saw what Larry posted there and decided to post this deal I wrote to auto write code and help expedite the process of pixget and pixsearch. Pretty basic but I thought maybe someone might use it or improve it for me heh. Once it writes the code it sends it to the clipboard for quick clickin pastin fingers, yeah baby.

$done = 0;
$exit = 1;
$exiting = 0;
Global $ks1 = "!1";
Global $ks2 = "!2";
Global $number = 0;
Global $clip = 0;
$loopit = 1;

;=======================Main Loop===============================

While $loopit > 0;

    Main()

WEnd

;=======================PixSearch===============================

Func PixSearch()

HotKeySet($ks1)
HotKeySet($ks2)

Global $file = FileOpen("autopix.txt", 2)
Global $spreadx = InputBox("PixelSearch Input", "PixelSearch Horizontal Spread?", "10")
Global $spready = InputBox("PixelSearch Input", "PixelSearch Vertical Spread?", "5")
Global $shadevariation = InputBox("PixelSearch Input", "PixelSearch Shade Variation?", "0")
Global $step = InputBox("PixelSearch Input", "PixelSearch Step?" & @CRLF & @CRLF & "After clicking OK, press ALT + 1 to set the point.", "1")

Do

    HotKeySet($ks1, "Searchit")

Until $exit = 1

EndFunc

;======================PixColor=================================

Func PixColor()

HotKeySet($ks1)
HotKeySet($ks2)

Global $file = FileOpen("autopix.txt", 2)
Global $points = InputBox("PixelGet Input", "How many points do you want to set?" & @CRLF & @CRLF & "After clicking OK, press ALT + 1 to set each point.", "4")

Do

HotKeySet($ks1, "GetPoints")

    If $number = $points Then
  PixGetTest()
    Endif
    

Until $exit = 1;

EndFunc

;====================PixSearch Related==========================

Func Searchit()

SoundPlay ( "C:\WINDOWS\Media\Windows XP Balloon.wav");

HotKeySet($ks1)
HotKeySet($ks2)

$pos = MouseGetPos()
$color = PixelGetColor ( $pos[0] , $pos[1] )
$leftcoord = $pos[0] - $spreadx
$topcoord = $pos[1] - $spready
$rightcoord = $pos[0] + $spreadx
$bottomcoord = $pos[1] + $spready

PixelSearch( $leftcoord , $topcoord , $rightcoord , $bottomcoord , $color , $shadevariation , $step )
    
    If @error = 0 Then
  $comment1 = InputBox("PixelSearch Input", "Enter a Comment for what this relates to.", "")
  FileWrite($file, "If PixelSearch(" & $leftcoord & "," & $topcoord & "," & $rightcoord & "," & $bottomcoord & "," & $color & "," & $shadevariation & "," & $step & ") Then")
  FileClose ( $file )
  $file = FileOpen("autopix.txt", 0)
  $output1 = FileReadLine ( $file , 1 )
  FileClose ( $file )
  ClipPut ( $output1 & Chr ( 59 ) & " " & $comment1 )
  MsgBox ( 0 , "Found", "PixelSearch Successful. Resultant Code sent to Clipboard.")
    Else
  MsgBox ( 0 , "Failure", "PixelSearch Failed.")
    Endif

$exit = 1;

EndFunc

;========================PixColor Related========================

Func GetPoints()

$number = $number + 1;
$pos = MouseGetPos()
$color = PixelGetColor ( $pos[0], $pos[1] )
Global $setit1 = $pos[0]
Global $setit2 = $pos[1]
Global $setit3 = $color

    If $points = $number Then
  FileWrite($file, "PixelGetColor(" & $setit1 & "," & $setit2 & ") = " & $setit3 & " Then")
    ElseIf $points > $number AND $number > 1 Then
  FileWrite($file, "PixelGetColor(" & $setit1 & "," & $setit2 & ") = " & $setit3 & " AND ")
    ElseIf $number = 1 Then
  FileWrite($file, "If PixelGetColor(" & $setit1 & "," & $setit2 & ") = " & $setit3 & " AND ")
    Endif

SoundPlay ( "C:\WINDOWS\Media\Windows XP Balloon.wav");

EndFunc

Func PixGetTest()

FileClose ( $file )
$file = FileOpen("autopix.txt", 0)


$output = FileReadLine ( $file , 1 )
     
  If $output Then
     $comment = InputBox("PixelGet Input", "Enter a Comment for what this relates to.", "")
     FileClose ( $file )
     ClipPut ( $output & Chr ( 59 ) & " " & $comment )
     MsgBox ( 0 , "Found", "PixelGetColor Successful. Resultant Code sent to Clipboard.")
     $number = 0;
  Else
     MsgBox ( 0 , "Failure", "PixelGet Failed.")
  Endif
     
$exit = 1;

EndFunc

;========================FrontEnd Loop==============================

Func Main()
    
    
    If $exit = 1 Then
  Global $continue = MsgBox ( 4 , "Instruction", "PixelSearch: Press ALT + 1. PixelGetColor: Press ALT + 2." & @CRLF & "Continue?")
  HotKeySet($ks1, "PixSearch")
  HotKeySet($ks2, "PixColor")
    Endif
    
    If $continue = 6 Then
  $continue = 0;
  $exit = 0;
    ElseIf $continue = 7 Then
  Cleanup()
    Endif

EndFunc

;=======================CleanUP TXT===============================

Func Cleanup()

FileDelete ( "autopix.txt" )
$loopit = 0;

EndFunc
Link to comment
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
 Share

  • Recently Browsing   0 members

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