Jump to content

Conditional click still clicking on wrong conditions?


DaRkf0x
 Share

Recommended Posts

Hello all :graduated:

First of all, don't be too harsh on me, I have little background in programming and although I've been using autoIt for some time, I never gave much thought into actually learning it as I don't have that much time AND I never really needed to, although I love it.

That being said, I'm trying to make a script that will click certain positions when, in a certain place, a popup will open (so as to close it) using:

MouseClick("left",818,242,1) ; close popup
    MouseClick("left",899,277,1) ; close erroneous dialog
    Mouseclick("left",901,287,1) ; close random dialog
    MouseClick("left",413,153,1) ; mandatory click
    sleep(500)

And it was working fine! But Now I've decided I don't want so many useless clicks, so I'm trying to make it click only if the pure white color is present (there is an X mark on the dialog which is pure white, and that pixel is never white unless the dialog is open).

What I'm using is:

MouseClick("left",818,242,1) ; close popup
    
    $color = pixelgetcolor(902,275)
    if $color = 16777215 then 
        Mouseclick("left",902,275,1) ; close erroneous dialog
    EndIf
    $color = pixelgetcolor(901,285)
    if $color = 16777215 then 
        Mouseclick("left",901,285,1) ; close random dialog
    EndIf
    
    MouseClick("left",413,153,1) ; mandatory click
    sleep(500)

Thing is, I still see the mouse moving to all those pixels! I mean two of them are mandatory clicks, but the other two are not, but the mouse still goes there and thus I still waste time going to uneeded places!

What am I doing wrong?

EDIT: Just realized I said some things I shouldn't in the post, and edited it so I don't break any rules. Sorry for anything.

Edited by DaRkf0x
Link to comment
Share on other sites

A longshot perhaps, but could it be that you are using the wrong PixelCoordMode? (Meaning, you might be looking in a different location for a white pixel and find it, and then click the mouse on the intended coordinates.)

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

A longshot perhaps, but could it be that you are using the wrong PixelCoordMode? (Meaning, you might be looking in a different location for a white pixel and find it, and then click the mouse on the intended coordinates.)

That could happen if I had switched the coordinates, like (y,x) instead of (x,y), but i'm pretty sure those are correct, in fact you can see the function is using, for example, x = 901, y = 285 for both MouseClick and PixelGetColor and I think it wouldn't be searching in a wrong place unless between processes it would change environment and/or they were relative coordinates..

You think maybe color shades have anything to do with it as normally that pixel is dark gray? Or maybe converting the color to Hex would help?

Or maybe I'm getting this wrong and AutoIt just moves the mouse to said coordinates to check the pixel without clicking it, which would be weird but still possible...

Link to comment
Share on other sites

That could happen if I had switched the coordinates, like (y,x) instead of (x,y), but i'm pretty sure those are correct, in fact you can see the function is using, for example, x = 901, y = 285 for both MouseClick and PixelGetColor and I think it wouldn't be searching in a wrong place unless between processes it would change environment and/or they were relative coordinates..

You think maybe color shades have anything to do with it as normally that pixel is dark gray? Or maybe converting the color to Hex would help?

Or maybe I'm getting this wrong and AutoIt just moves the mouse to said coordinates to check the pixel without clicking it, which would be weird but still possible...

What I mean is that PixelGetColor depends on PixelCoordMode, and MouseClick depends on MouseCoordMode. So if you set different modes for those two, the same coordinates could point to different locations of your screen. But if you haven't set either of those modes, they both default to "absolute screen coordinates" so then this is not the issue :graduated:

Using decimals for the color shouldn't be any problem.

/Edit: by the way, no, PixelGetColor shouldn't be moving the mouse. At least it isn't in my tests :(

Edited by SadBunny

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

What I mean is that PixelGetColor depends on PixelCoordMode, and MouseClick depends on MouseCoordMode. So if you set different modes for those two, the same coordinates could point to different locations of your screen. But if you haven't set either of those modes, they both default to "absolute screen coordinates" so then this is not the issue :graduated:

Using decimals for the color shouldn't be any problem.

/Edit: by the way, no, PixelGetColor shouldn't be moving the mouse. At least it isn't in my tests :(

Thanks for clearing that up, and for pointing out that the function shouldn't be moving the mouse, it's a huge step as now I know something is definitely wrong. Just need to figure out what :D

Link to comment
Share on other sites

I don't know what kind of application you are running, but are you sure the PixelGetColor reads the pixel correctly? I mean, if it's some kind of full screen application, it could be possible that the PixelGetColor searches in a big white square of the actual Windows window, and that the application itself writes directly to the graphics card buffer or something. I'm not that into screen grabbing, but what I would try is to take a line of pixels where you KNOW there should be lots of differently colored pixels, and write a for loop that dumps the colors of all pixels on that line to the console or something, and see if there are in fact lots of different colors reported or if they are in fact all white (which would indicate my hunch might be correct).

Roses are FF0000, violets are 0000FF... All my base are belong to you.

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...