Jump to content

i have similar problem but i found an ahk script solution from google. can anyone help me convert ahk to autoit script?


 Share

Recommended Posts

i have similar problem pixelsearch. but i found an ahk script solution from google. can anyone help me convert ahk to autoit script? im really new to this 

heres ahk script

MainLoop() {
Loop {
    PixelSearch, X, Y, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, 0x00FF00, 0, fast
        if(ErrorLevel=0) {
                MouseClick, left, %X%, %Y%
            sleep, 300
            RefinedLoop(x, y)
}

RefinedLoop(pX, pY) {
    Loop {
         pX := X + 50
         pY := y + 50
         dX := X - 50
         dY := Y - 50
         PixelSearch, X, Y, %pX%, %pY%, %dX%, %dY%, 0x00FF00, 0, fast
            if(ErrorLevel=0) {
                MouseClick, left, %X%, %Y%
                sleep, 300
            }
            Else if (ErrorLevel <> 0)
                i++
            If (i > 10)
                MainLoop()
    }
}

 

i tried to convert to autoit but gives me bunch of error

Func MainLoop() 
While 1
$green = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0x00ff00)
If isArray($green) then
MouseClick("primary", $green[0], $green[1] , 1, 0)

RefinedLoop(pX, pY)
}

RefinedLoop(pX, pY) {
 while 1 
         pX = X + 50
         pY = y + 50
         dX = X - 50
         dY = Y - 50
  

$green = PixelSearch($pX, $pY, $dX, $dY 0x00ff00)
If isArray($green) then
MouseClick("primary", $green[0], $green[1] , 1, 0)
            
            Else if @ErrorLevel <> 0
                i++
            If (i > 10)

 

Edited by christian11
Link to comment
Share on other sites

Func MainLoop() 
While 1
$green = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0x00ff00)
If isArray($green) then
MouseClick("primary", $green[0], $green[1] , 1, 0)

RefinedLoop(pX, pY)
EndFunc

Func RefinedLoop(pX, pY) {
$i = 0
 while 1 
         pX = X + 50
         pY = y + 50
         dX = X - 50
         dY = Y - 50
  

$green = PixelSearch($pX, $pY, $dX, $dY 0x00ff00)
If isArray($green) Then
MouseClick("primary", $green[0], $green[1] , 1, 0)
            If Not @error Then
            Else
                $i += 1
            EndIf    
            If $i > 10 Then
            MainLoop()
          EndIf
 EndFunc

It's such a mess but here's a start.

Put $ before all your variables too.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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

×
×
  • Create New...