Building a Script File

Let us now begin script building.

  1. Create a new VB project named CitrixEx using steps 1-6 of Example 1.
  2. Since the Citrix server has to be accessed through the web, once again, the Internet Explorer needs to be opened. Since these procedures have been dealt with elaborately in Example 1, let us look at what needs to be done once the IE window opens.
  3. Now that the IE window is open, key in the URL of the Citrix client to connect to (192.168.10.28) in the Address box. Prior to that, the cursor must be positioned inside the Address box. To instruct the script to do the same, capture an image of the Address box, and associate a click event with it. This again, has been explained in great detail in Example 1. The next step therefore, is to type the URL. For that, open the script window, click on the key button on its tool bar, and enter http://192.168.10.28/ in the Text String text box (see Figure 1). Then, click on the Add to Script Code >> button adjacent to the text box to add the equivalent script code to the Keystroke Script Code box. Then, click the ok button in Figure 1.

    Figure 1 : Keying in the URL of the Citrix client

  4. Next, ensure that the script presses the Enter key on the keyboard (see Figure 2).

    Figure 2 : Pressing the Enter key after typing the URL

  5. The script will get updated accordingly (see Figure 3).

    Figure 3 : Script for typing the URL and pressing the Enter key

  6. The Citrix client login page will then appear. To verify whether the page has downloaded completely, instruct the script to wait for the appearance of the Citrix logo on top of the page, and the Done message on its status bar. Since the Done image has already been captured (in Example 1), proceed to capture the Citrix logo alone as depicted by Figure 4.

    Figure 4 : Capturing the Citrix log image

  7. Save the image as Citrixlogo.bmp (see Figure 5).

    Figure 5 : Saving the Citrix logo

  8. Associate a ‘wait for’ event with both the Done and Citrixlogo bitmaps using the procedure depicted by Figure 6.

    Figure 6 : Waiting for the Done and Citrixlogo images

  9. The script will reflect the recent changes (see Figure 7).

    Figure 7 : Script for waiting for the Citrixlogo.bmp and Done.bmp

  10. To calculate the time taken to connect to the Citrix login page, place the cursor on top of the ‘wait for’ script (see Figure 7), and insert a timer named CitrixLogin by clicking on the button on the tool bar of Figure 7. Provide the Timer Name in Figure 8 that appears, and click the ok button therein.

    Figure 8 : Starting the CitrixLogin timer

  11. Stop the CitrixLogin timer after the ‘wait for’ script by clicking on the button on the tool bar of the script window. Select the Timer to be stopped from the Timer Names list of Figure 9, and then click the ok button therein to add the corresponding script code to the VB script.

    Figure 9 : Stopping the CitrixLogin timer

  12. Next, the script will have to provide the authentication information (username, password, domain) required to login to the Citrix server. Begin by providing the user name john. For that, first capture the image of the Username text box, and define its click spot, so that the cursor is automatically positioned inside the text box (see Figure 10).

    Figure 10 : Defining the click spot for the username.bmp image

  13. Then, associate a click event with the username.bmp (see Figure 10), and click the ok button therein.
  14. Once you return to the script window, you will find that the script code corresponding to the click event has been appended to it (see Figure 11).

    Figure 11 : Script for clicking on username.bmp

  15. Next, type the username john in the Username text box as depicted by Figure 12.

    Figure 12 : Keying in the user name john

  16. Now, to navigate to the Password field in the login page, the script will have to press the Tab key on the key board. Build this capability into the script by following the procedure depicted by Figure 13 below.

    Figure 13 : Pressing the Tab key to switch to the Password field

  17. Once in the Password text box, the script needs to type egurkha as the password (see Figure 14).

    Figure 14 : Specifying the password, egurkha

  18. As chn is the Domain to which the Citrix user john belongs, the script will have to click on the Tab key yet again to move to the Domain text box, and then, specify chn in it. After which, the script will have to click on the Login button to login to the Citrix server, 192.168.10.28. To click on the Login button, instruct the script to press the Tab key from the Domain text box, and then press Enter (see Figure 15).

    Figure 15 : Providing the domain name and clicking on the Login button

  19. The script window will thus be updated with the login script (see Figure 16).

    Figure 16 : Script for logging into the Citrix server, 192.168.10.28

  20. If the login is successful, the resultant page will display an Applications section, and of course, a Done message on the status bar. The script should therefore be instructed to wait for the appearance of the aforesaid to confirm successful login. To achieve this, first, capture a small portion of the title of the Applications section (see Figure 17).

    Figure 17 : Capturing the title of the Applications section

  21. Save the image as Applicationstext.bmp (see Figure 18).

    Figure 18 : Saving the image as Applicationstext.bmp

  22. Next, follow the procedure depicted by Figure 19 to associate a ‘wait for’ event with both the Applicationstext.bmp, and the already existing Done.bmp.

    Figure 19 : Waiting for Applicationstext.bmp and Done.bmp

  23. Now, the login time will have to be measured. To ensure this, start a timer named CitrixConnect before the ‘wait for’ script, and stop the timer after the ‘wait for’ script. The script will be updated accordingly (see Figure 20).

    Figure 20 : Script for calculating the login time

  24. Now that we have gained access to the Citrix server, 192.168.10.28, let us proceed to open the Textpad application published on it. As the first step towards this, capture an image of the Textpad icon as shown by Figure 21.

    Figure 21 : Capturing as image of the Textpad icon

  25. Save the image as Textpadicon.bmp (see Figure 22).

    Figure 22 : Saving the Textpadicon.bmp

  26. The next step is to click on the Textpad icon. To achieve this, first, click on the clk button on the script window. Then, proceed as shown by Figure 23.

    Figure 23 : Clicking on the Textpadicon.bmp

  27. Figure 24 displays the script code that corresponds to the association of a click event with the Textpadicon.bmp.

    Figure 24 : Script for clicking on the Textpadicon.bmp

  28. Next, the script will have to wait until the Textpad application fully opens. A clear indicator to this is the appearance of the title bar text, TextPad – [Document 1]. Therefore, open the Textpad application, and capture an image of its title bar text (see Figure 25).

    Figure 25 : Capturing an image of the text on Textpad’s title bar

  29. Save the image as TextpadTitle.bmp.

    Figure 26 : Saving the image as TextpadTitle.bmp

  30. Then, to make sure that the script waits for the TextbarTitle.bmp image to appear, click on the w / v button on the script window’s tool bar, and do as indicated by Figure 27 below.

    Figure 27 : Waiting for TextbarTitle.bmp

  31. Also, track the time taken for Textpad to open, by starting a timer named TextpadOpen before the ‘wait for’ script, and then stopping it after the ‘wait for’ script (see Figure 28).

    Figure 28 : Calculating the time taken for opening Textpad

  32. Let us now proceed to type a few words in Textpad. To instruct the script to do the same, click on the key button in Figure 28 and proceed in the same manner depicted by Figure 29.

    Figure 29 : Typing a line in text pad

  33. The script is accordingly updated (see Figure 30).

    Figure 30 : Script for typing a line of text on Textpad

  34. Finally, the script will have to close the Textpad application without saving the changes made to it. The simplest way to initiate application closure is to press the “Alt+F4” key combination. To achieve this, once again, click on the key button in Figure 30. From the Special Keys list of Figure 31, select Alt. Since the F4 key is to be pressed while holding down the Alt key, choose the Key Down option from the Keystroke Action for Special Keys section. Then, click on the Add to Script Code >> button. Next, select F4 from the Special Keys list, choose the Key Press option, and then click on the Add to Script Code >> (see Figure 32).

    Figure 31 : Pressing down the Alt key

    Figure 32 : Pressing the F4 key

  35. As soon as “Alt+F4” is pressed, a message box requesting the user’s confirmation to save the changes made to the Textpad application will appear. The script will have to click on the No button here. By default, control will rest on the Yes button in the message box. To move to the No button, the Tab key is to be pressed. To click on the No button, the Enter key is to be pressed. Before performing either of these steps, the Alt key that was “pressed down” earlier, should be released. To ensure this, click on the key button on the script window’s tool bar, select Alt from the Special Keys list of Figure 33, select the Key Up option from the Keystroke Action for Special Keys section, and then, click the Add to Script Code >> button.

    Figure 33 : Releasing the Alt key

  36. Finally, click the ok button in Figure 33 to return to the script window. After verifying the changes that were effected on the script, click on the key button on the tool bar once again. This time select the Tab option from the Special Keys list and click on the Add to Script Code >> button adjacent to it. Similarly, add the Enter option to the Keystroke Script Code list (see Figure 34). Then, click the ok button to return to the script window and view the complete script (see Figure 35).

    Figure 34 : Pressing the Tab key and then the Enter key to click on the No button in the message box

    Figure 35 : The complete script

  37. With that, request emulation is complete. Now, compile the script by clicking the button on the tool bar of Figure 35. Once compilation becomes successful, run the script by clicking on the button.