Sign in to follow this  
Followers 0
lolp1

Compile error.

16 posts in this topic

Hello, I'm getting this error:

Error: Subscript used with non-Arry variable.

When run this 'code'.

Func movemouse ( $x, $y )
    $name = WinGetTitle ( "Classname=Diablo II", "")
    $pos = WinGetPos ( $name, "")
    $x = $x + $pos[0]
    $y = $y + $pos[1]
    MouseClick ( "left", $x, $y, 1, 0)
EndFunc

Full:

Sleep(2000)
Send("i")
movemouse ( 804, 436)
movemouse ( 344, 387)

Func movemouse ( $x, $y )
    $name = WinGetTitle ( "Classname=Diablo II", "")
    $pos = WinGetPos ( $name, "")
    $x = $x + $pos[0]
    $y = $y + $pos[1]
    MouseClick ( "left", $x, $y, 1, 0)
EndFunc

Can anyone tell me what I am doing wrong?

Share this post


Link to post
Share on other sites



WinGetPos() returns an Array, if it did not get the information for whatever reason it doesn't return an Array. So you have to do a check after it to make sure it was captured.

Sleep(2000)
Send("i")
movemouse ( 804, 436)
movemouse ( 344, 387)

Func movemouse ( $x, $y )
    $name = WinGetTitle ( "Classname=Diablo II", "")
    $pos = WinGetPos ( $name, "")
    If Not IsArray($pos) Then Return SetError(1, 0, 0)
    $x = $x + $pos[0]
    $y = $y + $pos[1]
    MouseClick ( "left", $x, $y, 1, 0)
EndFunc
Something like that.

[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

#3 ·  Posted (edited)

This is one step closer, how ever now it will not perform the mousemove function, any ideas?

Here is everything I got:

WinActivate("Diablo II", "")

sleep(2000)
Send("i")
movemouse ( 804, 436)
movemouse ( 344, 387)

Func movemouse ( $x, $y )
    $name = WinGetTitle ( "Classname=Diablo II", "")
    $pos = WinGetPos ( $name, "")
    If Not IsArray($pos) Then Return SetError(1, 0, 0)
    $x = $x + $pos[0]
    $y = $y + $pos[1]
    MouseClick ( "left", $x, $y, 1, 0)
EndFunc

It activates the window, and presses I, but doesnt perform mouse move.

Edited by lolp1

Share this post


Link to post
Share on other sites

This is one step closer, how ever now it will not perform the mousemove function, any ideas?

Here is everything I got:

WinActivate("Diablo II", "")

sleep(2000)
Send("i")
movemouse ( 804, 436)
movemouse ( 344, 387)

Func movemouse ( $x, $y )
    $name = WinGetTitle ( "Classname=Diablo II", "")
    $pos = WinGetPos ( $name, "")
    If Not IsArray($pos) Then Return SetError(1, 0, 0)
    $x = $x + $pos[0]
    $y = $y + $pos[1]
    MouseClick ( "left", $x, $y, 1, 0)
EndFunc

It activates the window, and presses I, but doesnt perform mouse move.

Well if that's the entire script... then yeah:

At the top you'll need:

Opt("WinTitleMatchMode", 4)

[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

#5 ·  Posted (edited)

This is one step closer, how ever now it will not perform the mousemove function, any ideas?

Here is everything I got:

WinActivate("Diablo II", "")

sleep(2000)
Send("i")
movemouse ( 804, 436)
movemouse ( 344, 387)

Func movemouse ( $x, $y )
    $name = WinGetTitle ( "Classname=Diablo II", "")
    $pos = WinGetPos ( $name, "")
    If Not IsArray($pos) Then Return SetError(1, 0, 0)
    $x = $x + $pos[0]
    $y = $y + $pos[1]
    MouseClick ( "left", $x, $y, 1, 0)
EndFunc

It activates the window, and presses I, but doesnt perform mouse move.

i played d2.. could you exactly say what you wanna do?

bcoz i still got some old trash scripts of d2 *-)

Thanks.

Edited by aceloc

[quote name='AceLoc']I gots new sunglasses there cool.[/quote]

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

It's for a Diablo II bot I made, ment to drop the item(s) it collects into act 1 for another bot (mule) to pick up.

Edited by lolp1

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

MouseX(); starts func

Func _MouseClickPlus($Window, $Button = "left", $X = "", $Y = "", $Clicks = 1)
  Local $MK_LBUTTON       =  0x0001
  Local $WM_LBUTTONDOWN   =  0x0201
  Local $WM_LBUTTONUP     =  0x0202
 
  Local $MK_RBUTTON       =  0x0002   
  Local $WM_RBUTTONDOWN   =  0x0204
  Local $WM_RBUTTONUP     =  0x0205

  Local $WM_MOUSEMOVE     =  0x0200
 
  Local $i                = 0
 
  Select
  Case $Button = "left"
     $Button     =  $MK_LBUTTON
     $ButtonDown =  $WM_LBUTTONDOWN
     $ButtonUp   =  $WM_LBUTTONUP
  Case $Button = "right"
     $Button     =  $MK_RBUTTON
     $ButtonDown =  $WM_RBUTTONDOWN
     $ButtonUp   =  $WM_RBUTTONUP
  EndSelect
 
  If $X = "" OR $Y = "" Then
     $MouseCoord = MouseGetPos()
     $X = $MouseCoord[0]
     $Y = $MouseCoord[1]
  EndIf
 
  For $i = 1 to $Clicks
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $WM_MOUSEMOVE, _
        "int",   0, _
        "long",  _MakeLong($X, $Y))
       
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $ButtonDown, _
        "int",   $Button, _
        "long",  _MakeLong($X, $Y))
       
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $ButtonUp, _
        "int",   $Button, _
        "long",  _MakeLong($X, $Y))
  Next
EndFunc  ;==>MouseClickPlus

Func _MakeLong($LoWord,$HiWord)
  Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc  ;==>MakeLong

Func MouseX()
_MouseClickPlus("WINDOW", "BUTTON",  X, Y, CLICKS); so would be something like "_MouseClickPlus("Diablo II", "left", x, y, 1)"
EndFunc  ;==>MouseX

i always used that to click the items *-)

Edited by aceloc

[quote name='AceLoc']I gots new sunglasses there cool.[/quote]

Share this post


Link to post
Share on other sites

@aceloc

Why do you have a function only calling a function?


[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

#9 ·  Posted (edited)

@aceloc

Why do you have a function only calling a function?

because.. i got no idea actually but it are really old scripts just after AI2 Edited by aceloc

[quote name='AceLoc']I gots new sunglasses there cool.[/quote]

Share this post


Link to post
Share on other sites

Ok right now, this is what I got:

WinActivate("Diablo II", "")
Opt("WinTitleMatchMode", 4)

sleep(2000)
Send("i")
movemouse ( 815, 513)


Func movemouse ( $x, $y )
    $name = WinGetTitle ( "Classname=Diablo II", "")
    $pos = WinGetPos ( $name, "")
    If Not IsArray($pos) Then Return SetError(1, 0, 0)
    $x = $x + $pos[0]
    $y = $y + $pos[1]
    MouseClick ( "left", $x, $y, 1, 0)
EndFunc

It maximized the screen, then presses I, and minamized, any idea why?

Note:

My goal here is the maximize screen - Done

Press I - Done

Mouse click in the right postion - Not done

I have to use this function:

Func movemouse ( $x, $y )
    $name = WinGetTitle ( "Classname=Diablo II", "")
    $pos = WinGetPos ( $name, "")
    If Not IsArray($pos) Then Return SetError(1, 0, 0)
    $x = $x + $pos[0]
    $y = $y + $pos[1]
    MouseClick ( "left", $x, $y, 1, 0)
EndFunc

To make sure it knows the size of the screen ect, but it won't perform the mouse clicks, any idea why?

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Ok right now, this is what I got:

WinActivate("Diablo II", "")
Opt("WinTitleMatchMode", 4)

sleep(2000)
Send("i")
movemouse ( 815, 513)
Func movemouse ( $x, $y )
    $name = WinGetTitle ( "Classname=Diablo II", "")
    $pos = WinGetPos ( $name, "")
    If Not IsArray($pos) Then Return SetError(1, 0, 0)
    $x = $x + $pos[0]
    $y = $y + $pos[1]
    MouseClick ( "left", $x, $y, 1, 0)
EndFunc

It maximized the screen, then presses I, and minamized, any idea why?

Note:

My goal here is the maximize screen - Done

Press I - Done

Mouse click in the right postion - Not done

I have to use this function:

Func movemouse ( $x, $y )
    $name = WinGetTitle ( "Classname=Diablo II", "")
    $pos = WinGetPos ( $name, "")
    If Not IsArray($pos) Then Return SetError(1, 0, 0)
    $x = $x + $pos[0]
    $y = $y + $pos[1]
    MouseClick ( "left", $x, $y, 1, 0)
EndFunc

To make sure it knows the size of the screen ect, but it won't perform the mouse clicks, any idea why?

you are saying when it is at the

Send("i")

part... then the window minimize?

P.S mines also clicks etc (used it for Aurabug dupe) -- Minimized

because that one DOES work minimized.

Edited by aceloc

[quote name='AceLoc']I gots new sunglasses there cool.[/quote]

Share this post


Link to post
Share on other sites

Here is what I am trying to do:

Activate diablo II window - done

Press I - Done

Mouseclick here:

movemouse ( 815, 513)
- Not done

What happens is:

Activates Diablo II window

Presses I

Sleeps a few seconds

Then minamizes for no reason. (Looks likes it trys to click somewhere as well)

This is all of what I am using:

WinActivate("Diablo II", "")
Opt("WinTitleMatchMode", 4)

sleep(2000)
Send("i")
movemouse ( 815, 513)
Func movemouse ( $x, $y )
    $name = WinGetTitle ( "Classname=Diablo II", "")
    $pos = WinGetPos ( $name, "")
    If Not IsArray($pos) Then Return SetError(1, 0, 0)
    $x = $x + $pos[0]
    $y = $y + $pos[1]
    MouseClick ( "left", $x, $y, 1, 0)
EndFunc

The mousemov function is important cause I have to have the right X-Y just incase screen size is diffrent.

Share this post


Link to post
Share on other sites

Any help would be apperciated.

Share this post


Link to post
Share on other sites

you are saying when it is at the

Send("i")

part... then the window minimize?

P.S mines also clicks etc (used it for Aurabug dupe) -- Minimized

because that one DOES work minimized.


[quote name='AceLoc']I gots new sunglasses there cool.[/quote]

Share this post


Link to post
Share on other sites

Yes, it presses I, waits a moment, and the proceds to minamize. (With out doing the mousemove)

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