Saturday, August 6, 2011

Android Screen Control Without Root

The ability to control the screen of my Android phone has been a major pain since I moved from Windows Mobile to Android quite some time ago.

The only solutions required root permissions. However there are scenarios where that is not an option such as in a corporate environment / providing remote support for a device that is not your own.

Android 2.1 onwards ( as far as I know) supports a API called MonkeyRunner that is to be used for application testing. Using this along with java sources provided by "The Android Open Source Project" I have put together a small application that will capture the screen and allow passing of click and key press events to the device.

It is highly limited to the extent that it allows only for touch events and keystrokes. It currently does not support drag events and typing of special characters but something is better than nothing :)

Download the zip file from here

In order to run the files, you need to ensure that the device is connected via USB cable only and debugging has been enabled on the device.

Once this is done, Fire up the screen.bat and it should load up the window. The screen.bat is a single line command calling java.exe along with all the required class and jar files required to make this work.

I have also included adb.exe which is required, you could replace with your own, however mine will probably be more stable.

Again, Consider this only if your device is not rooted. If you have rooted your device I would recommend you use the either of the following better softwares

Android Screencast

This works with the USB connection

Droid VNC Server by José Luis Pereira

This works with Wifi

I hope this has been helpful for some of you all. Am sure there are more brilliant people out there who can modify the sources to add drag functionality as well. Do let me know !

F.J. Wechselberger has integrated this functionality into MyPhoneExplorer through
native TCP-Calls. Its not possible for him to implement Java-Library into the PC-Program but he was able to translate the source of MonkeyRunner. I Would recommend you download this if you are looking for a simple solution for controlling the screen.

Vikram Sridharan.


  1. I would sure love this to work!!! Exactly what I am looking for. Downloaded zip, usb connected, and 'storage in use', ran screen.bat, but the command window pops up and hangs. Nothing else. In reading some of the files, it mentions not having any other USB devices connected? I ahve sevearl (keyboard, drives, etc) Do I need to disconnect them all?

  2. Other USB devices can be connected, it should not be an issue. Just make sure storage is not in use and the USB Debugging is checked. This option is in Settings -> Applications -> Development.

    Hope you have java available on your computer.

  3. This is great work! Will you be adding the drag events or provide some way to scroll using the UI? If that feature is added it could definitely be used to remotely support Android devices.

  4. Looks like drag is supported by the Money API. Just need to map it to the UI. Creating scroll up/down right/left buttons on the UI may be a good way to implement it at first and then connect the event to what the user is doing with the mouse in a later release.

    Example of someone using Monkey for a drag event.

  5. @Anonymous

    Thanks ! Drag is support by Monkryrunner, however my knowledge is programming is quite limited, am trying to get some help on this which is why the zip has all the sources. Am open to anyone to help on this. If I do manage, will definitely update the files here.

  6. Well you have done well for someone with limited programming knowledge!

    I would help if I could. I'm a C++ and .Net guy so I would have to come up a learning curve with the tools and environment before I could even contribute.

  7. Great job! I had the first post about it not working... I had java and the SDK, but was missing some python stuff on my computer. It is now up and running. This shows a lot of promise. My three comments: (1) it seems laggy, especially when typing. I don't mind the slow screen refresh, but typing is very stop and go. (2) when typing, the space bar takes you completely back to the home screen. I read that there are problem handling the space bar in a string, but that there are work arounds. (3) my droid is in a desktop dock on the computer, so it is in landscape format. The PC emulator shows it in landscape, but rotated to portrait, so everything is sideways. I suppose I could figure out how to have the droid stay in portrait when docked... but until the spacebar is fixed, its not gonna work for me. Wish I could help you with the coding on it!!! I'll stay tuned.

  8. Any idea when you'll have an update that allows for scrolling and fixes the space bar issues? I can hardly wait!

  9. Hi There,

    I am getting the following Exception. Need Help please.

    Exception in thread "main" java.lang.NoClassDefFoundError: com/android/monkeyrun
    Caused by: java.lang.ClassNotFoundException:
    at$ Source)
    at Method)
    at Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    Could not find the main class:
    ler. Program will exit.

  10. Hi Vikram,
    I am having trouble "firing up Screen.bat"
    Double clicking opens up gedit.
    If I use my terminal I get the following output:
    john@john-775Dual-880Pro:~/ScreenControl/files$ Screen.bat
    Screen.bat: command not found
    john@john-775Dual-880Pro:~/ScreenControl/files$ cd Screen.bat
    bash: cd: Screen.bat: Not a directory
    john@john-775Dual-880Pro:~/ScreenControl/files$ ./Screen.bat
    bash: ./Screen.bat: Permission denied
    john@john-775Dual-880Pro:~/ScreenControl/files$ sudo ./Screen.bat
    [sudo] password for john:
    sudo: ./Screen.bat: command not found
    What am I doing wrong?

  11. @john

    You are running the files in a linux / unix operating system. The program is meant for windows.

    However considering it is a java based, am sure it should be possible to run on a unix platform but unfortunately am not sure of the right syntax.

  12. is there actual any way round the hanging after launching the screen.bat file?

  13. It also hangs for me (Win7 Pro, HTC Desire S). Someone replied earlier about "...missing some python stuff on my computer.." - how do I find out what might be missing?

  14. no need of python for me, just had to copy all the content of c:\program files\java\jre6\bin into the unzipped Screencontrol directory and it no longer hangs but perfectly works !
    Awesome work dude !!! You rock !!!!!
    Would be real nice however to add the slide ability (up/down / sideways).

  15. Hi,

    I get this message and dont know how I can fix this :/

    31.03.2012 01:40:08 sendMonkeyEventAndGet
    INFO: Monkey Command: wake.
    31.03.2012 01:40:08 createManager
    SCHWERWIEGEND: Timeout while trying to create monkey mananger
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at Source)

    to copy the java bin does not wort for me :(
    - Win7, Motorola Milestone2

    any ideas? want these functionality!

  16. @ all

    Please check the post have updated on an easier alternative !

  17. ita say to me:

    C:\Documents and Settings\Shlomi\Desktop\files>java.exe -cp MonkeyRunner.jar;ddm

  18. Encountered the same problem as right above: launching the command prompt showing the line in Screen.bat only and nothing happened (ie. without having the MonkeyController window). How to resovle?

  19. Excellent, perfect on HTC Sensation XE.

  20. This is awesome, or at least it would if the screen wasn't rotated. The screen taps are correct it's just the image that's wrong.

    Is there any way to rotate the image ?

  21. I've a "socket write error"... What should I do?

  22. It would be perfect it worked because there is no way to open up the program

  23. You can try this Android app, VMLite VNC Server that does NOT require root.

  24. It feels great to feature much revealing and unequalled articles on your websites.
    one click root blog

  25. Thank you very's work for me but the question is same project i want to implement in android so that if you install this Application on your mobile you can run directly while connecting with USB. Please suggest me...

  26. Hi , I run it from linux . I followed following things :

    1. Copy all .jar files except monkeyrunner.jar to a folder named libs in the same directory.

    2. Run the following command :
    java -cp monkeyrunner.jar:libs/*