christian11

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

2 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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.

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

  • Similar Content

    • Nitrolord
      By Nitrolord
      I had this problem with PixelGetColor not giving me the same HEX Color as the AU3Info Tool and searched every were with no luck then had a OH DA moment LoL.
      The problem is that the
      "PixelGetColor ($mouseX[0], $mouseY[1])"
      is looking rite at the very tip of the mouse pointer not under it.  So you have to set a -3 after the [0] and [1].  
      "PixelGetColor ($mouseX[0] -3, $mouseY[1] -3)"
      to make it search next to the pointer not on the pointer.  You may have to adjust this a bit for your display but you should not have  to go more then -5.  -3 seems to work best for me.
      Example.au3
      #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 141, 127, 276, 231) $Input1 = GUICtrlCreateInput("", 8, 8, 121, 21) $Label1 = GUICtrlCreateLabel("Press or Hold F1 to get Hex color at Mouse X -3, Y-3 Pos,", 8, 40, 124, 73) GUISetState(@SW_SHOW) HotKeySet("{f1}","MousePos") Func MousePos() $aPos = MouseGetPos() $PGC = PixelGetColor($aPos[0] -3, $aPos[1] -3) GUICtrlSetData($Input1, "0x" & Hex($PGC, 6)) EndFunc While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd  
    • DuyAnh
      By DuyAnh
      how to find the location on an image color ?? 
      Similar PixelSearch, but in a format bmp image

      search 0x0806EB and returns coordinates

      sorry I am not good at English
    • Tirk
      By Tirk
      PixelSearch in a GUI window which state's @SW_MINIMIZE.
      Is it possible?
    • Annonyreeder
      By Annonyreeder
      Hello,
      I've wrote a fairly straight forward script that will search an area of the screen and then left click on apart of that area should it find a certain color/pixel. 
      I have a small issue where by within the area, multiple pixels of the same color will appear, the script will continue to click on the same pixel over and over again. Is there a way so that it will cycle through all the results and click on each one for a given time period then move onto the next, as apose to clicking on the same spot forever. I have used timers before and that shouldn't be an issue, its more the having it stop clicking, or ignoring the current pixel its clicking and then moving onto the next one (same pixel color within same area).

      Hopefully this makes sense.
      [autoit]
      HotKeySet("{ESC}", "END_EXIT") HotKeySet("+1", "start") While 1     Sleep(100)  WEnd func start()    while 1 $location = PixelSearch( 631, 175, 1181, 597, 0xFF0000) If IsArray ($location) = 1 Then     MouseClick ('left', $location[0], $location[1], 1, 0)  EndIf  WEnd EndFunc  func END_EXIT()  Exit  EndFunc
       
      [/autoit]
    • Reizvoller
      By Reizvoller
      Greetings, 
      Func pixelHunter () Local $PixelHunt[2] Do $PixelHunt = PixelSearch (1, 1, 1016, 874, "0xCCE4CC", 0, 1, $sWorkOrderWin) Until $PixelHunt[0] > 0 EndFunc So when I call up this function in my app it fires back "Subscript used on non-accessible variable"
      Now, if I am understanding this message properly it is trying to tell me that the variable can't be seen by the function asking for it.
      I replaced "Do...Until" with simply a "ConsoleWrite" the $PixelHunt value and it doesn't throw that error.
      Any advice would be appreciated!
      -Reiz