Jump to content

Image/Pixel Search - of sorts


Recommended Posts

I don't really know what this is called, which is why I'm here. I need AutoIt to click a button in a program written in Fox Pro. The problem is the button cannot be detected by AU3Info and does not have a hotkey or tabindex, so I'm left scratching my head as to how to get it to click the area. This needs to be flexible so I can't depend on mouse move and such.

Is there a way to define a set of pixels (an image) and then have the mouse move to and click that area?

Any direction is MUCH appreciated. I've never done something like this and the info in the manual and what I've searched on the forum is cool but doesn't do what I need it to.

thank you!

A decision is a powerful thing
Link to comment
Share on other sites

If the button stays still you could use a old UDF called mouse click two? Anyways i remember that it will click in any window using the coordnates relative to that window and the window can be minimized or whatever. Bit simpler then the pixel thing =].

[center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw

Link to comment
Share on other sites

  • Moderators

If the button stays still you could use a old UDF called mouse click two? Anyways i remember that it will click in any window using the coordnates relative to that window and the window can be minimized or whatever. Bit simpler then the pixel thing =].

That's encouraging... not only do you not have the correct name or the link of the UDF (_MouseClickPlus() (Makes it kind of hard to look for your option doesn't it?)), you didn't note that he doesn't want to use specific coords.

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

My understanding was that he afraid of the overall window moving. Or some other unforseen problem of that nature. _MouseClickPlus() would solve that problem. And the last time I looked at that function was over a year ago so excuse me for not being able to remember the correct name. I was just giving a simple option that I thought would help. No need to rip my head off.

[center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw

Link to comment
Share on other sites

  • Moderators

My understanding was that he afraid of the overall window moving. Or some other unforseen problem of that nature. _MouseClickPlus() would solve that problem. And the last time I looked at that function was over a year ago so excuse me for not being able to remember the correct name. I was just giving a simple option that I thought would help. No need to rip my head off.

I wasn't ripping your head off. Pretend like you didn't write what you wrote, and re-read it... Did your post actually help in anyway other than possibly confuse him/her?

Now, I'm going to out out on a limb and say, you are suggesting (On top of _MouseClickPlus()) possibly using Client Coords for the coords of the location he wants to click so that regardless of where the window is (as long as active with regular MouseClick) he/she would still be able to click the desired location, unlike using the Default of Screen for the coords... Which in that case... that's a good idea.

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

smoke_n and fear1313,

Thank you both for the direction! I am a dude, so he is fine :whistle: I am busy reading up on what you both suggested. I haven't ever used any of the pixel functions before and typically try to avoid specific coors (as you mentioned). However, it sounds like this will do what I'm wanting (ie. set the coors after looking for them).

Quick question: I'm a bit confused. Smoke_N, so what you initially pointed to is not what I should keep researching?

A decision is a powerful thing
Link to comment
Share on other sites

  • Moderators

smoke_n and fear1313,

Thank you both for the direction! I am a dude, so he is fine :whistle: I am busy reading up on what you both suggested. I haven't ever used any of the pixel functions before and typically try to avoid specific coors (as you mentioned). However, it sounds like this will do what I'm wanting (ie. set the coors after looking for them).

Quick question: I'm a bit confused. Smoke_N, so what you initially pointed to is not what I should keep researching?

I only answered your specific question you asked with the link I provided.

I only use the pixel functions when it is absolutely necessary personally.

If a button (let's say it's a pic) is always in the same spot, and I'm clicking on that button controlled within my script at my leisure and not if some Pixel event tells me too, then I use Client Coordinates of that location. That way, even if you move the window, or your screen resolution is different from what I have as the coder, or you are using a different theme than I am as a the coder, your client coords are always relative to the client area itself, not the actual window position.

Again, keep in mind that with MouseClick, that you must have the window to interact with active.

Edit:

I will add, that in 99.99% of the scripts I write, I use client coordinates for both MouseClick and Pixel* functions.

Edited by SmOke_N

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

I only answered your specific question you asked with the link I provided.

Yeah, thank you! I know you were doing so. I appreciate you addressing what I specifically asked. I thought about what I wanted to write before I wrote it out. Really any information can be helpful for me.

As for the client coors, I don't know exactly what you're talking about. I found this in the manual - CaretCoordMode. Is that it? I'll do a forum search right now.

As for the _MouseClickPlus, I can find a lot of people talking about it in the forums and I see it's an include file. However, I can't seem to find the original au3 file.

Thanks!!

Edited by JohnBailey
A decision is a powerful thing
Link to comment
Share on other sites

  • Moderators

For Client Coords.

Au3Info.exe (window tool)

Options

Coord Mode

Client

How to change from standard (for Pixel*/MouseClick function) coords.

Opt

MouseCoordMode ... Client = 2

PixelCoordMode ... Client = 2

For searching use advanced search... if someone says it's a function or UDF then always try the Example Script forum first for the search to narrow it down.

_MouseClickPlus

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

Ok i am having some trouble i am a total newb when it comes to scripting... I got basicly the same issue with this guy. I have to click a button that is in an area but the button changes places... but is in the same general area. the color of the botton is totally different than any other colors in the region so it can be picked out.. so i made this... i am doing something totally wrong please give me some ideas :whistle: and remember talk to me like im 10. :)

Traveling.au3

Link to comment
Share on other sites

Here is one that I've done:

Button_coord = PixelSearch(0, 0, 1000, 1000, 0xFCCC00, 0, 0)
    If Not @error Then
        $Button_x = $Button_coord[0]
        $Button_y = $Button_coord[1]
        mouseclick('left', $Button_x, $Button_y, 1, 0)
    EndIf

You'll need to replace the FCCC00 with the hex code of the pixel colour of your button for it to find.

You may find that it puts the mouse over the top left of the button where the pixel is first found and sometimes this isn't clickable, so just do the following to move the mouse slightly to the right and down to correct it:

$Button_x = $Button_coord[0] + 5

$Button_y = $Button_coord[1] + 5

Edited by saldous
Link to comment
Share on other sites

sleep(15000)

Button_coord = PixelSearch(0, 0, 1000, 1000, 0xFFFF00, 0, 0)

If Not @error Then

$Button_x = $Button_coord[0] + 5

$Button_y = $Button_coord[1] + 5

mouseclick('left', $Button_x, $Button_y, 1, 0)

EndIf

nope still not even moving the mouse to the spot.. remember im still a total newb at this...im getting this error:

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Documents and Settings\Adam\Desktop\Traveling.au3"

C:\Documents and Settings\Adam\Desktop\Traveling.au3 (3) : ==> Error parsing function call.:

Button_coord = PixelSearch(0, 0, 1000, 1000, 0xFFFF00, 0, 0)

^ ERROR

>Exit code: 0 Time: 15.222

Edited by Adamrl018
Link to comment
Share on other sites

  • Moderators

sleep(15000)

Button_coord = PixelSearch(0, 0, 0, 0, 0xFFFF00, 0, 0)

If Not @error Then

$Button_x = $Button_coord[0] + 5

$Button_y = $Button_coord[1] + 5

mouseclick('left', $Button_x, $Button_y, 1, 0)

EndIf

nope still not even moving the mouse to the spot.. remember im still a total newb at this...im getting this error:

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Documents and Settings\Adam\Desktop\Traveling.au3"

C:\Documents and Settings\Adam\Desktop\Traveling.au3 (3) : ==> Error parsing function call.:

Button_coord = PixelSearch(0, 0, 0, 0, 0xFFFF00, 0, 0)

^ ERROR

>Exit code: 0 Time: 15.222

:whistle: @myself... I was going to post to remember to put a $ in front of Button_coord to make it a variable (probably cut off in th copy and paste) or it would throw you an error... but I said to myself... surely he would understand that or if an error came up he would know to do that comparing that to the rest of the script.... then I saw your date of join (which means nothing really)... so I guess you didn't put the 2 and 2 together :) .

$Button_coord = PixelSearch(0, 0, 0, 0, 0xFFFF00, 0, 0)
    If Not @error Then
      $Button_x = $Button_coord[0] + 5
      $Button_y = $Button_coord[1] + 5 
        mouseclick('left', $Button_x, $Button_y, 1, 0)
    EndIf

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

Thanks SmOke N for noticing the "$" missing, copy and paste missed it off when highlighting.

If you have the code in SciTE then click on Tools, Compile (or Ctrl + F7), or use the "compile script to .exe" tool which is in the Start Menu items in the AutoIT folder.

Link to comment
Share on other sites

Smoke_N, thanks for the awesome advice about searching the forums! I use the advance search as much as I can, but not that I know the stipulations for udfs and the like that will help a ton.

I've been trying to figure this out. How do I do the pixel group? It's driving me nuts. I looked at your array idea but I can't seem to make it work as a single group. I'm wondering if I should do some more research on OCR related things. Maybe I'm totally not understanding.

A decision is a powerful thing
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...