system.gui.openDesktop() fails occasionally

Hi there,

I'm using the function system.gui.openDesktop() to manage a multi screen application.
Occasionally the desktop opening fails, without any log.


		for d in range(0,dn):
			frame= system.gui.openDesktop(windows=['myWindow'], title='Desk ' + str(d), handle=str(d), x=1920*d, y=0, width=1920, height=1080)

The fail is random, on desk 0, 1 or both. most of the time it works, but it is annoying and I'm wondering if I'm making any mistake.

Any suggestion?

What determines dn?

Any chance they are opening off screen?

Why is system.gui.openDesktop being assigned to this variable? Are we doing something with this afterwards that could be causing an issue?


Hi Justin,
dn is how many desktop to open, in my case is set to 2 so desk 0 and 1 will open.
no, the resolution is correct.

system.gui.openDesktop is assigned to frame var, on next row:


My apologies for the late response, I got sidetracked with other things and forgot to follow up on this.

I do a lot of multidesktop scripting, and I've never had any problems, so naturally, I look for things that are being done differently. For example, I only ever specify x and y on really large monitors or when opening multiple desktops in the same screen. Even so, I've never seen the script fail because of a coordinate specification. One thing that I've never done is assign the openDesktop to a variable and setAlwaysOnTop, but this should be doable with a JFrame, so I don't understand why that would be a problem.

One thing we haven't explored is where is this script being called from? Perhaps that could be the issue.

In any case, here is an example of using the screen data to set the desktops instead of directly specifying the coordinates. Try this and see if the problem persists:

openDesktops = len(system.gui.getDesktopHandles())
monitorData = system.gui.getScreens()
if openDesktops == 0 and len(monitorData) > 1:
	for desktopIndex, desktopWidth, desktopHeight in monitorData[1:]:
		handleName = "Desktop %d" %desktopIndex
		system.gui.openDesktop(screen=desktopIndex, handle=handleName, width=desktopWidth, height=desktopHeight).setAlwaysOnTop(True)
elif openDesktops > 0:
	print 'Execution halted: Multiple open desktops have been detected'
	print 'Execution halted: Only one monitor detected'

Thank you for the reply,
the script is called in the client startup script, I'll try your method and I'll came back to you.

I have 3 monitors. 0 is in the center, 1 is on the left, 2 is on the right.

Using your script on a button on monitor 0, I get 2 new desktops but they're on monitors 0 and 1, respectively. I tried changing it to screen=desktopIndex+1, but then I just get a new desktop on screen 1. I can't get one to open on screen 2, and they don't open full-screen at the 0,0 position.

Here's the result of the getScreens() and getDesktopHandles() functions:


My desktop window on monitor 1 is also too large (extends on to monitor 0).