Get and use MainWindowHandle for a hidden or minimized window


i want , use mainwindowhandle of hidden or minimized window can take snapshot of it. not want make window visible in process. window window on system, not 1 own. snapshot part no problem -- getting mainwindowhandle works challenge.

i have tried many variations on showwindowasync, sendmessage, findwindowex, etc. if window restored, if not visible, no problem either -- works fine. when window hidden or minimized mainwindowhandle either zero, or when using findwindowex, value when window minimized different when window restored.

most grateful method definitively provides mainwindowhandle window in state. thanks!

hi jeronymite,

  welcome msdn forum support.

  main window window opened process has focus (the toplevel form). must use refresh method refresh process object get current main window handle if has changed.

  can mainwindowhandle property processes running on local computer. mainwindowhandle property value uniquely identifies window associated process.

  process has main window associated if process has graphical interface. if associated process not have main window, mainwindowhandle value zero. value 0 processes have been hidden, is, processes not visible in taskbar. can case processes appear icons in notification area, @ far right of taskbar.

if have started process , want use main window handle, consider using waitforinputidle method allow process finish starting, ensuring main window handle has been created. otherwise, exception thrown.

  based on reason above,you need use process.refresh,so don't make program not visible or hide in taskbar. if that, use findwindowsex enumerate windows , extract specific windows windows title.

while (process.mainwindowhandle == intptr.zero) {     thread.sleep(100);     process.refresh(); }
 

<the content provided "as is" without warranty of kind, whether express or implied>
thanks
msdn community support

please remember "mark answer" responses resolved issue. common way recognize have helped you, , makes easier other visitors find resolution later.



Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'