# Scripting with the window size

**URL:** <https://forum.inductiveautomation.com/t/scripting-with-the-window-size/6145>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [April 3, 2013, 11:58am UTC](https://forum.inductiveautomation.com/t/scripting-with-the-window-size/6145 "2013-04-03T11:58:59Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![r.dominguez](https://avatars.discourse-cdn.com/v4/letter/r/a8b319/32.png) [@r.dominguez](https://forum.inductiveautomation.com/u/r.dominguez)\
**Post date:** [April 3, 2013, 11:58am UTC](https://forum.inductiveautomation.com/t/scripting-with-the-window-size/6145/1 "2013-04-03T11:58:59Z")

</div>

Hi all,

I need to know the size of the main window that the Client is seeing to know the resolution of his monitor. I have used [color=#0000FF]"aux = event.source.parent.parent.parent.parent.size"[/color] but it returns a "Dimension" type, so I can't read the width and height or use string replace or something...

Any idea? Thanks a lot.

Raul.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [April 3, 2013, 2:50pm UTC](https://forum.inductiveautomation.com/t/scripting-with-the-window-size/6145/2 "2013-04-03T14:50:28Z")

</div>

How about this:

```python
h=event.source.parent.parent.parent.parent.size.height
w=event.source.parent.parent.parent.parent.size.width

```

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [April 3, 2013, 2:57pm UTC](https://forum.inductiveautomation.com/t/scripting-with-the-window-size/6145/3 "2013-04-03T14:57:11Z")

</div>

[quote=“r.dominguez”]  
I need to know the size of the main window that the Client is seeing to know the resolution of his monitor…[/quote]

Just to stress a perhaps minor point, the window will be smaller than screen resolution. It will be affected if something like the menu bar is showing.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [April 3, 2013, 3:16pm UTC](https://forum.inductiveautomation.com/t/scripting-with-the-window-size/6145/4 "2013-04-03T15:16:04Z")

</div>

Sorry, couldn’t let this one pass…

This one will get screen resolution for you.

```python
import java.awt
gd=java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
width = gd.getDisplayMode().getWidth()
height = gd.getDisplayMode().getHeight()

```

---

<div class="post-metadata">

**Author:** ![r.dominguez](https://avatars.discourse-cdn.com/v4/letter/r/a8b319/32.png) [@r.dominguez](https://forum.inductiveautomation.com/u/r.dominguez)\
**Post date:** [April 8, 2013, 11:37am UTC](https://forum.inductiveautomation.com/t/scripting-with-the-window-size/6145/5 "2013-04-08T11:37:27Z")

</div>

Hi Jordan,

thanks for all the replies! This one did the trick!!

[color=#0000FF]size\_string1 = event.source.parent.parent.parent.parent.height  
size\_string2 = event.source.parent.parent.parent.parent.width

event.source.parent.getComponent(‘Label 2’).text = str(size\_string1)  
event.source.parent.getComponent(‘Label 3’).text = str(size\_string2)[/color]

Thanks again!!

---

<div class="post-metadata">

**Author:** ![manjuyadav95.m](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@manjuyadav95.m](https://forum.inductiveautomation.com/u/manjuyadav95.m)\
**Post date:** [December 22, 2023, 10:37am UTC](https://forum.inductiveautomation.com/t/scripting-with-the-window-size/6145/6 "2023-12-22T10:37:02Z")

</div>

does it works only in vision ? or perspective too ? because i m getting exact my system display resolution from vision but not in perspective as it is returning some different ..  
system display resolution is : 1366 \* 768  
Vision o/p: 1366 \* 768  
Perspective o/p: 1024\*768

Please help to get same in perspective too

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [December 22, 2023, 10:56am UTC](https://forum.inductiveautomation.com/t/scripting-with-the-window-size/6145/7 "2023-12-22T10:56:56Z")

</div>

Won't work with perspective. NOTHING related to display is common between vision and perspective. Two very, VERY different technologies.

What exactly do you want to do ?

---

<div class="post-metadata">

**Author:** ![manjuyadav95.m](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@manjuyadav95.m](https://forum.inductiveautomation.com/u/manjuyadav95.m)\
**Post date:** [December 22, 2023, 11:02am UTC](https://forum.inductiveautomation.com/t/scripting-with-the-window-size/6145/8 "2023-12-22T11:02:18Z")

</div>

Thanks for your response. I want to get my system display resolution to set height and width based on that value ..so that the screen will be visible same as mine(height and width will be same as per system display resolution) ..

below code worked in vision but giving different values when used in perspective.. please help

```auto
gd=java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
width = gd.getDisplayMode().getWidth()
height = gd.getDisplayMode().getHeight()
print('width',width,' height',height)
window=system.gui.getParentWindow(event)
window.setSize(int(round(width*0.25)), int(round(height*0.65)))

```

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [December 22, 2023, 1:54pm UTC](https://forum.inductiveautomation.com/t/scripting-with-the-window-size/6145/9 "2023-12-22T13:54:56Z")

</div>

I think this should be split off to a separate thread. The original question was in 2013 when Perspective didn't exist. Reference this thread if it's relevant (which it isn't).

What is "height n width"? If it's "height **and** width" then write that to avoid confusion. If not then please explain.
