2012-02-06 5 views
0

実行中のアプリケーションにマウスイベントを挿入する(マウスポインタをクリックして移動するなど)。猿のツールで可能ですか?はいの場合は、アンドロイドアプリケーション開発プラットフォームで猿のツールを使用する方法について私にロードマップを教えてもらえますか?マウスイベントインジェクションのためのアンドロイドのモンキーツール

答えて

0

私は猿を使ってエミュレータでアプリを運転しています。

monkeyrunnerツールに送られるPythonスクリプトがあります。これは主にAndroid開発者のサンプルwebsiteのサンプルから来ています。 アクティビティを呼び出して応答することは可能です。 ここでは、アクティビティを呼び出すと、別のアクティビティが実行されます。その時点で4桁の数字を入力し、 'ok'ボタンに対応する画面上の100,400の座標を 'クリック'します。

from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice 

if __name__ == "__main__": 
    # Connects to the current device, returning a MonkeyDevice object 
    device = MonkeyRunner.waitForConnection() 

    # Installs the Android package. Notice that this method returns a boolean, so you can test 
    # to see if the installation worked. 
    # device.installPackage('myproject/bin/MyApplication.apk') 

    # sets a variable with the package's internal name 
    package = 'com.mypackage' 

    # sets a variable with the name of an Activity in the package 
    activity = 'com.mypackage.myactivity' 

    # sets the name of the component to start 
    runComponent = package + '/' + activity 

    # Runs the component 
    device.startActivity(component=runComponent) 

    if device.getProperty('am.current.comp.class') == 'com.mypackage.anotheractivity': 
     device.type('0000') 
     # Click the 'Enter' button on screen at coordinates 100,400 
     device.touch(100, 600, 'DOWN_AND_UP') 

私は役立つことを望みます。

関連する問題