Jump to content

script isnt working correctly


Recommended Posts

HotKeySet("{f7}", "tp")
$color = 0x800080
$shadevar = 25
$step = 1

Func Tp()
          $size = WinGetClientSize ( "runescape"); <--- The Window Tool is Awesome.
      $Pix = PixelSearch( ($size[1])/2,  ($size[0])/2,  ($size[1])/2,  ($size[0])/2, 0xff0000, 25, 1)
      Opt( "MouseCoordMode", 2)
      Sleep( 2000 )
      MouseClick( "Left", $Pix[0], $Pix[1])
EndFunc



while 1
    Sleep( 5000 )

WEnd

i get this:

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Program Files\AutoIt3\Test.au3"   
C:\Program Files\AutoIt3\Test.au3 (19) : ==> Subscript used with non-Array variable.:
$Pix = PixelSearch( ($size[1])/2,  ($size[0])/2,  ($size[1])/2,  ($size[0])/2, 0xff0000, 25, 1)
$Pix = PixelSearch( ($size^ ERROR
>Exit code: 1   Time: 4.895

please help!

Link to comment
Share on other sites

HotKeySet("{f7}", "tp")
$color = 0x800080
$shadevar = 25
$step = 1

Func Tp()
      $size = WinGetClientSize ( "runescape"); <--- The Window Tool is Awesome.
      if isArray($size) then
           $Pix = PixelSearch( ($size[1])/2,  ($size[0])/2,  ($size[1])/2,  ($size[0])/2, 0xff0000, 25, 1)
           Opt( "MouseCoordMode", 2)
           Sleep( 2000 )
           MouseClick( "Left", $Pix[0], $Pix[1])
     else
          msgbox(0,"","Didnt find window")
     endif
EndFunc



while 1
    Sleep( 5000 )

WEnd

Link to comment
Share on other sites

HotKeySet("{f7}", "tp")
$color = 0x800080
$shadevar = 25
$step = 1

Func Tp()
      $size = WinGetClientSize ( "RuneScape"); <--- The Window Tool is Awesome.
      if isArray($size) then
           $Pix = PixelSearch( ($size[1])/2,  ($size[0])/2,  ($size[1])/2,  ($size[0])/2, 0xff0000, 25, 1)
           Opt( "MouseCoordMode", 2)
           Sleep( 2000 )
           MouseClick( "Left", $Pix[0], $Pix[1])
     else
          msgbox(0,"","Didnt find window")
     endif
EndFunc



while 1
    Sleep( 5000 )

WEnd

turns out i had the window wrong but now when i run it i get

C:\Program Files\AutoIt3\Test.au3 (23) : ==> Subscript used with non-Array variable.:
MouseClick( "Left", $Pix[0], $Pix[1])
MouseClick( "Left", $Pix^ ERROR
>Exit code: 1   Time: 4.709
Link to comment
Share on other sites

if you get that error it means your script did not found pixel color you were looking for.

HotKeySet("{F7}", "tp")
$color = 0x800080
$shadevar = 25
$step = 1
$client_name = "RuneScape"

Func Tp()
    if WinExists($client_name) Then
        WinActivate($client_name)
        $size = WinGetClientSize ($client_name); <--- The Window Tool is Awesome.
        $handle = WinGetHandle($client_name)
        Opt("PixelCoordMode", 2)
        $Pix = PixelSearch( 0,  0,  $size[0],  $size[1], $color, 25, 1, $handle)
        if @error Then
            MsgBox(0, "", "didn't found your color in the client")
        Else
            Opt( "MouseCoordMode", 2)
            Sleep( 2000 )
            MouseClick( "Left", $Pix[0], $Pix[1])
        EndIf
    else
        msgbox(0,"","Didn't found client's window")
    endif
EndFunc

while 1
    Sleep( 5000 )
WEnd

edit: Your coordinates wasn't correct, now the script searches for a desired pixel color in the client's window area.

Edited by sandin
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...