For Advanced

Lesson 9/10

RDC Automated

Take the script from the previous lesson and enhance it with some more UI actions to get a sample of a fully automatic configuration of the Remote Desktop Connection:

program mstsc
♥rdc = /ui[@name='Remote Desktop Connection']
waitfor.ui ‴♥rdc/ui[@id='5017']/ui[@name='Show Options ']‴
ui.click ‴♥rdc/ui[@id='5017']/ui[@name='Show Options ']‴
ui.settext ‴♥rdc/ui[@typeid='50003']/ui[@typeid='50004']‴ text test.domain.com
delay 1
ui.settext ‴♥rdc/ui[@id='13064']‴ text admin
ui.click ‴♥rdc/ui[@id='5015']/ui[@name='Display']‴
for ♥i from 1 to 4
  ui.click ‴♥rdc/ui[@id='13065']/ui[@name='Page left']‴
end
ui.click ‴♥rdc/ui[@id='5015']/ui[@name='Local Resources']‴
ui.click ‴♥rdc/ui[@id='13222']‴
ui.click ‴♥rdc/ui[@id='13082']‴
ui.click ‴♥rdc♥rdc/ui[@id='13221']/ui[@name='Drives']‴
keyboard ⋘SPACE⋙
ui.click ‴♥rdc♥rdc/ui[@id='13220']‴
ui.click ‴♥rdc/ui[@id='5015']/ui[@name='General']‴
dialog ‴Now, click OK to close this dialog and click Save As button‴
waitfor.ui ‴♥rdc/ui[@name='Save As']/descendant::ui[@id='FileNameControlHost']/ui[@id='1001']‴ timeout 10000
ui.settext ‴♥rdc/ui[@name='Save As']/descendant::ui[@id='FileNameControlHost']/ui[@id='1001']‴ text ‴Sample RDP file‴

First seven lines were explained before, so now take a closer look at the rest of the script:

  1. Click the Display tab.

      1. On the Display tab, repeat clicking the remote desktop size slider four times, moving it to the left and thus reducing the resolution.
  2. Click the Local Resources tab.

  3. On the Local Resources tab, click to uncheck the box next to Printers.

  4. Click More… button.

  5. In the resulting Local devices and resources window, click the Drives element.

  6. Since it’s not possible to select this particular check box with the ui.click command (the WPath points only to a label, not to the check box itself), use Space key to select it.

  7. Click OK button to close this window.

  8. Click General tab.

  9. Display a message.

  10. Wait for the Save As… window, which will appear after a user clicked Save As… button (this is only for the purpose of showing how the waitfor.ui command works — you can easily automate clicking the button).

  11. When the Save As… window shows up, enter Sample RDP file in the File name: input box.

In the next lesson you will learn how to access Excel spreadsheet files data without actually having Excel application.