From 49649b00bec08dac56542ab8f99d8130fd720e4b Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Fri, 20 Sep 2024 18:25:21 +0900 Subject: [PATCH] Updated Screen Time Feature (markdown) --- Screen-Time-Feature.md | 65 +++++++++++++++++++++++++++++++----------- 1 file changed, 49 insertions(+), 16 deletions(-) diff --git a/Screen-Time-Feature.md b/Screen-Time-Feature.md index 183d863..ac69aa3 100644 --- a/Screen-Time-Feature.md +++ b/Screen-Time-Feature.md @@ -7,28 +7,61 @@ This was introduced to enable integration with highly restrictive applications. ## How to Use -1. Configure the `settings.ini` file as follows: +#### 1. **Configure the `settings.ini` file** + In the `settings.ini` file, configure the service settings by adding the following: + + ```ini + [Service] + DISABLE_SCREEN_TIME=true + ; backward,save,sample_width=128,sample_height=128,sample_adjust_x=0,sample_adjust_y=0,sample_any=button.png:message.png:like.png,sample_ocr=like.png,sample_clipboard=button.png,sample_nodup=message.png,process_name=notepad.exe + SCREEN_TIME_PARAMS=save + ``` + + - **`DISABLE_SCREEN_TIME=true`**: Disables the screen time feature. + - **`SCREEN_TIME_PARAMS=save`**: Enables the screenshot saving function. Screenshots will be saved to the directory `app/assets/img/_captured`. + + The commented-out line provides an example of more advanced parameters you can use, such as image searches, OCR, clipboard copying, and duplication prevention. - ```ini - [Service] - DISABLE_SCREEN_TIME=true - ; SCREEN_TIME_PARAMS=backward,save,sample_ocr,sample_clipboard - SCREEN_TIME_PARAMS=save - ``` +#### 2. **Place templates in the `app/assets/img/_templates` directory** + - Add the image fragments (templates) you want to match in PNG format in this directory. + - If you want to match the images in grayscale (ignoring color), prefix the file names with `binary_`. This helps in scenarios where color information isn't necessary for matching. - The `save` parameter is used when you need to save screenshots. The save directory is located at `app/assets/img/_captured`. +#### 3. **Run the service in `User Interactive` mode** + - To start the service, run the `startInteractiveService.bat` file. This will enable interactive processing of templates on the screen. -2. Place the template (image fragment) you want to match in PNG format in the `app/assets/img/_templates` directory. If you need to ignore color values (grayscale), prefix the file name with `binary_`. +#### 4. **Handle template match events** + - When a template (image fragment) is matched, the `onScreenTemplateMatched()` event will be triggered. + - This event provides the matched template's name and the coordinates where it was found. You can use this information to perform actions based on the match. + - Example usage can be found in `defaultService.example.js`. -3. Run the service in `User Interactive` mode. Execute the `startInteractiveService.bat` file. - -4. Through the `onServiceScreenTime()` event, you can receive the name of the matched template (image fragment) and the coordinates where it was matched. You can find an example of usage in `defaultService.js`. +#### 5. **Optimize with the `onScreenNextTemplate()` event** + - You can use the `onScreenNextTemplate()` event to improve processing speed by specifying the next template image to be handled. + - If you return the name of the next image to be processed, only that image will be considered, and the rest will be ignored, leading to faster execution. + - If you do not specify this event, all images will continue to be processed. ## Available options -- `backward`: Searches the image from the end. -- `save`: Saves the screenshot for storage. The save path is `app/assets/img/_captured`. -- `sample_ocr`: Performs OCR (Use [Tesseract OCR](https://github.com/tesseract-ocr/tesseract)) in a 128x128 pixel area around the detected coordinates of the template (image fragment). -- `sample_clipboard`: Copies to the clipboard a 128x128 pixel area around the detected coordinates of the template (image fragment). +- **`backward`**: This option indicates that the search for the image should start from the end of the list or sequence, which may prioritize images appearing later. + +- **`save`**: This option saves a screenshot of the processed area or the result, typically stored in the specified path, such as `app/assets/img/_captured`. + +- **`sample_width={sample_width}` and `sample_height={sample_height}`**: These define the size of the sample region for the image search, setting it to a `{sample_width}x{sample_height}` pixel area. + +- **`sample_adjust_x=0` and `sample_adjust_y=0`**: These options adjust the position of the sample area horizontally (`x`) and vertically (`y`). A value of `0` means no adjustment; the sample area is positioned exactly at the detected coordinates. + +- **`sample_any=button.png:message.png:like.png`**: This specifies a list of image templates (`button.png`, `message.png`, `like.png`) that the process will try to match in the specified region. It will stop as soon as one of these is found. + +- **`sample_ocr=like.png`**: Once `like.png` is found in the search, OCR (optical character recognition) will be performed around the detected area, specifically a `{sample_width}x{sample_height}` pixel region around it. + +- **`sample_clipboard=button.png`**: When `button.png` is detected, a `{sample_width}x{sample_height}` pixel region around the detection is copied to the clipboard. + +- **`sample_nodup=message.png`**: + - When `message.png` is found for the first time, it is added to a **queue** for tracking. + + - If the same image fragment is detected again, the system checks the queue to see if it has already been processed. + + - If the image is in the queue, it skips processing it again, effectively preventing duplicate actions. However, the system continuously checks for new detections to ensure that only the first occurrence is processed. + +- **`process_name=notepad.exe`**: This specifies the process or application (in this case, Notepad) in which the image search and operations will be performed. ## Report abuse - abuse@catswords.net