Guest User

Untitled

a guest
Oct 15th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>MPC-HC WebServer - Variables</title>
  4. <meta http-equiv="content-type" content="text/html; charset=utf-8">
  5. <link rel="stylesheet" type="text/css" href="default.css">
  6. </head>
  7. <body>
  8. <p id="filepatharg">C:music.mp3</p>
  9. <p id="filepath">C:music.mp3</p>
  10. <p id="filedirarg">C:</p>
  11. <p id="filedir">C:</p>
  12. <p id="state">1</p>
  13. <p id="statestring">Paused</p>
  14. <p id="position">85918</p>
  15. <p id="positionstring">00:01:25</p>
  16. <p id="duration">284525</p>
  17. <p id="durationstring">00:04:44</p>
  18. <p id="volumelevel">50</p>
  19. <p id="muted">0</p>
  20. <p id="playbackrate">1</p>
  21. <p id="reloadtime">0</p>
  22. </body>
  23.  
  24. class Program
  25. {
  26. public delegate bool WindowEnumDelegate(IntPtr hwnd,
  27. int lParam);
  28.  
  29. [DllImport("user32.dll")]
  30. public static extern int EnumChildWindows(IntPtr hwnd,
  31. WindowEnumDelegate del,
  32. int lParam);
  33.  
  34. [DllImport("user32.dll")]
  35. public static extern int GetWindowText(IntPtr hwnd,
  36. StringBuilder bld, int size);
  37.  
  38. static void Main(string[] args)
  39. {
  40.  
  41. var mainWindowHandle = Process.GetProcessesByName("mpc-hc").First().MainWindowHandle;
  42. var list = new List<string>();
  43. EnumChildWindows(mainWindowHandle, (hwnd, param) =>
  44. {
  45. var bld = new StringBuilder(256);
  46. GetWindowText(hwnd, bld, 256);
  47. var text = bld.ToString();
  48. if (!string.IsNullOrEmpty(text))
  49. list.Add(text);
  50.  
  51. return true;
  52. }, 0);
  53.  
  54. Console.WriteLine("length={0}", list[0]);
  55. Console.WriteLine("state={0}", list[1]);
  56. Console.WriteLine("bitrate={0}", list[5]);
  57. Console.WriteLine("name={0}", list[7]);
  58.  
  59. Console.WriteLine("Press enter to exit");
  60. Console.ReadLine();
  61. }
  62. }
Add Comment
Please, Sign In to add comment