Sc1 Posted June 14, 2008 Share Posted June 14, 2008 Hey, I just started looking into AutoIt and I can't seem to get this right. Could someone please tell me why the below script returns an error of ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $var[1] = $pos[1] + 10 ^ ERROR CODE#include <Array.au3> _Main() Func _Main() Local $pos = MouseGetPos() Local $var[1] $var[0] = $pos[0] + 10 $var[1] = $pos[1] + 10 $var[2] = $pos[2] + 10 $var[3] = $pos[3] + 10 While 1 _MouseTrap($var[0], $var[1], $var[0] + $var [2], $var[1] + $var[3]) sleep ( 10000 ) WEnd _MouseTrap() Exit EndFunc I also tried the below variation and added the arrays later but that didn't work either. The one below returns an error of: ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: _ArrayAdd($var, $pos[2] + 10) _ArrayAdd($var, ^ ERROR CODE#include <Array.au3> _Main() Func _Main() Local $pos = MouseGetPos() Local $var[1] $var[0] = $pos[0] + 10 _ArrayAdd($var, $pos[1] + 10) _ArrayAdd($var, $pos[2] + 10) _ArrayAdd($var, $pos[3] + 10) While 1 _MouseTrap($var[0], $var[1], $var[0] + $var [2], $var[1] + $var[3]) sleep ( 10000 ) WEnd _MouseTrap() Exit EndFunc Thanks for your help. Link to comment Share on other sites More sharing options...
Xantioss Posted June 14, 2008 Share Posted June 14, 2008 CODE #include <Array.au3> _Main() Func _Main() Local $pos = MouseGetPos() Local $var[4] $var[0] = $pos[0] + 10 $var[1] = $pos[1] + 10 $var[2] = $pos[2] + 10 $var[3] = $pos[3] + 10 While 1 _MouseTrap($var[0], $var[1], $var[0] + $var [2], $var[1] + $var[3]) sleep ( 10000 ) WEnd _MouseTrap() Exit EndFunc This schould do the trick? Link to comment Share on other sites More sharing options...
Sc1 Posted June 14, 2008 Author Share Posted June 14, 2008 I realized after I posted that I was meant to change that to a 4, but it hasn't changed anything. Still erroring. Link to comment Share on other sites More sharing options...
Xantioss Posted June 14, 2008 Share Posted June 14, 2008 (edited) I realized after I posted that I was meant to change that to a 4, but it hasn't changed anything. Still erroring. ah,you forget a include #include <Array.au3> #Include <Misc.au3> _Main() Func _Main() Local $pos = MouseGetPos() Local $var[4] $var[0] = $pos[0] + 10 $var[1] = $pos[1] + 10 $var[2] = $pos[2] + 10 $var[3] = $pos[3] + 10 While 1 _MouseTrap($var[0], $var[1], $var[0] + $var [2], $var[1] + $var[3]) sleep ( 10000 ) WEnd _MouseTrap() Exit EndFunc this schould work edit: one litle thingy,the MouseGetPos only returns 2 arguments so have a look at the help file Edited June 14, 2008 by Xantioss Link to comment Share on other sites More sharing options...
Xantioss Posted June 14, 2008 Share Posted June 14, 2008 #include <Array.au3> #Include <Misc.au3> _Main() Func _Main() Local $pos = MouseGetPos() Local $var[4] $var[0] = $pos[0] + 10 $var[1] = $pos[1] + 10 $var[2] = $pos[0] + 10 $var[3] = $pos[1] + 10 While 1 _MouseTrap($var[0], $var[1], $var[0] + $var [2], $var[1] + $var[3]) sleep ( 10000 ) WEnd _MouseTrap() Exit EndFunc try this i think this is your goal? Link to comment Share on other sites More sharing options...
Sc1 Posted June 14, 2008 Author Share Posted June 14, 2008 Didn't know that MouseGetPos only returned 2 arguements so that would be a problem. It creates the box to trap the mouse in, however I would like to it wait for 10 seconds (sleep ( 10000 )), and then evaluate the mouse position and set another box. How would I get it to do that since they removed Gotos. Link to comment Share on other sites More sharing options...
Xantioss Posted June 14, 2008 Share Posted June 14, 2008 Didn't know that MouseGetPos only returned 2 arguements so that would be a problem. It creates the box to trap the mouse in, however I would like to it wait for 10 seconds (sleep ( 10000 )), and then evaluate the mouse position and set another box. How would I get it to do that since they removed Gotos. uh,you could do that by checking the position of the mouse by mousegetpos() and evaluate it with something like if $pos[0] < 200 and $pos[1] > 200 then mousetrap() endif that might be usefull? Link to comment Share on other sites More sharing options...
Sc1 Posted June 14, 2008 Author Share Posted June 14, 2008 It is helpful but not really what i'm lookin for. I want more of a CODEMouseGetPos() While 1 _MouseTrap($var[0], $var[1], $var[0] + $var [2], $var[1] + $var[3]) Wend sleep ( 10000 ) Goto While 1 So that after creatin the MouseTrap, it waits for a little while, then evaluates where the mouse is now, then creates another box around it. Link to comment Share on other sites More sharing options...
Sc1 Posted June 14, 2008 Author Share Posted June 14, 2008 I tried putting a While loop in a while loop, but my knowledge is limited and it doesn't seem to be working =\ CODE While 1 While 2 _MouseTrap($var[0], $var[1], $var[0] + $var [2], $var[1] + $var[3]) sleep ( 5000 ) WEnd sleep ( 5000 ) WEnd Link to comment Share on other sites More sharing options...
SxyfrG Posted June 15, 2008 Share Posted June 15, 2008 (edited) Didn't know that MouseGetPos only returned 2 arguements so that would be a problem. It creates the box to trap the mouse in, however I would like to it wait for 10 seconds (sleep ( 10000 )), and then evaluate the mouse position and set another box. How would I get it to do that since they removed Gotos. #include <Misc.au3> $Pos = MouseGetPos() _MouseTrap($Pos[0]-50, $Pos[1]-50, $Pos[0]+50, $Pos[1]+50) While 1 Sleep(10000) $NewPos = MouseGetPos() If ... Then;add your conditional statements here, i.e. If $NewPos[0] < $Pos[0] And $NewPos[1] > $Pos[1] Then ... ;It'd be best to split up the conditional statements so that 4 quadrants in the virtual square you have created ;are checked to see if the mouse is in there, then change the boundary accordingly. ElseIf ... Then ;More Code EndIf WEnd That should help you *EDIT* Instead of goto, you must call a function. For example If 1 = 1 Then _My1Equals1Function() ;Call the '_My1Equals1Function'. EndIf Edited June 15, 2008 by SxyfrG My scripts:AppLauncherTRAY - Awesome app launcher that runs from the system tray NEW VERSION! | Run Length Encoding - VERY simple compression in pure autoit | Simple Minesweeper Game - Fun little game :)My website 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