Point _GetScreenResolution(string deviceID)
{
string cmdCommand = $"adb -s {deviceID} shell dumpsys display | Find \"mCurrentDisplayRect\"";
string text = _ExecuteCMD(cmdCommand);
string pattern = @"mCurrentDisplayRect=Rect\(\d+, \d+ - (\d+), (\d+)\)";
// Use Regex.Match to find the matches
Match match = Regex.Match(text, pattern);
if (match.Success)
{
if (int.TryParse(match.Groups[1].Value, out int firstValue) && int.TryParse(match.Groups[2].Value, out int secondValue))
{
// Create and return a Point object
Point point = new Point(firstValue, secondValue);
return point;
}
}
return Point.Empty;
}