Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
753 B
1
Indexable
Never
 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;
 }