WinActor

2020.11.10
SampleScenarios
Calculate click coordinates for a specified date to manipulate the calendar with the mouse

In order to operate the calendar with the mouse, here is an explanation of a sample scenario (hereinafter referred to as this sample scenario) that calculates the coordinates for clicking after finding the display position on the calendar from the specified date.
*Please see this precautions upon downloading this sample scenario.

Feature

This sample scenario executes following process.

  • Open the sample input file (HTML) in Google Chrome.
  • Set the display zoom magnification to 100%.
  • Focus on the date input field and display the icon for displaying the calendar.
  • Left-click the icon for displaying the calendar by "image matching" to display the calendar.
  • The following processing is performed based on the date when the scenario was executed (hereinafter referred to as "search date").
    • Find out how many rows and columns the search date is on the calendar.
    • The coordinates to be clicked are calculated from the display start position of the calendar and the display width and height for one day.
    • Move the mouse to the search date.
    • Left-click to confirm the date on the calendar.

You can also specify the date in text when entering the date using the Google Chrome calendar. However, in this sample scenario, the calendar of Google Chrome is used as an example of processing assuming a calendar that can only be operated with the mouse.

WinActor(OR-5200) Modules to use

In this sample scenario, the following WinActor(OR-5200) modules are used.

  • Node / action / image matching
  • Node / variable / calculate
  • 08_Date/Date_GetFormattedDate.ums6
  • 12_Mouse/Mouse_MovePointer.ums6
  • 12_Mouse/Mouse_ClickLeftButton.ums6
  • 15_ImageMatching/ImageMatching_GetMatchedPosition.ums6
  • 23_Browser/Browser_Launch.ums6
  • 23_Browser/Browser_Browse.ums6
  • PL2004_469_CalculateCalendarPosition.ums6
  • PL1907_372_GetDate_Last Day_script.ums6

Note

It may not work properly in an environment where the display resolution is high (resolution higher than Full-HD) or when the display magnification is adjusted.

How to use

The usage of this sample scenario is as follows.

Step 1. Load the sample scenario

Extract the downloaded ZIP file and load this sample scenario included in the extracted folder with WinActor.

Step 2. Set the variables required for operation


If necessary, update the values ​​required to execute this sample scenario in the variable list.
The variables that need to be set when executing this sample scenario are as follows.

  • Search date

Enter the date you want to specify on the calendar. In this sample scenario, the date when the scenario is executed is automatically entered.
* Since this sample scenario does not implement calendar operation for differences in year and month, it will not operate normally if you enter a date other than the month when the scenario is executed.

Step 3. Execute the sample scenario


Start executing this sample scenario with WinActor.
The following operations are performed.

  • Open the sample input file (sampleDateInput.html) in Google Chrome.
  • Perform the following processing on the calendar.
    • Click the icon that displays the calendar.
    • Click the search date.

Step 4. Confirmation after execution of sample scenario


On your browser, make sure the search date is entered in the date field.

Trouble shooting

In this sample scenario, an error message will be displayed if a variable is specified incorrectly.

See the error message list for more information.

Explanation

This section describes the implementation techniques used in this sample scenario.

Find out where the specified date is displayed on the calendar

The calendar used in this sample scenario is the basic calendar that is displayed when the file specified as <input type = """" date """"> in html is opened in Google Chrome.

In this sample scenario, this calendar is processed in the following order, and the search date is specified on the calendar.

  • Calendar coordinate calculation
  • Coordinate calculation of search date in calendar
  • Left click on search date

Calendar coordinate calculation

Calculate the coordinates of ① to ⑤ in the figure below.

calendar_img_03.png


Coordinates of the calendar used for processing

Get the coordinates of ①


Use the library ""15_Image matching related / Get image matching location.ums5"" to find the XY coordinates of the calendar pull-down menu."

Get the coordinates of ② and ③ from the coordinates of ①


For both ② and ③, the relative position from ① is set as the initial value of the variable.
Calculate the coordinates of ② and ③ based on the coordinate position of ① and the initial value.
② X coordinate (month start position X) = X coordinate obtained in ① + month start position difference X
② Y coordinate (month start position Y) = Y coordinate obtained in ① + month start position difference Y
X coordinate (end of month position X) = X coordinate obtained in ① + end of month position difference X
③ Y coordinate (end of month position Y) = Y coordinate obtained in ① + end of month position difference Y

input_variable_01.png

List of initial values of variables



For the month beginning position difference X, month beginning position difference Y, month month position difference X, and month month position difference Y, the values adjusted to the calendar size of Google Chrome are preset as the variable initial values. If you want to use a different calendar, modify the value according to the size of the calendar to which you want to apply the process.

Coordinate calculation of search date in calendar

To calculate the coordinates of the search date on the calendar, do the following:

  • Get search date column and line number

Use the library "PL2004_469_CalculateCalendarPosition.ums6" to get the column number and row number on the calendar of the search date.

* Since the Google Chrome calendar starts on Sunday, the "first day" is set to 0. Change it according to the specified calendar.

  • Calculate the Y coordinate of the search date

The Y coordinate of the search date is calculated as follows.

  • Height of one month = Y coordinate of ③ (end of month position Y) - Y coordinate of ② (start of month position Y)
  • Height of day = Height of month ÷ Number of weeks of this month
  • Search date Y coordinate = ② Y coordinate (month beginning position Y) + Height of day * (search date calendar position (row number) -1 + 0.5)

* Addition of 0.5 is an adjustment for clicking the center of the date.

  • Calculate the X coordinate of the search date

The X coordinate of the search date is calculated as follows.

  • Week width = ③ X coordinate (end of month position X)-② X coordinate (month start position X)
  • Width of day = 1 week width ÷ 7
  • Search date X coordinate = ② X coordinate (month beginning position X) + Width of day * (search date calendar position (column number) -1 + 0.5))

* Addition of 0.5 is an adjustment for clicking the center of the date.

  • Left click on search date

Move the mouse and left-click on the coordinates calculated in the previous step using the mouse-related library.

These actions cause the search date to be clicked on the calendar.

If you end the scenario as it is immediately after the left click, the left click may not be reflected, so wait for a certain period of time before ending the scenario.

Processing to improve the accuracy of image matching


This sample scenario opens Google Chrome in the process.

Normally, immediately after opening Google Chrome, the web-page will be opened at a zoom of 100%, but if you execute the scenario while the web-page openning, the web-page that is already opened may be in one of following states.

  • A place that is not the beginning of the web-page is displayed. (So, the target image for image-matching cannot be located.)
  • The zoom is other than 100%.

In above state, image matching will not work properly. Therefore, the following operations need to be performed before image matching.

  • Press the "HOME" key to display the beginning.
  • Press "Ctrl + 0" key to change to 100% display.

In addition, there are cases where the icon image display for calendar display changes slightly just by changing the width of the browser. As a countermeasure, in this sample scenario, the match rate is set to 90%.

SS1908_5528_button_diff.png

Comparison by enlarged icon images

Track changes

VersionDateDetails
1.0 10/27/2020 First edition