Windows desktop application robot
This software robot opens the Spotify desktop application, searches for the given song, and plays the song. The robot demonstrates the basic Windows-automation capabilities of the RPA Framework, using keyboard navigation.
This robot currently works only on Windows. You need to have the Spotify desktop application (Windows) installed on your machine. The robot expects the user to be already logged in when it launches the application.
Robot script
*** Settings ***
Documentation Spotify Windows desktop application robot. Opens the Spotify
... desktop application, searches for the given song, and plays the
... song. Demonstrates the basic Windows-automation capabilities of
... the RPA Framework, using keyboard navigation.
Library RPA.Desktop.Windows
*** Variables ***
${EXECUTABLE_NAME}= Spotify
${WINDOW_TITLE}= Spotify Premium
${SONG_NAME}= Monody
*** Keywords ***
Open the Spotify desktop application
Open From Search ${EXECUTABLE_NAME} ${WINDOW_TITLE}
*** Keywords ***
Search for the song
Send Keys To Input ^l
Send Keys To Input ${SONG_NAME}
*** Keywords ***
Select the song
Send Keys To Input {TAB}{TAB}{TAB}
*** Keywords ***
Play the song
Send Keys To Input {ENTER} with_enter=False
Sleep 10
*** Tasks ***
Open Spotify desktop application and play a song
Open the Spotify desktop application
Search for the song
Select the song
Play the song
[Teardown] Close All Applications
Robot script explained
This section explains some of the keywords used in this robot script.
Open From Search ${EXECUTABLE_NAME} ${WINDOW_TITLE}
The Open From Search
keyword is provided by the RPA.Desktop.Windows
library. The keyword opens the application using the Windows search dialog.
Send Keys To Input ^l
The Send Keys To Input
(from RPA.Desktop.Windows
library) sends given keys to Windows and automatically sends an {ENTER}
after the input by default. The ^l
means Ctrl+L
on Windows. See pywinauto documentation for the available key codes.
Send Keys To Input {TAB}{TAB}{TAB}
Multiple keys can be sent at the same time.
Send Keys To Input {ENTER} with_enter=False
with_enter=False
is used here to prevent sending a double {ENTER}
, since Send Keys To Input
defaults to automatically sending it.