fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Runtime.InteropServices;
  4. using System.Text;
  5.  
  6. class Program
  7. {
  8. const int GWL_STYLE = -16;
  9. const uint WS_CAPTION = 0x00C00000;
  10.  
  11. delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
  12.  
  13. [DllImport("user32.dll")]
  14. static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, IntPtr lParam);
  15.  
  16. [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
  17. static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
  18.  
  19. [DllImport("user32.dll", SetLastError = true)]
  20. static extern int GetWindowTextLength(IntPtr hWnd);
  21.  
  22. [DllImport("user32.dll")]
  23. static extern int GetWindowLong(IntPtr hWnd, int nIndex);
  24.  
  25. [DllImport("user32.dll")]
  26. static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
  27.  
  28. [DllImport("user32.dll")]
  29. static extern bool IsWindowVisible(IntPtr hWnd);
  30.  
  31. static void Main(string[] args)
  32. {
  33. if (args.Length == 0)
  34. {
  35. Console.WriteLine("Uso: RemoveTitleBar.exe \"parte do título da janela\"");
  36. return;
  37. }
  38.  
  39. string partialTitle = args[0].ToLower();
  40.  
  41. List<IntPtr> windowsToChange = new List<IntPtr>();
  42.  
  43. EnumWindows((hWnd, lParam) =>
  44. {
  45. if (!IsWindowVisible(hWnd))
  46. return true;
  47.  
  48. int length = GetWindowTextLength(hWnd);
  49. if (length == 0)
  50. return true;
  51.  
  52. StringBuilder sb = new StringBuilder(length + 1);
  53. GetWindowText(hWnd, sb, sb.Capacity);
  54.  
  55. string title = sb.ToString().ToLower();
  56. if (title.Contains(partialTitle))
  57. {
  58. windowsToChange.Add(hWnd);
  59. }
  60. return true; // continue enumeration
  61. }, IntPtr.Zero);
  62.  
  63. if (windowsToChange.Count == 0)
  64. {
  65. Console.WriteLine($"Nenhuma janela encontrada contendo '{partialTitle}'.");
  66. return;
  67. }
  68.  
  69. foreach (var hWnd in windowsToChange)
  70. {
  71. int style = GetWindowLong(hWnd, GWL_STYLE);
  72. style &= ~(int)WS_CAPTION; // remove WS_CAPTION flag
  73. SetWindowLong(hWnd, GWL_STYLE, style);
  74. Console.WriteLine($"Barra de título removida da janela: {GetWindowTitle(hWnd)}");
  75. }
  76. }
  77.  
  78. static string GetWindowTitle(IntPtr hWnd)
  79. {
  80. int length = GetWindowTextLength(hWnd);
  81. if (length == 0) return "";
  82. StringBuilder sb = new StringBuilder(length + 1);
  83. GetWindowText(hWnd, sb, sb.Capacity);
  84. return sb.ToString();
  85. }
  86. }
Success #stdin #stdout 0.07s 28896KB
stdin
Standard input is empty
stdout
Uso: RemoveTitleBar.exe "parte do título da janela"