WnG88

MEmu Emulator

6 posts in this topic

Hi,

I'm trying to use AutoIT with MEmu emulator just to do a basic task of launching a program on the desktop. This wasn't an issue when using VirtualBox.  Anyone have experience using AutoIT with MEmu? I'd like to move over to using it instead of VirtualBox. MEmu just runs Android apps better. Thanks.

I am using the following basic code:

Func Test()
    $Success= ControlClick("[CLASS:Qt5QWindowIcon]", "", "[CLASSNN:SQt5QWindowIcon6]", "", "", "290", "200")
    Switch $Success
        Case 0
            ConsoleWrite ("ControlClick Failed" & @CRLF)
        Case 1
            ConsoleWrite ("ControlClick Success" & @CRLF)
    EndSwitch
EndFunc

 

I think the CLASSNN isn't right even though AU3Info is saying this is the control.  I've also tried using another bit of code from the forums that catches the CLASSNN based on Mouse Position - again it works with VirtualBox but not MEmu.

 

; Function Name:    _CtrlGetByPos()
; Description:      Get the Control ID or the ClassNameNN by the X and Y client coordinates
; Syntax:           _CtrlGetByPos("Window Title", [Control Text], [X Client Coord], [Y Client Coord], [Return Type])
;
; Parameter(s):     $hWin               = Window Name or Handle
;                   $sText              = Text of the Control
;                   $iXPos              = X Client Coord
;                   $iYPos              = Y Client Coord
;                   $iReturnType        = Return type (default = 0 (ClassNameNN))
;                                           0 = ClassNameNN
;                                           1 = Control ID
;                                           2 = Control Handle
;                                           3 = All 3 ClassNameNN, Control ID, Control Handle
;
;
; Requirement(s):   External:           = None.
;                   Internal:           = AutoIt Beta 3.1.130 (or which ever release SetError(0,0,0) was introduced)
;
; Return Value(s):  On Success:         = Returns Array List
;                   On Failure:         = @error 1 (Control was found but there was an error with the DLLCall)
;                   On Failure:         = @error 2 (No classes were found)
;
; Author(s):        SmOke_N
;
; Note(s):          Similar to LxP's here (This was made before I remembered he had done something similar)
;                   <a href='http://www.autoitscript.com/forum/index.php?showtopic=14323&hl=' class='bbc_url' title=''>http://www.autoitscript.com/forum/index.php?showtopic=14323&hl=</a>
;
;
; Example(s):
;   Opt('WinTitleMatchMode', 4)
;   _CtrlGetByPos('classname=SciTEWindow', '', 829, 504, 2)
;
;Global $Control_To_Interact_With_Is = _CtrlGetByPos($window[1], '', 840, 50, 3)
;If IsArray($Control_To_Interact_With_Is) Then
;    For $i = 1 To UBound($Control_To_Interact_With_Is) - 1
;        MsgBox(0, '', $Control_To_Interact_With_Is[$i])
;    Next
;EndIf

Func _CtrlGetByPos($hWin, $sText = '', $iXPos = 0, $iYPos = 0, $iReturnType = 0)
    If IsString($hWin) Then $hWin = WinGetHandle($hWin)
    Local $sClassList = WinGetClassList($hWin), $hCtrlWnd
    Local $sSplitClass = StringSplit(StringTrimRight($sClassList, 1), @LF), $aReturn = ''
    For $iCount = UBound($sSplitClass) - 1 To 1 Step - 1
        Local $nCount = 0
        While 1
            $nCount += 1
            Local $aCPos = ControlGetPos($hWin, $sText, $sSplitClass[$iCount] & $nCount)
            If @error Then ExitLoop
            If $iXPos >= $aCPos[0] And $iXPos <= ($aCPos[0] + $aCPos[2]) _
                    And $iYPos >= $aCPos[1]  And $iYPos <= ($aCPos[1] + $aCPos[3]) Then
                If $sSplitClass[$iCount] <> '' And Not $iReturnType Then
                    Local $aClassNN[2] = [2, $sSplitClass[$iCount] & $nCount]
                    Return $aClassNN
                EndIf
                If $sSplitClass[$iCount] <> '' And $iReturnType = 3 Then
                    $hCtrlWnd = ControlGetHandle($hWin, $sText, $sSplitClass[$iCount] & $nCount)
                    ControlFocus($hWin, $sText, $hCtrlWnd)
                    $aReturn = DllCall('User32.dll', 'int', 'GetDlgCtrlID', 'hwnd', $hCtrlWnd)
                    If @error = 0 And $aReturn[0] <> '' Then
                        Local $aClassNN[4] = [4, $aReturn[0], $sSplitClass[$iCount] & $nCount, $hCtrlWnd]
                        Return $aClassNN
                    EndIf
                    Local $aClassNN[2] = [2, $sSplitClass[$iCount] & $nCount]
                    Return $aClassNN
                ElseIf $sSplitClass[$iCount] <> '' And $iReturnType = 2 Then
                    Return ControlGetHandle($hWin, $sText, $sSplitClass[$iCount] & $nCount)
                ElseIf $sSplitClass[$iCount] <> '' And $iReturnType = 1 Then
                    $hCtrlWnd = ControlGetHandle($hWin, $sText, $sSplitClass[$iCount] & $nCount)
                    ControlFocus($hWin, $sText, $hCtrlWnd)
                    $aReturn = DllCall('User32.dll', 'int', 'GetDlgCtrlID', 'hwnd', $hCtrlWnd)
                    If @error = 0 And $aReturn[0] <> '' Then
                        Local $aClassNN[2] = [2, $aReturn[0]]
                        Return $aClassNN
                    EndIf
                EndIf
                Return SetError(1, 0, 0)
            EndIf
        WEnd
    Next
    Return SetError(2, 0, 0)
EndFunc

Thanks for any help.

Share this post


Link to post
Share on other sites



You are threading on thin ice, MEmu is can be used to play android games. If you are looking to automate a game, you won't get any help. Game Automation is forbidden here!

So I recommend you focus on automating non-game apps in MEmu :D.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

I know and do agree, but not looking for anything game related. I've got a virtual android session running in windows and would like to launch a program in the android session. If there is no help that is fine. I can stick to Virtual Box but it is a resource hog.

Share this post


Link to post
Share on other sites
Just now, WnG88 said:

If there is no help that is fine.

As you are not automating games, I can assure you that someone will indeed help you :).


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites
20 minutes ago, TheDcoder said:

As you are not automating games, I can assure you that someone will indeed help you :).

Not for you to decide, in this case.

@WnG88 as the official subtitle of MEmu is "Play Android games on PC with Superb Experience", please let me know what non-game activity you're trying to accomplish with this emulator. I have perused their site, and the associated forum, and find nothing that is not related to playing android games.


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

Share this post


Link to post
Share on other sites

I am testing in windows a Kodi plugin for an android tv box and launching the app multiple instances. Anyways, figured out how to do it.

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