title: Close window by keyword
body: <p>I want to close all the windows that has any keywords assigned. Below is the C code:</p>
  
  <pre class="lang-c prettyprint-override"><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #define WINVER 0x0600
  #define _WIN32_IE 0x0500
  #include &lt;windows.h&gt;
  #include &lt;stdint.h&gt;
  
  BOOL CALLBACK WindowFoundCB(HWND hwnd, char* param) {
      char *key = (char*) param;
      char strIte[256]; // This way, you have allocated 256 bytes for the Window name.
      GetWindowText(hwnd, strIte, 256);
      if (IsWindowVisible(hwnd)){
          char *p = strstr(strIte,key);
          if (p!= NULL){
              SendMessage(hwnd, WM_SYSCOMMAND, SC_CLOSE, 0);
              printf("==== close a window by key [%s]: &lt;%s&gt;\n",key,strIte);
          }
      }
      return TRUE;
  }
  
  int main(int argc, char *argv[])
  {   int i;
      for (i = 1; i &lt; argc; i++){
          printf("...keep closing window 1Hz for: %s\n", argv[i]);
      }
      if (argc &gt; 1){
          while (1){
              for (i = 1; i &lt; argc; i++){
                  char* aStr = argv[i];
                  EnumWindows(WindowFoundCB,&amp;aStr);
               }
              Sleep(1000);
          }
      }
      return 0;
  }
  </code></pre>
  
  <p>However, when I run it, it only prints the message:</p>
  
  <blockquote>
    <p>...keep closing window 1Hz for : myKeyword</p>
  </blockquote>
  
  <p>Then there is no further reaction at all, even if I have a window named "jjjj myKeyword--".</p>
  
  <p>By the way, is there a way to make case-insensitive compare for searching of keyword here?
  Thanks.</p>