Sign in to follow this  
Followers 0
Muchuchu

Help With Arrays

7 posts in this topic

I don't understand what is wrong, I know I am not declaring the arrays correctly, but i don't understand how to do it.

$i = 0

Do

;Assign some data

$arr[0]="coord[o]"

$arr[1]="coord[1]"

$coord = PixelSearch( 0, 0, 50000, 300, 0xCCCCCC)

sleep("500")

mouseclick("left" , $coord[0] , $coord[1])

sleep("50")

mousedown("left")

$i = $i + 1

sleep("5000")

until $i = 1000

Share this post


Link to post
Share on other sites



First... this doesn't seem to be necessary...

;Assign some data
$arr[0]="coord[o]"
$arr[1]="coord[1]"oÝ÷ Ù'¢wyÓM4Eæ¥&®¶­sbb33c¶6ö÷&BÒVÅ6V&6ÂÂSÂ3Â444442oÝ÷ Ù8b­Ü!jÝý³­Ø^·
'$±«­¢+Ùµ½Õͱ¥¬ ÅÕ½Ðí±ÐÅÕ½Ðì°ÀÌØí½½ÉlÁt°ÀÌØí½½ÉlÅt¤)ͱÀ ÅÕ½ÐìÔÀÅÕ½Ðì¤)µ½Õͽݸ ÅÕ½Ðí±ÐÅÕ½Ðì¤
"User responsibility: For every MouseDown there should eventually be a corresponding MouseUp event."

Share this post


Link to post
Share on other sites

I don't understand what is wrong, I know I am not declaring the arrays correctly, but i don't understand how to do it.

It's not obvious to me what you want to do so I've made a guess.

Dim $arr[2][1000]; 1000 x,y coords
$i = 0
Do

$coord = PixelSearch( 0, 0, 50000, 300, 0xCCCCCC)
if @error = 0 then
  $arr[0][i] =$coord[0]
  $arr[1][i] = $coord[1]
endif

sleep(500)
mouseclick("left" , $coord[0] , $coord[1])
sleep(50)
mousedown("left")
$i = $i + 1
sleep(5000)
until $i = 1000

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

It's not obvious to me what you want to do so I've made a guess.

Dim $arr[2][1000]; 1000 x,y coords
$i = 0
Do

$coord = PixelSearch( 0, 0, 50000, 300, 0xCCCCCC)
if @error = 0 then
  $arr[0][i] =$coord[0]
  $arr[1][i] = $coord[1]
endif

sleep(500)
mouseclick("left" , $coord[0] , $coord[1])
sleep(50)
mousedown("left")
$i = $i + 1
sleep(5000)
until $i = 1000
That's what I assumed at first too but after some thought I got to wondering if

$arr[0]="coord[0]";; Note the change from "o" to "0"
$arr[1]="coord[1]"
wasn't done intentionally to be used in a MsgBox or something.

BTW; Martin, your code will error out.

$coord = PixelSearch( 0, 0, 50000, 300, 0xCCCCCC)
if @error = 0 then
  $arr[0][i] =$coord[0]
  $arr[1][i] = $coord[1]
endif

Should be

$coord = PixelSearch( 0, 0, 50000, 300, 0xCCCCCC)
if @error = 0 then
  $arr[0][$i] =$coord[0]
  $arr[1][$i] = $coord[1]
endif

Then of course there is the matter of the OP continually clicking at the same coordinates but perhaps that's what they want.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

First off, thanks for taking the time to help guys, but i'm still having compiling issues.

First off I just want the script to find the color, click it, wait 5 seconds, then find the color again and click it and keep repeating.

Martin I tried your script with GEOSoft's correction, but it continues to say:

mouseclick("left" , $coord[0] , $coord[1])

mouseclick("left" , $coord^ ERROR

Error: Subscript used with non-Array variable

I am finding it hard to see why this is occuring, maybe something wrong with the loop? Edited by Muchuchu

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

First off, thanks for taking the time to help guys, but i'm still having compiling issues.

First off I just want the script to find the color, click it, wait 5 seconds, then find the color again and click it and keep repeating.

Martin I tried your script with GEOSoft's correction, but it continues to say:

I am finding it hard to see why this is occuring, maybe something wrong with the loop?

Try

$coord = PixelSearch( 0, 0, 50000, 300, 0xCCCCCC)
if NOT @error then
  $arr[0][$i] =$coord[0]
  $arr[1][$i] = $coord[1]
  $I += 1
endif
Edit: Code would have exited just move your $I = $I + 1 to the way I have it now. Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

For some reason I think there is some type of bug, because I ran that once, and it worked fine, it kept finding the color and clicking it, so I stopped it and added a quit hotkey to exit quicker and it came out with that same error, and I know it's not the hotkeys that are messed up because I removed them and I continue to get the same exact error. Here is my current code:

hotkeyset("{BS}","quit")

Dim $arr[2][1000]; 1000 x,y coords

$i = 0

Do

$coord = PixelSearch( 0, 0, 50000, 300, 0x7B190F)

if @error = 0 then

$arr[0][$i] =$coord[0]

$arr[1][$i] = $coord[1]

endif

sleep(500)

mouseclick("left" , $coord[0] , $coord[1])

sleep(50)

mousedown("left")

$I += 1

sleep(5000)

until $i = 1000

func quit()

exit

endfunc

Can it be some type of bug? Edited by Muchuchu

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