简体   繁体   English

如何确定来自其他应用程序的窗口是否可见?

[英]How can I determine whether a window from another application is visible?

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. 我最近获得了WinX DVD Ripper Platinum的许可证,我很恼火的是,当它翻录DVD时,它并没有告诉我。 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: 为了加快我的DVD翻录过程,我正在制作一个简单的控制台应用程序(使用C#和VS2010):

  1. Finds the handle of the process named "WinX_DVD_Ripper_Platinum" (the process name of the WinX DVD Ripper Platinum software) 查找名为“WinX_DVD_Ripper_Platinum”的进程句柄(WinX DVD Ripper Platinum软件的进程名称)
  2. Finds the handle of the progress dialog on that process using the GetChildWindows method defined in this sample at pinvoke.net 使用此示例中在pinvoke.net中定义的GetChildWindows方法查找该进程上的进度对话框的句柄
  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 启动一个System.Timers.Timer实例,该实例检查(或应该检查)进度对话框是否每5秒关闭一次(使用GetWindowLong函数 ,以及
  4. Plays a few beeps with the System.Console.Beep method to tell the user that the rip is complete. 使用System.Console.Beep方法发出一些哔声,告诉用户rip已完成。 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. 定时器自动重置,每5秒执行一次检查(或在对话框关闭时重复发出蜂鸣声),直到用户按下控制台窗口中的某个键。

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? 第1步,第2步和第4步工作正常,但我遇到第3步的问题,我的问题是,我应该使用哪种窗口样式常量来检查窗口是否可见? (WS_VISIBLE did NOT work...) (WS_VISIBLE没有工作......)

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;
}

您是否尝试过使用IsWindowVisible()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在不使用重定向的情况下,我如何从 web 应用程序中知道另一个 web 应用程序是否经过身份验证? - How can I know from a web application whether another web application is authenticated or not without using redirects? 给定一个窗口,如何确定它是否属于winforms应用程序? - Given a window, how can I determine if it is part of a winforms application? 如何捕捉元素是否不可见 - How can I catch whether the element is not visible 如何从另一个类更新窗口应用程序中的进度条? - How can i update the progress bar in window application from another class? 如何将应用程序控制传递到另一个WPF窗口? - How can I pass application control to another WPF window? 如何确定某个方法在其自己的程序集之外是否可见? - How do I determine whether a method is visible outside its own assembly? 如何以编程方式确定Windows任务栏是否隐藏? - How can I determine programmatically whether the Windows taskbar is hidden or not? 如何使用IWizard确定是否添加项目项? - How can I determine whether or not to add project items using IWizard? 如何确定应用程序的控制台窗口何时获得焦点或失去焦点? - How can I determine when my application's console window gets or loses focus? 如何确定 Windows 应用程序是否在屏幕外? - How to determine whether a Windows application is offscreen?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM