# Programmatically get Window file name

**URL:** <https://forum.inductiveautomation.com/t/programmatically-get-window-file-name/70848>\
**Category:** Ignition\
**Tags:** vision, ignition81, scripting\
**Created:** [March 9, 2023, 6:14pm UTC](https://forum.inductiveautomation.com/t/programmatically-get-window-file-name/70848 "2023-03-09T18:14:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chad\_Putnam](https://avatars.discourse-cdn.com/v4/letter/c/9fc29f/32.png) [@Chad\_Putnam](https://forum.inductiveautomation.com/u/Chad_Putnam)\
**Post date:** [March 9, 2023, 6:14pm UTC](https://forum.inductiveautomation.com/t/programmatically-get-window-file-name/70848/1 "2023-03-09T18:14:17Z")

</div>

Does anyone know if it is possible to programmatically get the file name of a window from a script file? My application has lots of different windows. When troubleshooting with the end users, its hard to understand what window they are on. I wanted to add a tiny label to each screen with the window file name in it...that way I can troubleshoot without having to physically go to the workstation to see where the problem is.  
 ![Capture](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/2/b2a1a263b3cd06f619a2710f5ba00b402c04f01d.png)  
Like in the screenshot...Can I somehow pull "Line Selection" and load that into a label dynamically?

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [March 9, 2023, 6:16pm UTC](https://forum.inductiveautomation.com/t/programmatically-get-window-file-name/70848/2 "2023-03-09T18:16:40Z")

</div>

[system.gui.getWindowNames](https://docs.inductiveautomation.com/display/DOC81/system.gui.getWindowNames) can get you a full list, but then you would need to do some parsing.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 9, 2023, 6:34pm UTC](https://forum.inductiveautomation.com/t/programmatically-get-window-file-name/70848/3 "2023-03-09T18:34:38Z")

</div>

```auto
if event.propertyName == "componentRunning":
	from com.inductiveautomation.factorypmi.application import FPMIWindow
	from javax.swing import SwingUtilities
	event.source.text = SwingUtilities.getAncestorOfClass(FPMIWindow, event.source).name

```

Works on pretty much any component, including a label. Note that in the designer, you must be in preview mode when the window opens for the script to actually run.
