Robotic process automation (RPA) tools are able to capture in dedicated user interface (UI) logs the execution of high-volume routines previously performed by a human user on the interface of a computer system, and then emulate their enactment in place of the user by means of a software robot. A UI log can record information about several routines, whose actions and events are mixed in some order that reflects the particular order of their execution by the user. In addition, the same user action may belong to different routines, making its automated identification far from trivial. The issue to automatically understand which user actions contribute to a specific routine inside the UI log is also known as segmentation. In this contribution, after discussing in detail the issue of segmentation and all its potential variants, we present a novel segmentation technique that leverages trace alignment in process mining for automatically deriving the boundaries of a routine by analyzing the UI logs that keep track of its execution, in order to cluster all user actions associated with the routine itself in well-bounded routine traces.