SyncStark

How can I loop a PixelSearch ?

10 posts in this topic

Hi, I would like some help, I explain myself :

I would like my bot detects a button that appears several times between two time requiring automated actions that the bot does not need to.

But I do not know how to do, I tried to make a code with a "First time" (First time to the first button, Second Time for the second button etc.)

And a system of HuntPixel, which is 0 to 3 if the bot can not find the button it adds 1 to HuntPixel, it reached 3 then it will abandon the search and press another button.

I did all this in a function but when I call, it does not work!

I give you all the code, I also wonder if it was possible to improve it or if I made mistakes that I can correct.

Thank you very much !

;FT MEANS FIRST TIME, I WILL ADD ST AND TT

HotKeySet("{F9}", "MyExit")

;-----VARIABLES-----

Global $MouseLeft
Global $HuntPixelFT = 0


Global $ColorSkipButton = 0x2C3A47

 Global $LeftSkip = 613
 Global $TopSkip = 28
 Global $RightSkip = 677
 Global $BottomSkip = 47

 Global $ClickMouse = $MouseLeft
 Global $SearchResult

;-----FONCTIONS-----

Func MyExit()
         Exit
      EndFunc


Func AutoSkipFT()

While 1
   $SearchResult = PixelSearch($LeftSkip, $TopSkip, $RightSkip, $BottomSkip, $ColorSkipButton, 5)

     If @error Then
        ContinueLoop
        $HuntPixelFT = $HuntPixelFT +1

        ElseIf $HuntPixelFT = 3 Then

           ExitLoop

            Sleep(2000)

           MouseClick("Left", 497, 349)

      EndIf
Wend

EndFunc

;-----CODE-----

 WinActivate("Mobizen")

Sleep(1000)

WinMove("Mobizen", "", 0, 0)

sleep(500)

MouseClick("left", 490, 339)

sleep(4000)

MouseClick("left", 581, 132)

sleep(2000)

MouseClick("left", 490, 339)

Sleep(20000)

AutoSkipFT()

 

Share this post


Link to post
Share on other sites



Why can't you access the button by it's ID?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
On 18/3/2016 at 5:06 PM, water said:

Why can't you access the button by it's ID?

It's ID ? Where can I find a ID's Button ? By the way it's not a button you can find on Internet Explorer, Google Chrome or any Form it's just a mirrorred button on an Android Screen from Mobizen

Share this post


Link to post
Share on other sites

You didn't give enough information about your environment in the OP so I could only guess.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

@SyncStark, can you please explain in detail what you are attempting to do? What is Mobizen, and how are you trying to manipulate the app?


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

Share this post


Link to post
Share on other sites
42 minutes ago, JLogan3o13 said:

@SyncStark, can you please explain in detail what you are attempting to do? What is Mobizen, and how are you trying to manipulate the app?

From my understanding, Mobizen allows you to control you Android Phone from a Desktop Chrome Browser

Share this post


Link to post
Share on other sites

@Dgameman1 yes, I can Google as well. I am attempting to get the OP to provide a more detailed explanation to help us help him ;)


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

Share this post


Link to post
Share on other sites
1 minute ago, JLogan3o13 said:

@Dgameman1 yes, I can Google as well. I am attempting to get the OP to provide a more detailed explanation to help us help him ;)

I figured, I was just trying to help :P

Share this post


Link to post
Share on other sites
11 hours ago, Dgameman1 said:

From my understanding, Mobizen allows you to control you Android Phone from a Desktop Chrome Browser

Yes, he's right, I'll explain more :

 

What I want is to create a bot that would detect the color of a button in a perimeter given by X and Y rectangle. In my first attempt , I tried to repeat the same code multiple times for there to be several detections. The problem is that it takes too much time to the bot, it makes a lot of writing for nothing and I want it faster , for example, that repeats the code several times himself until that it detects the color and in result it stops wanting to find . I inquired with the functions Do , Until but I have no idea where and when to use them , I also tested While, Wend but the problem is that even after executed with a StopLoop he kept still ...

Share this post


Link to post
Share on other sites

is there any reason why you can't use an app that works on the android platform to automate what you have in  mind? I did a quick google search and found a few.

https://www.google.com/search?num=100&q=android+automation+app&spell=1&sa=X&ved=0ahUKEwjA_IqN4NDLAhVIqx4KHUEpCPYQvwUIGigA&biw=1600&bih=654

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