lolp1 Posted September 25, 2006 Share Posted September 25, 2006 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? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 25, 2006 Moderators Share Posted September 25, 2006 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) EndFuncSomething like that. 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. Link to comment Share on other sites More sharing options...
lolp1 Posted September 25, 2006 Author Share Posted September 25, 2006 (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 September 25, 2006 by lolp1 Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 25, 2006 Moderators Share Posted September 25, 2006 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) 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. Link to comment Share on other sites More sharing options...
AceLoc Posted September 25, 2006 Share Posted September 25, 2006 (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 September 25, 2006 by aceloc [quote name='AceLoc']I gots new sunglasses there cool.[/quote] Link to comment Share on other sites More sharing options...
lolp1 Posted September 25, 2006 Author Share Posted September 25, 2006 (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 September 25, 2006 by lolp1 Link to comment Share on other sites More sharing options...
AceLoc Posted September 25, 2006 Share Posted September 25, 2006 (edited) expandcollapse popupMouseX(); 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 September 25, 2006 by aceloc [quote name='AceLoc']I gots new sunglasses there cool.[/quote] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 25, 2006 Moderators Share Posted September 25, 2006 @aceloc Why do you have a function only calling a function? 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. Link to comment Share on other sites More sharing options...
AceLoc Posted September 25, 2006 Share Posted September 25, 2006 (edited) @acelocWhy 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 September 25, 2006 by aceloc [quote name='AceLoc']I gots new sunglasses there cool.[/quote] Link to comment Share on other sites More sharing options...
lolp1 Posted September 25, 2006 Author Share Posted September 25, 2006 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? Link to comment Share on other sites More sharing options...
AceLoc Posted September 25, 2006 Share Posted September 25, 2006 (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 September 25, 2006 by aceloc [quote name='AceLoc']I gots new sunglasses there cool.[/quote] Link to comment Share on other sites More sharing options...
lolp1 Posted September 25, 2006 Author Share Posted September 25, 2006 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. Link to comment Share on other sites More sharing options...
lolp1 Posted September 25, 2006 Author Share Posted September 25, 2006 Any help would be apperciated. Link to comment Share on other sites More sharing options...
lolp1 Posted September 25, 2006 Author Share Posted September 25, 2006 Up Link to comment Share on other sites More sharing options...
AceLoc Posted September 25, 2006 Share Posted September 25, 2006 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) -- Minimizedbecause that one DOES work minimized. [quote name='AceLoc']I gots new sunglasses there cool.[/quote] Link to comment Share on other sites More sharing options...
lolp1 Posted September 25, 2006 Author Share Posted September 25, 2006 Yes, it presses I, waits a moment, and the proceds to minamize. (With out doing the mousemove) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now