Jump to content

Trouble Using ImageSearch


Recommended Posts

Hello Everybody!

I'm new here (as you can see; first post) and also new to AutoIt. I have done lots of search and browsing of the forum to learn what I'm doing wrong, but I just can't figure it out. Hopefully one of you can help me.

I finally figured out how to launch and get the handle of the program I'm automating (Bluestacks, and android emulator). Now I would like to search within that window to find a button, then click that button. To do that I'm trying to use ImageSearch from here:

 

#include <ScreenCapture.au3>
#include <ImageSearch.au3>

$AndroidPID = Run ("C:\ProgramData\BlueStacksGameManager\BlueStacks.exe")

Sleep(250)

$AndroidHWND = WinGetHandle("[ACTIVE]")

$AndroidPos = WinGetPos($AndroidHWND) ;--> [0] = X pos, [1] = Y pos; [2] = Width; [3] = Height

$x = 0
$y = 0

$found = _ImageSearchArea("FindMe.bmp", 1, $AndroidPos[0], $AndroidPos[1], $AndroidPos[2], $AndroidPos[3], $x, $y, 100)

If $found = 1 Then
    MouseMove($x,$y, 10)
EndIf

MsgBox (0, '', $found)
;--> Returns 0

MsgBox(0, '', $AndroidPos[0] & @CRLF & $AndroidPos[1] &@CRLF &  $AndroidPos[2] &@CRLF &  $AndroidPos[3])
;--> Returns 0, 0, 1602, 950

Thanks!

Adam

Link to comment
Share on other sites

Hi @astranberg and welcome to AutoIt Forum.


I do like Android and I work with android alot, please explain what or why you need this because maybe I could help you to do it with another approach. In a different way i mean.

I cant help you with BlueStack because I finish with them long time ago.

Kind Regards
Alien.

Link to comment
Share on other sites

Thanks @alien4u!

Awesome! The ultimate project is to automate a game called Clash Royale. I am not going to do anything crazy like they have for Clash of Clans bots (I'm assuming you're familiar). Here is the grand scheme:

  1. Launch Clash Royale
  2. Click a couple buttons to launch a game against the 'trainer'.
  3. Playing the game will consist of recognizing resource level ("Elixir" can be anywhere between 0-10), clicking on cards to select them, and clicking on the battlefield.

Right now I'm just trying to click the button to launch Clash Royale.

Link to comment
Share on other sites

  • Jos locked this topic
Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...