问题描述:

I recently obtained a license for WinX DVD Ripper Platinum, and am annoyed by the fact that, when it's done ripping a DVD, it doesn't tell me so. There's no popup, no system "beep"- nothing. The progress dialog simply closes. The main window doesn't even focus itself...

To speed up my DVD-ripping proccess, I'm making a simple console application (using C# and VS2010) that:

  1. Finds the handle of the process named "WinX_DVD_Ripper_Platinum" (the process name of the WinX DVD Ripper Platinum software)
  2. Finds the handle of the progress dialog on that process using the GetChildWindows method defined in this sample at pinvoke.net
  3. Starts a System.Timers.Timer instance that checks (or is supposed to check) whether the progress dialog has closed every 5 seconds (using the GetWindowLong function, and
  4. Plays a few beeps with the System.Console.Beep method to tell the user that the rip is complete. The timer auto-resets, performing the check (or repeating the beep if the dialog has closed) every 5 seconds until the user presses a key in the console window.

Steps 1, 2, and 4 are working fine, but I'm having problems with step 3- this, my question is, which of the window style constants should I use to check if the window is visible? (WS_VISIBLE did NOT work...)

For more details, this is the function I'm using to check the dialog's visibility:

private static bool IsWindowVisible(IntPtr hwnd)

{

var style = GetWindowLong(hwnd, GWL.GWL_EXSTYLE);

var visible = style & (WS flag goes here);

return visible != 0;

}

网友答案:

Have you tried using IsWindowVisible() instead?

相关阅读:
Top