Jump to content

Recommended Posts

Posted (edited)

I use: _WinAPI_CreateDesktop example:
 

#include <MsgBoxConstants.au3>
#include <WinAPIMem.au3>
#include <WinAPIProc.au3>
#include <WinAPISys.au3>

; Retrieve a handle to the current desktop and create a new desktop named "MyDesktop"
Local $hPrev = _WinAPI_GetThreadDesktop(_WinAPI_GetCurrentThreadId())
Local $hDesktop = _WinAPI_CreateDesktop('MyDesktop', BitOR($DESKTOP_CREATEWINDOW, $DESKTOP_SWITCHDESKTOP))
If Not $hDesktop Then
        MsgBox(($MB_ICONERROR + $MB_SYSTEMMODAL), 'Error', 'Unable to create desktop.')
        Exit
EndIf

; Switch to the newly created desktop
_WinAPI_SwitchDesktop($hDesktop)

; Run "notepad.exe" on "MyDesktop" and wait until a process will not be closed by user
Local $pText = _WinAPI_CreateString('MyDesktop')
Local $tProcess = DllStructCreate($tagPROCESS_INFORMATION)
Local $tStartup = DllStructCreate($tagSTARTUPINFO)
DllStructSetData($tStartup, 'Size', DllStructGetSize($tStartup))
DllStructSetData($tStartup, 'Desktop', $pText)
If _WinAPI_CreateProcess('', @SystemDir & '\notepad.exe', 0, 0, 0, $CREATE_NEW_PROCESS_GROUP, 0, 0, $tStartup, $tProcess) Then
        ProcessWaitClose(DllStructGetData($tProcess, 'ProcessID'))
EndIf

; Switch to previous desktop and close "MyDesktop"
_WinAPI_SwitchDesktop($hPrev)
_WinAPI_CloseDesktop($hDesktop)

; Free memory allocated for a string
_WinAPI_FreeMemory($pText)

and also _WinAPI_EnumDesktops :
 

#include <Array.au3>
#include <WinAPISys.au3>

Local $aData = _WinAPI_EnumDesktops(_WinAPI_GetProcessWindowStation())

_ArrayDisplay($aData, '_WinAPI_EnumDesktops')


How this differ with:
https://support.microsoft.com/en-us/windows/multiple-desktops-in-windows-36f52e38-5b4a-557b-2ff9-e1a60c976434
 

https://www.digitalcitizen.life/how-create-use-and-remove-desktops-windows-10/

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

  • mLipok changed the title to _WinAPI_CreateDesktop + _WinAPI_EnumDesktops - question about: Multiple desktops in Windows

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...