# Auto Cursor for Vision (windows to template)

**URL:** <https://forum.inductiveautomation.com/t/auto-cursor-for-vision-windows-to-template/77204>\
**Category:** Ignition\
**Tags:** ignition81, vision, ignition79, ignition80\
**Created:** [August 1, 2023, 9:53am UTC](https://forum.inductiveautomation.com/t/auto-cursor-for-vision-windows-to-template/77204 "2023-08-01T09:53:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![VIJAY\_S](https://avatars.discourse-cdn.com/v4/letter/v/b4bc9f/32.png) [@VIJAY\_S](https://forum.inductiveautomation.com/u/VIJAY_S)\
**Post date:** [August 1, 2023, 9:53am UTC](https://forum.inductiveautomation.com/t/auto-cursor-for-vision-windows-to-template/77204/1 "2023-08-01T09:53:54Z")

</div>

![forum](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/3/63ab902ce8f38d5a6e60dd728d0dfc31d2017cc8.png)  
 ![forum1](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/6/26898d720ad3950c88f2b0090fc8edf526aa85e6.png)  
Script--  
window = system.gui.getWindow("Main\_View\_Trace")  
component = window.getComponent("Root Container.tpMainView.Text Field 3").requestFocus()  
#component.requestFocus()  
system.gui.getParentWindow(event).getComponentForPath('Root Container.testttt').requestFocusInWindow()

This is my Auto Cursor script for Template from windows. But I like this kind of error. How to fix this error

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [August 1, 2023, 1:00pm UTC](https://forum.inductiveautomation.com/t/auto-cursor-for-vision-windows-to-template/77204/2 "2023-08-01T13:00:49Z")

</div>

> [@VIJAY\_S](#):
>
> But I like this kind of error

If you like the error, why would you get rid of it? 🙂  
I'm pretty sure theres a function getComponentFromPath or something. It's been a while since I used vision, but fairly confident that getComponent can only be supplied with a single component and you have to stack them, although that error suggests it should be an integer...

---

<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:** [August 1, 2023, 1:28pm UTC](https://forum.inductiveautomation.com/t/auto-cursor-for-vision-windows-to-template/77204/3 "2023-08-01T13:28:11Z")

</div>

Containers (like a root container) have a `.getComponent()` method that takes the string name of a single component. Window objects do not have this method, just the native Swing method that takes an integer.

But, window objects do have the `.getComponentForPath()` method that takes a complete path string. You are mixing the two.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [August 1, 2023, 7:28pm UTC](https://forum.inductiveautomation.com/t/auto-cursor-for-vision-windows-to-template/77204/4 "2023-08-01T19:28:53Z")

</div>

> [@nminchin](#):
>
> getComponentFromPath

> [@pturmel](#):
>
> getComponentForPath()

I was so close!  
But wait, the OP is already using this function 😅 I didn't see it as it's difficult to read code not in a code block
