App inside an app

It's not possible to start an application in a View, but you can launch an app from within your app:

 Intent i = getPackageManager().getLaunchIntentForPackage("com.package.ofapp");
 startActivity(i);

//EDIT to your updated question:

After starting the activity from the above code, one way you could start/stop the macro at any time in the new app would be to create a small view overlay on top of the screen.

This overlay would be on top of ALL activities.

Check out the following link: Creating a system overlay window (always on top)

You could write code to start the macro when the View is pressed, and then if the button was pressed once and the user presses it again, stop the macro. This would be in the onTouchEvent() method.


Unrooted:
Sadly, what you want to achieve does not seem to be possible without rooting the phone, because you can only interact with other apps via intents. Since developers decide how their apps react on specific intents, creating macros this way is nearly impossible.

With rooted phones:

  1. You may want to create a list of all installed apps, you can use

    getPackageManager().getInstalledApplications(PackageManager.GET_META_DATA);
    

    to retrieve a list of all installed apps.

  2. If the user now selects an app, launch it via an intent and create a system overlay to get all touch/key events (and let the user stop the macro). You can find a way to do this here. Store the x/y-values of the touch-events.
  3. You can recreate the events using MotionEvent#obtain.
  4. Now comes the part where you need a rooted phone (the permission INJECT_EVENTS). Launch the app and inject the events so your macro gets executed. Samplecode:

    Instrumentation m_Instrumentation = new Instrumentation();
    m_Instrumentation.sendPointerSync(motionEvent);
    

    You can find more information about injecting (also keyevents) here.

  5. If you need help to compile your app, these 2 links will help you: How to compile Android Application with system permissions, Android INJECT_EVENTS permission