# Inconsistent Screen Indexes

**URL:** <https://forum.inductiveautomation.com/t/inconsistent-screen-indexes/28578>\
**Category:** Ignition\
**Tags:** ignition79\
**Created:** [September 26, 2019, 12:58pm UTC](https://forum.inductiveautomation.com/t/inconsistent-screen-indexes/28578 "2019-09-26T12:58:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bfuson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bfuson/32/4597_2.png) [@bfuson](https://forum.inductiveautomation.com/u/bfuson)\
**Post date:** [September 26, 2019, 12:58pm UTC](https://forum.inductiveautomation.com/t/inconsistent-screen-indexes/28578/1 "2019-09-26T12:58:54Z")

</div>

On Ignition 7.9.11, I’m finding the screen indexes reported by `system.gui.getScreens()` are inconsistent across multiple workstations.

These Windows 10 workstations each have 5 monitors. The OS Display Settings for each workstation all identify the displays in the same pattern:

```auto
  [5]
[4] [3]
[2] [1]

```

However, when calling `system.gui.getScreens()` in Ignition, I’m getting varied results…  
Workstation 1:

```auto
  [1]
[4] [3]
[2] [0]

```

Workstation 2:

```auto
  [0]
[4] [3]
[2] [1]

```

To be clear, indexing start at 0 or 1 is not the issue, it’s the order that I need to be consistent to support certain features in my project. What could cause this discrepancy between PCs? What controls the Java screen indexes?

---

<div class="post-metadata">

**Author:** ![grietveld](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/grietveld/32/6984_2.png) [@grietveld](https://forum.inductiveautomation.com/u/grietveld)\
**Post date:** [September 26, 2019, 1:06pm UTC](https://forum.inductiveautomation.com/t/inconsistent-screen-indexes/28578/2 "2019-09-26T13:06:04Z")

</div>

> [@bfuson](#):
>
> To be clear, indexing start at 0 or 1 is not the issue, it’s the order that I need to be consistent to support certain features in my project. What could cause this discrepancy between PCs? What controls the Java screen indexes?

I'm still a bit of a newbie on this front, but messed with it a bit on a project.

The OS determines the monitor order. On the project I had, I had to set a particular order for the TVs to be turned on so that Windows would put them in the right order.

---

<div class="post-metadata">

**Author:** ![bfuson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bfuson/32/4597_2.png) [@bfuson](https://forum.inductiveautomation.com/u/bfuson)\
**Post date:** [September 26, 2019, 1:28pm UTC](https://forum.inductiveautomation.com/t/inconsistent-screen-indexes/28578/3 "2019-09-26T13:28:59Z")

</div>

As stated above, the order the monitors are listed in the OS is correct and consistent between workstations. That’s why I’m confused as to how Ignition is reporting differing locations with the same underlying monitor config.

---

<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:** [September 26, 2019, 2:27pm UTC](https://forum.inductiveautomation.com/t/inconsistent-screen-indexes/28578/4 "2019-09-26T14:27:34Z")

</div>

As Phil has stated elsewhere, sun, moon, stars, etc.

However, I believe it sources from _java.awt.GraphicsEnvironment_. I don’t know how it puts things in order, possibly in hardware names.

_getScreens()_ should probably also return the x and y properties from the bounds to give the location in the desktop space. In single monitor apps, they’d always be 0,0, but for my three-monitor setup, I get this:

 ![2019-09-26_10-21-23](https://us1.discourse-cdn.com/inductiveautomation/original/2X/e/e54e85bf530c7ba26f2f52c6b4253cfdafd86d3f.png)

```auto
def getScreens():
	import java.awt.GraphicsEnvironment as GE
	g_env = GE.getLocalGraphicsEnvironment()
	screenDevices = g_env.getScreenDevices()

	output = []
	count = 0

	for device in screenDevices:
		config = device.getDefaultConfiguration()
		bounds = config.getBounds()
		output.append((count, bounds.width, bounds.height, bounds.x, bounds.y))
		count += 1

	return output
		
print getScreens()

```

---

<div class="post-metadata">

**Author:** ![bfuson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bfuson/32/4597_2.png) [@bfuson](https://forum.inductiveautomation.com/u/bfuson)\
**Post date:** [September 26, 2019, 3:34pm UTC](https://forum.inductiveautomation.com/t/inconsistent-screen-indexes/28578/5 "2019-09-26T15:34:16Z")

</div>

Thanks @JordanCClark, I was about to start praying to the old gods again.

With your script, I discovered my monitor locations aren’t in a clean grid. Apparently It’s impossible to get the displays to snap into a 4x4 grid in the Display Settings drag-and-drop utility (very cool Microsoft!), they always have some location imperfection of 2-5 px.

I want to avoid having to configure pixel-perfect monitor locations in the registry, so instead I’m using `sorted` to sort the output of `getScreens()` by their vertical and horizontal locations. Then I’m assembling a dictionary to map between the expected OS screen indexes and the Java indexes.

---

<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:** [September 26, 2019, 3:39pm UTC](https://forum.inductiveautomation.com/t/inconsistent-screen-indexes/28578/6 "2019-09-26T15:39:08Z")

</div>

Actually, I’m more impresssed you have a fancy-schmancy 5 monitor setup. Heh. 😉

---

<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:** [September 26, 2019, 3:44pm UTC](https://forum.inductiveautomation.com/t/inconsistent-screen-indexes/28578/7 "2019-09-26T15:44:38Z")

</div>

Also added to the ideas forum, if you want to upvote.

[https://ideas.inductiveautomation.com/ignition-features-and-ideas/p/systemguigetscreens-xy-values](https://ideas.inductiveautomation.com/ignition-features-and-ideas/p/systemguigetscreens-xy-values)
