Jump to content

Advanced pixelsearch (im beginner)


Mandi
 Share

Recommended Posts

Hello!

Im quite new to Autoit and would love some help. My question is about the pixelsearch function. I 

 

So I've two problems.

1. I've selected a Area to pixelsearch in. There is 3 diffrent spots of the the same pixel within the pixelsearch area, but the script tend to just stay in 1 spot.

2. Insted of using Sleep() delay to move from pixels within the area , I would like to automate it in a way where if the current pixel you on dispear it moves to another in the area. (I hope it makes sense)

 

Here is the short code

While

   $pixels = PixelSearch(808, 503, 1064, 685 , 0x484537, 1)


   if Not(@error) then
   LC($pixels[0], $pixels[1])
   sleep(15000)
 

WEnd


Func LC($x, $y)
   mouseclick( "left", $x, $y, 1, 1)
EndFunc
 

 

Link to comment
Share on other sites

While

   $pixels = PixelSearch(808, 503, 1064, 685 , 0x484537, 1)


   If Not(@error) then
   LC($pixels[0], $pixels[1])
   Do
       Sleep(50)
   Until PixelGetColor($pixels[0], $pixels[1]) <> 0x484537
   EndIf
WEnd


Func LC($x, $y)
   mouseclick( "left", $x, $y, 1, 1)
EndFunc

something like this?

Edited by badcoder123
forgot endif
Link to comment
Share on other sites

 

On 2018-09-19 at 5:11 AM, badcoder123 said:
While

   $pixels = PixelSearch(808, 503, 1064, 685 , 0x484537, 1)


   if Not(@error) then
   LC($pixels[0], $pixels[1])
   Do
       Sleep(50)
   Until PixelGetColor($pixels[0], $pixels[1]) <> 0x484537
 

WEnd


Func LC($x, $y)
   mouseclick( "left", $x, $y, 1, 1)
EndFunc

something like this?

Dont work :( So there is 2  buttons of the same colour. I want the script to press one and wait until the colour change, and then press on the other button. But it dont work... 

 

 

Link to comment
Share on other sites

It does the action 1 time, but i have problem looping it. 

while (1)
$pixel = pixelsearch( 764, 185,  815, 232, $color ,1)

If Not(@error) Then
LC ($pixel[0], $pixel[1])
EndIf
Do
sleep(500)
Until pixelgetcolor($pixel[0], $pixel[1]) <> $color

$pixel = pixelsearch( 804, 146, 856, 186, $color ,1)
If Not(@error) Then
LC ($pixel[0], $pixel[1])
EndIf
Do
sleep(500)
Until pixelgetcolor($pixel[0], $pixel[1]) <> $color


WEnd


Func LC($x, $y)
   mouseclick( "left", $x, $y, 1, 1)
EndFunc

Link to comment
Share on other sites

1 hour ago, k0ownzz said:

It does the action 1 time, but i have problem looping it. 

while (1)
$pixel = pixelsearch( 764, 185,  815, 232, $color ,1)

If Not(@error) Then
LC ($pixel[0], $pixel[1])
EndIf
Do
sleep(500)
Until pixelgetcolor($pixel[0], $pixel[1]) <> $color

$pixel = pixelsearch( 804, 146, 856, 186, $color ,1)
If Not(@error) Then
LC ($pixel[0], $pixel[1])
EndIf
Do
sleep(500)
Until pixelgetcolor($pixel[0], $pixel[1]) <> $color


WEnd


Func LC($x, $y)
   mouseclick( "left", $x, $y, 1, 1)
EndFunc

made an edit to first comment - retry

Edited by badcoder123
Link to comment
Share on other sites

Lets start out with the application you wish to automate. I ask this for in many cases we have already coded what you have tried to do and it is a simple matter of finding the code you need. Also using pixel searching is the worst way to automate for if there is any changes in color your script breaks. Thanks in advance.

 

Link to comment
Share on other sites

Hello. I wanted to do pixelsearch and left mouseclick in my script, but it clicked the wrong location. I did search for answers and minimized screen is my problem. Is there any way to bypass this??? would love to know

 

Kind regards

 

Link to comment
Share on other sites

  • Moderators

Why did you start a new thread? And yes, there is a way to bypass it - stop using pixelsearch which is unreliable and start using Control* commands. But as has been pointed out, so long as you are not providing info on what you are trying to accomplish it is a bit difficult to assist.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

14 minutes ago, JLogan3o13 said:

Why did you start a new thread? And yes, there is a way to bypass it - stop using pixelsearch which is unreliable and start using Control* commands. But as has been pointed out, so long as you are not providing info on what you are trying to accomplish it is a bit difficult to assist.

 

I started a thread since I could not find a solution for the problem. I want the script to scan a area for a specific colour. If the color is found  then i want to click it. I had no problem with it in the past on fullscreen windows, but When i've the window minimized/smaller it dosent work.(I dont have it tabbed down, the window im using is just no fullscreen). It simply will just click on wrong spot insted of clicking the color and i dont have this problem with fullscreen windows... Would love help with it

 

AutoItSetOption ("MouseCoordMode", 0)

winactive ("X.X.X")

 

$pixel = PixelSearch(7, 9, 508, 329, 0x64483F, 1)

If Not (@error) Then
sleep(300)
LC ($pixel[0], $Pixel[1])
EndIf

 


Func LC ($x, $y)
   mouseclick ("left", $x, $y, 1, 15)
EndFunc

 

 

 

Link to comment
Share on other sites

  • Moderators

Stick to one thread in the future. And you still haven't explained why you can't use Control* commands.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

4 minutes ago, JLogan3o13 said:

Stick to one thread in the future. And you still haven't explained why you can't use Control* commands.

If i understand right controlclick is = click that dosen't involve your mouse having to click? Does that mean i can do other things on computer while running script?

 

How can i make controlclick insted of LC/ Left mouseclick like the example above?

 

I made this thread since i could not find answer. Could you link me to a thread with same problem and solution?

Edited by Mandi
Adding information
Link to comment
Share on other sites

  • Moderators

Yes, it clicks on the control without you having to move the mouse, the window doesn't even have to be active. You can view the example in the help file and try to match to your needs, or you can use the AutoIt Window Info Tool (in the same directory where you installed AutoIt) on the window and control you're trying to click on and post here so we have some actual information to help you.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

The entire point is you cannot. If you want a resolution to your problem you need to provide an example of the window you're trying to search on, and why it must stay minimized. We cannot both guess at what you're trying to do and try and fix it for you. Help us help you.

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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