# Get Component in the Shared library script

**URL:** <https://forum.inductiveautomation.com/t/get-component-in-the-shared-library-script/10442>\
**Category:** General Discussion\
**Created:** [September 9, 2015, 8:43am UTC](https://forum.inductiveautomation.com/t/get-component-in-the-shared-library-script/10442 "2015-09-09T08:43:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ian](https://avatars.discourse-cdn.com/v4/letter/i/bb73d2/32.png) [@ian](https://forum.inductiveautomation.com/u/ian)\
**Post date:** [September 9, 2015, 8:43am UTC](https://forum.inductiveautomation.com/t/get-component-in-the-shared-library-script/10442/1 "2015-09-09T08:43:53Z")

</div>

Hi all,

Is there a way to get a component from the Shared library script?

If we do component scripting, for instance, we could get any component from the parent window by

```auto
event.source.parent.getComponent('your component name')
```

How about getting a component from the shared script library? Anything that can substitute “event.source.parent”?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 9, 2015, 1:17pm UTC](https://forum.inductiveautomation.com/t/get-component-in-the-shared-library-script/10442/2 "2015-09-09T13:17:13Z")

</div>

It depends on how you called the shared script. If you are calling it from an event from a component, just pass the event variable to the shared script as a function argument. Then use event.source normally. Otherwise, you’ll need to use [getWindow()](https://support.inductiveautomation.com/usermanuals/ignition/system_gui_getwindow.htm) like:`w = system.gui.getWindow('your window name')
component = w.rootContainer.getComponent('your component name')`It’ll fail if the window isn’t opened, though, and will randomly select a matching window if multiple instances were opened.

---

<div class="post-metadata">

**Author:** ![ian](https://avatars.discourse-cdn.com/v4/letter/i/bb73d2/32.png) [@ian](https://forum.inductiveautomation.com/u/ian)\
**Post date:** [September 10, 2015, 1:33am UTC](https://forum.inductiveautomation.com/t/get-component-in-the-shared-library-script/10442/3 "2015-09-10T01:33:50Z")

</div>

I see… So, it is possible but the limitation is whether the window is opened or not. Thanks!
