Jump to content
serena_knight

pixelsearch does not return array

Recommended Posts

$xy = pixelsearch($ul,$top,$hrt,$bbot,0,1,$win)

msgbox(0,"",@error) ; returns 0  which mean command executed

_arraydisplay($xy)  ; returns 0

msgbox(0,"", $xy[0] & "  " & $xy[1])  ; fails suscript used on non-accessible variable

these commands worked in a previous pass using the same top and bottom coords

also the text being examined is the same color code.

why would the command return error = 0 and not the xy?

 

 

Share this post


Link to post
Share on other sites
Posted (edited)
3 minutes ago, serena_knight said:

why would the command return error = 0 and not the xy?

What does the Helpfile say about that? ;) 

Also seems you parameters aren't correct.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
24 minutes ago, serena_knight said:

also the text being examined is the same color code

And the color is ?

Share this post


Link to post
Share on other sites

yes i forgot to include the color code on this example...its 0x319aff

$xy = pixelsearch($ul,$top,$hrt,$bbot,0x319aff,0,1,$win)

the code was given by the info tool

 

 

Share this post


Link to post
Share on other sites

At first glance, with the color code it should work.  There must be something surrounding the code that you are not showing that creates this distortion.  Providing a runable snippet where the error occurs would help us find the problem.

Since you are there, please use this tool when you post code. Thanks.

Share this post


Link to post
Share on other sites

ty Nine, i forgot about the <> useage, to provide a runable snippet would require sending the java source behind the webpage and my script, both would be infeasible because behind the webpage is a database used to paint the page. also the company would fire me if i did any of this.  so i will try to explain in the best detail i can what is happening.

the page presents on the left side of the screen with a value of aaadev 

i used a ctrl+c (find command) to locate it, it does and highlight that value

i use the pixelsearch to find the highlight value which is that  background color and it finds it with no problem

next the value bbbdev is under the aaadev

i again issue a find command for the value and the the value is highlighted

i again issue the pixelsearch , the return code is 0 which says it found the highlighted 

i issued a _arraydisplay of the array returned by teh pixelsearch and test @error which returns a  "1"  array is not an array

i believe somehow that the first find of aaadev has interfeared with the find of bbbdev , note that aaadev is not highlighted at this

time.  

i isolated code to try to find the bbbdev  only and not find eh aaadev before that  and the  code  worked which proves that somehow the 

previous find of aaadev  interfeares with the find of bbbdev

 

so it seems some kind of reset of the pixelsearch is in order.   is there a way  to do that?

 

 

 

 

Share this post


Link to post
Share on other sites

There is no need to reset PixelSearch.  I have been using PixelSearch extensively in some situations and it worked perfectly well.  Since you don't want to share a larger part of your script, it is very hard to help you. If you can't provide us with the real life screen, you could try to replicate your problem using Paint or Notepad.

In any case, just remember that when a PixelSearch returns an error, the array result is replaced with a single value.  So it is not an array anymore.  I believe that your script is badly looking at @error and PixelSearch has erased the underlying array.  Until you can at least provide the surrounding statements of your script, I do not think I can help you further...

Share this post


Link to post
Share on other sites

i agree Nine, what about this,,, pixeshearch creates the array (right?) i.e. i don't define it with a dim statement

i tried to do a _arraydelete but that didn't seem to work, how can i completelly delete the array

Share this post


Link to post
Share on other sites

i give up,, all i wanted to find was the x,y of the highlighted text so i could do a mouse move to that position.

i can find no where  on the internet how to do this.

Share this post


Link to post
Share on other sites
Posted (edited)
Local $xy = pixelsearch($ul,$top,$hrt,$bbot,0x319aff,0,1,$win)
If @error Then
    MsgBox ( 48,"","error code:" & @error )
Else
    MsgBox ( 64,"","x:" & $xy[0] & "y:" & $xy[1] )
EndIf

If the pixelsearch fails you DON'T get an array how @Nine already said. So you won't get the xy!

maybe you got the color when the mouse was over the text and it's different to the color when the mouse isnt there?

Edited by Aelc

why do i get garbage when i buy garbage bags? <_<

Share this post


Link to post
Share on other sites

Aelc the text is highlighted and the info tool show color 0x319aff i have done a number of tests and the conclusion is that executing a pixelsearch a 2nd time

does not return an array   a _arraydisplay return code says the array is not an array

also i have tried using a pixelsearch on the first pass (it works) an using a different pixelsearch with a different array name(wy2 for the 2nd pass and that one also fails.  its as if you can not issue 2 pixelsearchs in the same script.  i have spent hours on this problem and cant find a solution.  

Share this post


Link to post
Share on other sites

What is your display scale set to? If it's over 100% then you're probably reading the wrong location.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

i'm not, i can plainly see the screen. if have done this a number of different ways, and result is always the same

a 2nd execution of pixelsearch does not return an array. anyway with my script it doesn't. i have changed the find to find a different text

and the result is the same. i need an alternate way of finding  a highlight text on the web page. and because it is a java created page

i don't have access to _IE functions. 

Share this post


Link to post
Share on other sites
1 hour ago, serena_knight said:

i'm not, i can plainly see the screen.

Was this an answer to my question? Because seeing the screen has nothing to do with what I asked you.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Posted (edited)

@serena_knight can you post more of your script? i guess there is a problem around pixelsearch e.g. with variables called inside

btw you said 4 times it's not an array.. so which error code do you have?

Edited by Aelc

why do i get garbage when i buy garbage bags? <_<

Share this post


Link to post
Share on other sites

i think this is going to be it, my code centers on the the used of the pixelsearch working, 

i loop in the code , the first pass works, the second pass does not, the return code of pixelsearch says it found the color

the _arraydisplay of that array says it is not an array.  @error = 1

i have done a lot of different tests and all i can determine is that the first pass create and array and is fine

because the array is not created the second pass fails to recreate the array.

in 50 years of working with all kinds of code, i have never found a situation i could not resolve. this one has beat me.

i have worked with operating systems, modified them, worked with machine code, i do know how to diagnose things, but this has beat me.

all i can say there is a software problem with pixelsearch

Share this post


Link to post
Share on other sites
6 minutes ago, serena_knight said:

n 50 years of working with all kinds of code, i have never found a situation i could not resolve. this one has beat me.

i have worked with operating systems, modified them, worked with machine code, i do know how to diagnose things, but this has beat me.

all i can say there is a software problem with pixelsearch

Funny ....   you ask a question here, don't answer specific questions asked, don't show any code, but am still able to conclude that?  

Jos


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
17 minutes ago, serena_knight said:

all i can say there is a software problem with pixelsearch

No, there is not.  I already told you that I am using PixelSearch extensively without a single issue.  The problem is your code that you are too afraid to show us.

Share this post


Link to post
Share on other sites

my last ditch effort.

i coded, this before the pixelsearch

redim $xy[2][1]

$xy[0][0] = 0

$xy[1][0] = 0

the first pass thru, not problem

the second pass thru , again _arraydisplay returns @error = 1

 

 

Share this post


Link to post
Share on other sites
Posted (edited)

Nine, what code would you like me to show you?   

$xy = pixelsearch($ul,$top,$hrt,$bbot,0,1,$win)

the values of $ul, $top, $hrt, $bbot, $win ?

besides the problem of violating company policy there is the problem of coping anything off my 

remote access to my computer at work and then pasting it here, the company security system blocks any such

copy/paste attempt.  I would love to show you everything, can't 

the code is very simple, it loops through the pixel search 2 times. 

there is a send("{f3}") 

send("aaadev") to the find box, which highlights aaadev before the pixelsearch

that one works

i wish there was another way to do this:  find the hightlighted text and move the mouse there, then i would use the mousepos to get the x and y points

 

 

 

on the 2nd send f3 and send bbbdev the bbbdev is highlighted  and then the array is not returned

 

Edited by serena_knight

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...