# Printing a window from a tag change script

**URL:** <https://forum.inductiveautomation.com/t/printing-a-window-from-a-tag-change-script/30145>\
**Category:** Ignition\
**Created:** [November 21, 2019, 3:54pm UTC](https://forum.inductiveautomation.com/t/printing-a-window-from-a-tag-change-script/30145 "2019-11-21T15:54:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tannerawbrey](https://avatars.discourse-cdn.com/v4/letter/t/bbe5ce/32.png) [@Tannerawbrey](https://forum.inductiveautomation.com/u/Tannerawbrey)\
**Post date:** [November 21, 2019, 3:54pm UTC](https://forum.inductiveautomation.com/t/printing-a-window-from-a-tag-change-script/30145/1 "2019-11-21T15:54:41Z")

</div>

Hello, so I am trying to print a window based on a tag change event script. I have put together the code on how to do it, but haven’t had any luck getting it to fully execute. My script is this:

system.nav.openWindow(‘Main Windows/ReceivingReport’)  
system.nav.centerWindow(‘Main Windows/ReceivingReport’)  
def clickButton(): import system  
Button = window.rootContainer.getComponent(‘Container/Print Button’)  
system.util.invokeLater(clickButton, 2000)

So when the script runs the windows change and get centered but the doClick() is not executing. The button is inside of another container on the window, but I have tried placing the button in the root container and still it will not work.

---

<div class="post-metadata">

**Author:** ![jonathan.taylor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jonathan.taylor/32/4048_2.png) [@jonathan.taylor](https://forum.inductiveautomation.com/u/jonathan.taylor)\
**Post date:** [November 21, 2019, 4:10pm UTC](https://forum.inductiveautomation.com/t/printing-a-window-from-a-tag-change-script/30145/2 "2019-11-21T16:10:03Z")

</div>

It doesn’t look like you’re telling it to use doClick() anywhere.

Try:

```auto
window.rootContainer.getComponent(‘Container/Print Button’).doClick()

```

---

<div class="post-metadata">

**Author:** ![Tannerawbrey](https://avatars.discourse-cdn.com/v4/letter/t/bbe5ce/32.png) [@Tannerawbrey](https://forum.inductiveautomation.com/u/Tannerawbrey)\
**Post date:** [November 21, 2019, 4:20pm UTC](https://forum.inductiveautomation.com/t/printing-a-window-from-a-tag-change-script/30145/3 "2019-11-21T16:20:28Z")

</div>

I tried using the .doClick at the end but it tells me my object has no attribute ‘doClick’

---

<div class="post-metadata">

**Author:** ![jonathan.taylor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jonathan.taylor/32/4048_2.png) [@jonathan.taylor](https://forum.inductiveautomation.com/u/jonathan.taylor)\
**Post date:** [November 21, 2019, 4:27pm UTC](https://forum.inductiveautomation.com/t/printing-a-window-from-a-tag-change-script/30145/4 "2019-11-21T16:27:17Z")

</div>

Is the code above the only code you’ve got running?

if so, then you’re not telling it what ‘window’ is.

Also, where is this code being run from? An on screen button? internalFrame event handler? This matters as the pathing changes

---

<div class="post-metadata">

**Author:** ![Tannerawbrey](https://avatars.discourse-cdn.com/v4/letter/t/bbe5ce/32.png) [@Tannerawbrey](https://forum.inductiveautomation.com/u/Tannerawbrey)\
**Post date:** [November 21, 2019, 4:29pm UTC](https://forum.inductiveautomation.com/t/printing-a-window-from-a-tag-change-script/30145/5 "2019-11-21T16:29:28Z")

</div>

The script is being ran from a client event change script. This is the only client event script I have running. I have some gateway scripts running but they work fine.

---

<div class="post-metadata">

**Author:** ![jonathan.taylor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jonathan.taylor/32/4048_2.png) [@jonathan.taylor](https://forum.inductiveautomation.com/u/jonathan.taylor)\
**Post date:** [November 21, 2019, 4:55pm UTC](https://forum.inductiveautomation.com/t/printing-a-window-from-a-tag-change-script/30145/6 "2019-11-21T16:55:33Z")

</div>

Ok, so to tell it what window it is you need:

```auto
window = system.gui.getWindow('Main Windows/ReceivingReport')

```

This will find any open instance of a window with that path. If it doesn’t find an open window with that path you’ll get an error.

So try:

```auto
system.nav.openWindow(‘Main Windows/ReceivingReport’)
system.nav.centerWindow(‘Main Windows/ReceivingReport’)

def clickButton(): 
      import system
      window = system.gui.getWindow('Main Windows/ReceivingReport')
      window.rootContainer.getComponent(‘Container/Print Button’).doClick()
system.util.invokeLater(clickButton, 2000)

```

I’m not sure the ‘Container/Print Button’ bit is right though… I can’t remember off the top off my head.

---

<div class="post-metadata">

**Author:** ![Tannerawbrey](https://avatars.discourse-cdn.com/v4/letter/t/bbe5ce/32.png) [@Tannerawbrey](https://forum.inductiveautomation.com/u/Tannerawbrey)\
**Post date:** [November 21, 2019, 5:01pm UTC](https://forum.inductiveautomation.com/t/printing-a-window-from-a-tag-change-script/30145/7 "2019-11-21T17:01:02Z")

</div>

So everything went well except for the .doClick() it’s still hungup there. Perhaps I don’t have the right path going to the object?
