

import ctypes, time, shlex, subprocessĬurrent_window = (0, current_window, 0, 0) The problem with that is, for applications like Chrome or Firefox, the new process is immediately closed if an existing process already exists, so it doesn't move the new windows (which actually belong to another, older process) to another desktop. Adobe Reader with default settings).Īnother strategy I tried was launching the applications, sleeping for a bit to allow the windows to be created, then calling MoveWindowToDesktopNumber() to move every window created by the new processes to different virtual desktops. Note that some applications only allow one instance/process, so you can't get multiple separate windows for each virtual desktop (e.g. The time.sleep() calls are needed because Windows doesn't change virtual desktops instantly (presumably because of animations), and to give the processes time to create windows.


Launch_apps_to_virtual_desktops(command_lines) "C:Program FilesMozilla Firefoxfirefox.exe" "C:Program Files (x86)AdobeAcrobat Reader DCReaderAcroRd32.exe" "C:StudyGuide.pdf" "C:Program Files (x86)GoogleChrome BetaApplicationchrome.exe" Virtual_desktop_accessor.GoToDesktopNumber(0) # Go back to the 1st desktop Time.sleep(2) # Wait for apps to open their windows Subprocess.Popen(shlex.split(command_line)) Time.sleep(0.25) # Wait for the desktop to switch

Virtual_desktop_accessor.GoToDesktopNumber(i) Virtual_desktop_accessor = ctypes.WinDLL("VirtualDesktopAccessor.dll") import ctypes, time, shlex, subprocessĭef launch_apps_to_virtual_desktops(command_lines, desktops=3): Put the dll in the current working directory. VirtualDesktopAccessor.dll by Jari Pennanen exports the functions a part of the mostly undocumented (by Microsoft) Virtual Desktop API. Tested with 64-bit Windows 10 Version 3.720. This can be achieved by launching your applications with subprocess.Popen(), then changing virtual desktop by calling GoToDesktopNumber() from VirtualDesktopAccessor.dll with the help of ctypes, and launching your applications again. Run "$system$\shutdown.How do I tell python to launch an app but in Desktop 2 and 3? The following not works (I guess only works on windows 8 ) Run "$system$\rundll32.exe" "PowrProf.dll,SetSuspendState Hibernate"Īll this solutions only write to hd or only to ram. Run "$system$\rundll32.exe" "PowrProf.dll, SetSuspendState 0,0,0" Run "$system$\rundll32.exe" "PowrProf.dll, SetSuspendState 0,1,0" Run "$system$\rundll32.exe" "PowrProf.dll,SetSuspendState" Run "$system$\rundll32.exe" "PowrProf.dll,SetSuspendState Sleep" Run "$system$\rundll32.exe" "PowrProf.dll,SetSuspendState Hybrid Sleep" Also works when I try with the external tool psshutdown:īut how I can call this directly? I have try many: But I not find anything which is working.īefore anyone ask: Yes hybrid sleep is on at my computer (windows7). I search for the a solution for the hybrid sleep (when the computer shutdown he write to ram and hd).
