Building a Script File
Let us now begin script building.
- Create a new VB project named CitrixEx using steps 1-6 of Example 1.
- 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.
-
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.
-
Next, ensure that the script presses the Enter key on the keyboard (see Figure 2).
-
The script will get updated accordingly (see Figure 3).
Figure 3 : Script for typing the URL and pressing the Enter key
-
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.
-
Save the image as Citrixlogo.bmp (see Figure 5).
-
Associate a ‘wait for’ event with both the Done and Citrixlogo bitmaps using the procedure depicted by Figure 6.
-
The script will reflect the recent changes (see Figure 7).
Figure 7 : Script for waiting for the Citrixlogo.bmp and Done.bmp
-
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.
-
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.
-
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
- Then, associate a click event with the username.bmp (see Figure 10), and click the ok button therein.
-
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).
-
Next, type the username john in the Username text box as depicted by Figure 12.
-
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
-
Once in the Password text box, the script needs to type egurkha as the password (see Figure 14).
-
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
-
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
-
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).
-
Save the image as Applicationstext.bmp (see Figure 18).
-
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.
-
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).
-
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.
-
Save the image as Textpadicon.bmp (see Figure 22).
-
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 24 displays the script code that corresponds to the association of a click event with the Textpadicon.bmp.
-
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
-
Save the image as TextpadTitle.bmp.
Figure 26 : Saving the image as TextpadTitle.bmp
-
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.
-
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).
-
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.
-
The script is accordingly updated (see Figure 30).
-
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
-
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.
-
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
- 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.