Start process on the other desktop, Python, Windows

前端 未结 1 873
无人及你
无人及你 2021-02-11 00:21

I have created second desktop

import win32api, win32con, win32gui, win32service, win32process
import pywintypes
import traceback, thread, time, cStringIO


k = w         


        
1条回答
  •  囚心锁ツ
    2021-02-11 00:49

    You can set the STARTUPINFO.lpDesktop to the name of that desktop:

    import win32api, win32con, win32gui, win32service, win32process
    #import pywintypes
    #import traceback, thread, time, cStringIO
    
    
    hDesktop = win32service.CreateDesktop("ABCD2",
                                          0,
                                          win32con.GENERIC_ALL,
                                          None)
    
    win32api.Sleep(500)
    StartInfo = win32process.STARTUPINFO()
    StartInfo.lpDesktop = "ABCD2"
    
    ProcInfo = win32process.CreateProcess(
        None,
        "mspaint.exe",
        None,
        None,
        True,
        win32con.NORMAL_PRIORITY_CLASS | win32con.CREATE_NEW_CONSOLE,
        None,
        None,
        StartInfo)
    

    0 讨论(0)
提交回复
热议问题