Update ScreenMatch.cs, settings.example.ini

This commit is contained in:
Namhyeon Go 2024-09-06 17:03:11 +09:00
parent a69603a10c
commit 6f3153a816
2 changed files with 74 additions and 54 deletions

View File

@ -157,69 +157,89 @@ public class ScreenMatch
parts => parts.Length > 1 ? parts[1] : parts[0] parts => parts.Length > 1 ? parts[1] : parts[0]
); );
foreach (var config in screen_time_configs) var config_keys = new string[]
{ {
switch (config.Key) "process_name",
"sample_width",
"sample_height",
"sample_adjust_x",
"sample_adjust_y",
"sample_only",
"backward",
"save",
"sample_clipboard",
"sample_ocr"
};
foreach (var config_key in config_keys)
{
string config_value;
screen_time_configs.TryGetValue(config_key, out config_value);
if (config_value != null)
{ {
case "backward": switch (config_key)
{ {
isSearchFromEnd = true; case "backward":
this.parent.Log("Use the backward search when screen time"); {
break; isSearchFromEnd = true;
} this.parent.Log("Use the backward search when screen time");
break;
}
case "save": case "save":
{ {
isSaveToFile = true; isSaveToFile = true;
this.parent.Log("Will be save an image file when capture the screens"); this.parent.Log("Will be save an image file when capture the screens");
break; break;
} }
case "sample_clipboard": case "sample_clipboard":
{ {
isUseSampleClipboard = true; isUseSampleClipboard = true;
this.parent.Log("Use Clipboard within a 128x128 pixel range around specific coordinates."); this.parent.Log($"Use Clipboard within a 128x128 pixel range around specific coordinates.");
break; break;
} }
case "sample_ocr": case "sample_ocr":
{ {
tesseractDataPath = Path.Combine(workingDirectory, "app/assets/tessdata_best"); tesseractDataPath = Path.Combine(workingDirectory, "app/assets/tessdata_best");
tesseractLanguage = "eng"; tesseractLanguage = "eng";
isUseSampleOCR = true; isUseSampleOCR = true;
this.parent.Log("Use OCR within a 128x128 pixel range around specific coordinates."); this.parent.Log($"Use OCR within a 128x128 pixel range around specific coordinates.");
break; break;
} }
case "sample_width": case "sample_width":
{ {
int.TryParse(config.Value, out sampleWidth); int.TryParse(config_value, out sampleWidth);
break; break;
} }
case "sample_height": case "sample_height":
{ {
int.TryParse(config.Value, out sampleHeight); int.TryParse(config_value, out sampleHeight);
break; break;
} }
case "sample_adjust_x": case "sample_adjust_x":
{ {
int.TryParse(config.Value, out sampleAdjustX); int.TryParse(config_value, out sampleAdjustX);
break; break;
} }
case "sample_adjust_y": case "sample_adjust_y":
{ {
int.TryParse(config.Value, out sampleAdjustY); int.TryParse(config_value, out sampleAdjustY);
break; break;
} }
case "sample_only": case "sample_only":
{ {
sampleOnly = config.Value; sampleOnly = config_value;
break; break;
} }
}
} }
} }
} }

View File

@ -13,7 +13,7 @@ DISABLE_SCREEN_TIME=true
DISABLE_FILE_MONITOR=true DISABLE_FILE_MONITOR=true
; screen or window ; screen or window
SCREEN_TIME_MODE=screen SCREEN_TIME_MODE=screen
;filename.exe,backward,save,sample_ocr,sample_clipboard,sample_width=128,sample_height=128,sample_adjust_x=0,sample_adjust_y=0,sample_only= ;backward,save,sample_ocr,sample_clipboard,sample_width=128,sample_height=128,sample_adjust_x=0,sample_adjust_y=0,sample_only=,process_name=notepad.exe
SCREEN_TIME_PARAMS= SCREEN_TIME_PARAMS=
GRPC_HOST=http://localhost:50051 GRPC_HOST=http://localhost:50051
ES_HOST=http://localhost:9200 ES_HOST=http://localhost:9200