SmithWesson

Help with PixelSearch (newbie Autoit user)

16 posts in this topic

#1 ·  Posted

Hello Autoit users!

 

I am trying to write a script that will auto play videos for me on a website similar to Netflix's auto start feature. This is rather simple, each show is 30 minutes long, and I want it to just click on the drop down menu, select the next one in line and then click the play button once it reloads. I have a window that needs closed periodically that's a screen popup, that has a specific color to it. I wrote the script to target the color that the play button turns once it's finished the show so that was easy, but I wanted to put in a safety that if the pop up is up (color is available) to click in it's close location first, then if that color is no longer available on the screen to simply click the 2nd color. This would just run waiting for either color to show up with color1 being priority of click, and color2 being secondary. 

 

Think you could look at this and tell me where my brain is failing? I'm using lose knowledge of programming languages to make this work. Hope it's not terrible. The problem is that it just keeps selecting the second color regardless if the first is present or not.

 

Func Autoplay();
While 1
$coord = PixelSearch(20, 50, 515, 415, $color1, 0)
If @error = 0 Then
   sleep (100);
   $coord = PixelSearch(20, 50, 515, 415, $color1, 0)
Else
   sleep (100);
   $coord = PixelSearch(20, 50, 515, 415, $color2, 0)
EndIf

 

Share this post


Link to post
Share on other sites



#2 ·  Posted

@SmithWesson is this for Netflix? If not, what site? Have you checked the site's TOS or EULA before trying to automate the service?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#3 ·  Posted

It's a Kodi plugin, it's opensource and no restrictions on automation.

Share this post


Link to post
Share on other sites

#4 ·  Posted

Anyone have an idea of something else that would work outside of pixelsearch? This goes behind my fun project for auto play, I really only thought of that as a project to try and teach myself scripting. I have prior programming background and like to try and advance myself with new languages and applications. It's bugging my mind that I can't fix this logic, was hoping it was something simple that I was over looking.

Share this post


Link to post
Share on other sites

#5 ·  Posted

Use one of the browser automation UDFs?

Share this post


Link to post
Share on other sites

#6 ·  Posted

2 hours ago, Danp2 said:

Use one of the browser automation UDFs?

I could certainly try that. I was hoping to learn how to prioritize actions within AutoIt. I'm merely curious on learning more about how AutoIt works and what I'm missing with this. There are several other options I could do for browser control and such.

 

Am I getting any closer to a better logic step with this? It doesn't seem to work either, it just keeps clicking on $color2 regardless if $color is present or not.

 

Func Auto();
   Local $colors[2] = [$color, $color2]
While 1
For $i = 0 To 1
$c = PixelSearch(20, 50, 515, 415, $colors[$i])
If IsArray($c) Then
 MouseClick("Primary",$c[0],$c[1]);

 

Share this post


Link to post
Share on other sites

#7 ·  Posted

No idea, because your code is incomplete. It shouldn't even run with the missing EndFunc, WEnd, Next, etc.

Share this post


Link to post
Share on other sites

#8 ·  Posted

4 minutes ago, Danp2 said:

No idea, because your code is incomplete. It shouldn't even run with the missing EndFunc, WEnd, Next, etc.

This is just an exert from all the code I have written. The script goes onto do other things, all of which work. The only problem I'm having is this portion of the code with regard to the logic sequence. I tried to not give all the lines of data so you guys didn't have to comb through it all. It executes just fine, and clicks on $color2 all day, but acts as if it doesn't see $color.

 

do you need the full function? see below:

Func Auto();
    While 1
        For $i = 0 To 1
            $c = PixelSearch(20, 50, 515, 415, $colors[$i])
        If IsArray($c) Then
            MouseClick("Primary",$c[0],$c[1],5);
            $newcoord1color = PixelGetColor($coordcheck1[0],$coordcheck1[1]);
            $newcoord2color = PixelGetColor($coordcheck2[0],$coordcheck2[1]);
            $newcoord3color = PixelGetColor($coordcheck3[0],$coordcheck3[1]);
            checkscreen();
            pausewhileplay();
        If PixelGetColor($screenstatus[0],$screenstatus[1]) = 0x000000 Then
            send($fkey);
        EndIf
        EndIf
    WEnd
EndFunc

 

Share this post


Link to post
Share on other sites

#9 ·  Posted

There are so many different things that could be wrong here, so I'm not sure how you expect us to assist you with this.

IMO, PixelSearch should only be used as a last resort.

Share this post


Link to post
Share on other sites

#10 ·  Posted

27 minutes ago, Danp2 said:

There are so many different things that could be wrong here, so I'm not sure how you expect us to assist you with this.

IMO, PixelSearch should only be used as a last resort.

There's that many things wrong with trying to define a priority list of variables to have PixelSearch use? I guess what I was thinking this software was capable of wasn't accurate. I must have misunderstood how pixelsearch works. Thanks for the help I suppose.

 

Is there another option that reads screen for color change up or does AutoIt not do that function well?

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Do the popups appear on the page?

Edited by aa2zz6

Share this post


Link to post
Share on other sites

#12 ·  Posted

5 minutes ago, aa2zz6 said:

Does the popups appear on the page?

Yes, they are coded within the source. This isn't a website, I just used that term. It's an opensource media app that has 3rd party programs.

Really the application I'm trying to use it for doesn't matter to me, as much as the understanding of logic. I guess what's confusing me is the static I'm getting back when just trying to ask about how the logic works within AutoIt. I wasn't looking for anyone to write the script for me, or troubleshoot it. the script was written by me for fun to try and do different things and learn along the way. 


I more so wanted to understand why AutoIt (or PixelSearch) isn't using priority (do this or this, do this and then do this) type of mentality. Seems like it would do the first declared action first, and if it's not able to or it's not true, continue the execution.

 

Sorry if this is more confusing than it's worth, I was merely curious what I was doing wrong with that regard. It's looking more and more like AutoIt doesn't handle pixel color detection quite as well as I thought it did from reading about PixelSearch in the help guides.

Share this post


Link to post
Share on other sites

#13 ·  Posted

Can you post the link to the website? If not, I understand but as Damp2 mentioned it's difficult to give advise when there could be a methods to implement.

Share this post


Link to post
Share on other sites

#14 ·  Posted

1 minute ago, aa2zz6 said:

Can you post the link to the website? If not, I understand but as Damp2 mentioned it's difficult to give advise when there could be a methods to implement.

no website, it's an application that I run on the PC.

No worries I guess, I again just thought it was a problem with my logic. The function above is essentially everything to it. I just want it to look for color X, if color X isn't on the page then look for color Y and click. If color X is on the page, click that instead. rinse. repeat.

Share this post


Link to post
Share on other sites

#15 ·  Posted

18 minutes ago, SmithWesson said:

This isn't a website, I just used that term. It's an opensource media app that has 3rd party programs.

If it isn't a website, the nix the suggestion of using one of the browser UDFs. Next time, tell us what it is to avoid leading us down the wrong path.

Share this post


Link to post
Share on other sites

#16 ·  Posted

Have you tried using AU3Info to examine the window(s)? Have you tried using WinExists to detect the popup window?

Post some screen shots so that we have an idea of what the environment is like.

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