FrenchTroll Posted September 11, 2007 Share Posted September 11, 2007 Hello, How do you do to run a process in a new desktop after switching in it ? I try like this but that don't work (the process run always in the default desktop) : $OriginalThread = DLLCall("kernel32.dll","int","GetCurrentThreadId") $OriginalInput = DllCall('user32.dll', 'hwnd', 'OpenInputDesktop', 'int', 0, 'int', 0, 'int', 0x100) $NouveauBureau = DLLCall("user32.dll","int","CreateDesktop","str","NouveauBureau", "str","","ptr",0,"int",0,"int",0x10000000,"ptr",0) $Startup = DllStructCreate($tagSTARTUPINFO) $Process = DllStructCreate($tagPROCESS_INFORMATION) DllCall('user32.dll', 'int', 'SetThreadDesktop', 'hwnd', $NouveauBureau[0]) DLLCall("user32.dll","int","SwitchDesktop","int",$NouveauBureau[0]) DllStructSetData($Startup, "Size", DllStructGetSize($Startup)) DllStructSetData($Startup, "Desktop", DllStructGetData($Startup, "NouveauBureau")) _API_CreateProcess("", "C:\Windows\Notepad.exe", 0, 0, False, 0, 0, "", DllStructGetPtr($Startup), DllStructGetPtr($Process)) Sleep(2000) _API_CloseHandle(DllStructGetData($Process, "hProcess")) _API_CloseHandle(DllStructGetData($Process, "hThread" )) DLLCall("user32.dll","int","SwitchDesktop","int",$OriginalInput[0]) DllCall('user32.dll', 'int', 'SetThreadDesktop', 'hwnd', $OriginalThread[0]) DLLCall("user32.dll","int","CloseDesktop","int",$NouveauBureau[0]) Certainly i make a mistake but i can't fing where... Thanks ! Link to comment Share on other sites More sharing options...
Hermano Posted December 10, 2007 Share Posted December 10, 2007 (edited) If you look in my signature you will find the create process function. inside the STARTUPINFO you can specify the name of the desktop you want your process to be run DO IT BEFORE YOU SWITCH !Careful keep track of the PID otherwise you will never be able to close that desktop again. Another thing pointer to NULL strings are different in AUTOIT from C and you cannot use just 0 so $NouveauBureau = DLLCall("user32.dll","int","CreateDesktop","str","NouveauBureau", "str",Pt_emptyStr,"ptr",Pt_emptyStr,"int",0,"int",0x10000000,"ptr",Pt_emptyStr) DllCall('user32.dll', 'int', 'SetThreadDesktop', 'hwnd', $NouveauBureau[0]) DLLCall("user32.dll","int","SwitchDesktop",'hwnd',$NouveauBureau[0]) Func Pt_emptyStr() $str="" $temp = DllStructCreate("char [" & Stringlen($str) + 1 & "]") DllStructSetData($temp,1, $str) $P_empty = DllStructGetPtr($temp) Return $P_empty EndFunc is the correct function Edited December 10, 2007 by Hermano ------- CARPE DIEM Display_Library_ Skype erase history Win10VirtualDesktopManager Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now