Sign in to follow this  
Followers 0
Skrip

How can this possibly be faster?

4 posts in this topic

Sleep(2000)
HotKeySet("h", "stop")
$searchcolor = 0xFFFFFF
While 1
            $coord = PixelSearch(393, 599, 869, 917, $searchcolor, 10, 3)
;~          $coord2 = PixelSearch(623, 747, 642, 764, $searchcolor, 1)
            If IsArray($coord) = 1 Then
                MouseMove($coord[0], $coord[1], 0)
            EndIf
;~          If IsArray($coord2) = 1 Then
;~              MouseClick("left", $coord2[0], $coord2[1])
;~          EndIf
WEnd
Func stop()
    Exit
EndFunc


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites



Sleep(2000)
HotKeySet("h", "stop")
$searchcolor = 0xFFFFFF
While 1
            $coord = PixelSearch(393, 599, 869, 917, $searchcolor, 10, 3)
;~    $coord2 = PixelSearch(623, 747, 642, 764, $searchcolor, 1)
            If IsArray($coord) = 1 Then
                MouseMove($coord[0], $coord[1], 0)
            EndIf
;~    If IsArray($coord2) = 1 Then
;~     MouseClick("left", $coord2[0], $coord2[1])
;~    EndIf
WEnd
Func stop()
    Exit
EndFunc
1. Get a faster computer.

2. Search a smaller area.

3. Don't do any error checking.

Share this post


Link to post
Share on other sites

1. Get a faster computer.

2. Search a smaller area.

3. Don't do any error checking.

You forgot:

4. IsArray() is being returned as a boolean, so you don't need = 1, just something extra to make it do.

5. Use a different language.

:whistle:


[center]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.[/center]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

try something like this if you're looking for an object which is moving on the screen

Sleep(2000)
HotKeySet("h", "stop")
$searchcolor = 0xFFFFFF
dim $l,$t,$r,$b
$lmin=393
$tmin=599
$rmax=869
$bmax=917
clipRect(0)
    
While 1
     $coord = PixelSearch($l, $t, $r, $b, $searchcolor, 10, 3)
     if @error=1 Then
          clipRect(0)
      Else
      MouseMove($coord[0], $coord[1], 0)
      clipRect(20)
      EndIf
WEnd

Func clipRect($rectSize)
  if $rectSize=0 then
      $l=$lmin
      $t=$tmin
      $r=$rmax
      $b=$bmax
  else 
     $l=$coord[0]-$rectSize/2
     if $l<$lmin then $l=$lmin
     $t=$coord[1]-$rectSize/2
     if $t<$tmin then $t=$tmin
     $r=$l+$rectSize
     if $r>$rmax then 
          $r=$rmax
          $l=$r-$rectSize
     endif
     $b=$t+$rectSize
     if $b>$bmax then 
            $b=$bmax
            $t=$b-$rectSize
      endif
   endif
EndFunc

Func stop()
    Exit
EndFunc
Edited by tresa

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