0

I'm trying to get the "real" title from windows opened in win10 via powershell. When I try it via:

Get-Process | Select MainWindowTitle,ProcessName,Id | where{$_.MainWindowTitle -ne ""}

Powershell command

I get twice "LabVIEW" as title while in the real window is mentioned "PTC05_Driver.lvproj - Project Explorer"

Any idea how to get this "PTC05_Driver.lvproj - Project Explorer" out what is the LabVIEW process?

LabVIEW window

nekomatic
  • 5,988
  • 1
  • 20
  • 27
MLXPVE
  • 1
  • 1
  • The window title you are looking for is probably on a child window of the main window. I suggest you to look for [this](https://bytes.com/topic/net/answers/855274-getting-child-windows-using-process-getprocess), this code should be easily translated in powershell. – Zilog80 Apr 20 '21 at 08:34
  • Welcome to SO. Please prefer post code than image : https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question – YLR Apr 21 '21 at 04:49

1 Answers1

2

Short version - you can't use the main window, so you need to enumerate all of the windows. See an example here, where you can modify the filter on the last line to be

| Where-Object { $_.WinTitle -like "*lvproj*"}| Where-Object { $_.WinTitle -like "*Project Explorer*"} |

This isn't a guarantee, but it's probably the best you can get. Note that this will still return all of the open project windows, as well as any other windows which happen to have "lvproj" and "Project Explorer" in the title.

Longer version - the project window is not "the real window". It's just one window. LabVIEW can have multiple project windows open. I expect the "LabVIEW" window you're seeing is the main window (known as the root window in LV) which handles the root loop, window messages to LV and other things. This could sometimes be seen in the taskbar with the help of an INI key, but I don't think the window itself was ever visible.

All that said, I don't think there's an easy way to reliably find the project windows. Their class is LVDChild, like other LV windows and even in the VI server API I'm not aware of something which gives you a list of the project windows themselves. Filtering by the title, as I showed above, is probably good enough, although it could also break if you have other windows with "lvproj" in the title.

Yair
  • 2,266
  • 12
  • 12