0

It is possible to start an application on another desktop as this example in autoit shows:

http://www.autoitscript.com/forum/topic/159441-createprocess-on-other-desktop-and-bring-it-back/

But is it possible to bring it back to the input desktop?

How to switch a process between default desktop and Winlogon desktop?

...says it is only possible for applications without window handles. But any windows app has at least one window. What is the purpose of SetThreadDesktop when it only can move console applications in a multi desktop-system?

And if SetThreadDesktop can move the calling thread how to perform that for the process I started which does not belong to my thread but has its own PID?

Thanks

Community
  • 1
  • 1
  • 1
    It is quite explicit in the MSDN article: "The SetThreadDesktop function will fail if the calling thread has any windows or hooks on its current desktop". So no. – Hans Passant Mar 03 '14 at 16:25
  • yes but msdn says: "unless the hDesktop parameter is a handle to the current desktop" ...this only makes sense if they mean the current input desktop. If it does not mean the current input desktop then again: what should the function be good for? Switching to the desktop its already located on? – Bluesmaster Mar 03 '14 at 18:45
  • I detect an XY question. Can you please ask what you __really__ want to know? – david.pfx Mar 04 '14 at 13:55
  • preload an application in the background and bring it to the input desktop on demand – Bluesmaster Mar 04 '14 at 16:16

1 Answers1

2

I am sure you are misunderstood concept of desktops. In Windows desktop is securable object, not graphical entity. Not confuse with Desktop in Windows Shell namespace.

Also is possible create windows app without any window so SetThreadDesktop works for windows app too, not only for console.

And last note: Input desktop is designed for input, why you want move any windows from another desktop? What is your design goal?

Xearinox
  • 3,224
  • 2
  • 24
  • 38
  • Design goal is preloading applications with long loading times to have them ready "on demand" (I got plenty of RAM). And: of course every windows app has a window even if it is not visible. Exceptions are only console applications. But it appears very arbitrary to me that one can only console apps can switch desktops. For what reasons of security? – Bluesmaster Mar 03 '14 at 18:35
  • Mhm. I dont see anything similar with desktops. – Xearinox Mar 03 '14 at 18:38
  • that it is possible for console apps is discussed here: http://stackoverflow.com/questions/16010659/how-to-switch-a-process-between-default-desktop-and-winlogon-desktop?lq=1 – Bluesmaster Mar 03 '14 at 18:41
  • Again windows app (subsystem: windows) not must have any window. – Xearinox Mar 03 '14 at 18:44
  • And again ask what is your goal? I dont see anything similar with desktops in preloading apps. – Xearinox Mar 03 '14 at 18:53
  • are you absolutly sure? From all I have read and experienced every subsystem:windows has an invisible window per definition. Even if you never create one explicitly. It is for example used to receive a wm_close message when you shut down windows to tell you programm to leave softly – Bluesmaster Mar 03 '14 at 18:55
  • Design goal 2: As I said one can load the app (lets say eclipse wich loads about 35 seconds on my pc) without interrupting the current work. And then when I need eclipse I just move it to the main desvtop – Bluesmaster Mar 03 '14 at 18:59
  • I am using this method for automating applications in the background through winodw messages at the moment. This would be just another utilisation – Bluesmaster Mar 03 '14 at 19:01
  • Windows app not must have window, you tryings are bad. Maybe you tries windows app with message loop, not without. :-) – Xearinox Mar 03 '14 at 19:04
  • Every graphical Windows-based application creates at least one window > http://msdn.microsoft.com/en-us/library/windows/desktop/ms632597(v=vs.85).aspx but you can show me the code to a programm that doesnt and I will believe you :) – Bluesmaster Mar 03 '14 at 19:09
  • simple: WinMain(...){ return1} thats all – Xearinox Mar 03 '14 at 19:16
  • turns out you are right :) But again what sense does this statement make: The SetThreadDesktop function will fail if the calling thread has any windows or hooks on its current desktop" ....unless the hDesktop parameter is a handle to the current desktop" I mean nobody wants to "switch" something to the state it was – Bluesmaster Mar 03 '14 at 19:33