Monkey talk library is using AOP and aspectJ combination to get current task thats why they are adding <uses-permission android:name="android.permission.GET_TASKS" />
permission. Now using using this permission they can access application current Activity and its view . so they are parsing current view each time when its changed. and adding new listener for these views.
For more information you can download and study its code is open source.