Jump to content

How can I loop a PixelSearch ?


Recommended Posts

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()

 

Link to comment
Share on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • Moderators

@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?

"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

@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 ;)

"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

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

Link to comment
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

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