Jump to content

How can I do to run applications with _WinAPI_SwitchDesktop and _WinAPI_CreateProcess?

Recommended Posts

---------------Detectar idiomaAfrikáansAlbanésAlemánAmáricoÁrabeArmenioAzerbaiyanoBengalíBielorrusoBirmanoBosnioBúlgaroCanarésCatalánCebuanoChecoChino (Simplificado)Chino (Tradicional)CingalésCoreanoCorsoCriollo haitianoCroataDanésEslovacoEslovenoEspañolEsperantoEstonioEuskeraFinésFrancésFrisón occidentalGaélico escocésGalésGallegoGeorgianoGriegoGuyaratíHausaHawaianoHebreoHindiHmongHúngaroIgboIndonesioInglésIrlandésIslandésItalianoJaponésJavanésJemerKazajoKirguísKurdoLaoLatínLetónLituanoLuxemburguésMacedonioMalayalamMalayoMalgacheMaltésMaoríMaratíMongolNeerlandésNepalíNoruegoNyanjaPanyabíPastúnPersaPolacoPortuguésRumanoRusoSamoanoSerbioSesotho meridionalShonaSindhiSomalíSuajiliSuecoSundanésTagaloTailandésTamilTayikoTeluguTurcoUcranianoUrduUzbekoVietnamitaXhosaYidisYorubaZulúEspañol
Hello everyone,

I'm new to this topic of autoit, and I'm in trouble I need help since I can not find a way to change the parallel desktop with the function WINAPI_SwitchDesktop, and try to run an app, with the function _WinAPI_CreateProcess that is not in system32, like for example "chrome", it does not run and it does not give me an error, it's for a project similar to a cyber-control, thanks.

PD :: recycle the code of the examples.


Share this post

Link to post
Share on other sites

I am new to the forums and not far into autoit, but I think I manage. What exactly is your error?

I ran tidy through your script and I received an error  that starts at line 14, my guess would be that the solution is to be placed between line 20 and 21

the usage of a few things is incorrent, like the switch statement and such


may I suggest tackling one issue at the time?


#include <Process.au3>
;~ #include <APIProcConstants.au3>
#include <APISysConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIMem.au3>
#include <WinAPIProc.au3>
#include <WinAPISys.au3>

Switch $reachdata
    Case Else ; I have put this here to avoid syntax error on the switch statement (look at the switch statement in the help file how to use it properly
        $reachdata = UDPRecv($reachserver, 50)
        If $reachdata Then ; ==========what is the goal here??????
            $Minutes = $reachdata ; Esperará 2 minutos.
            Local $60Count = 0, $begin = TimerInit()
            While $Minutes > $60Count
                $dif = TimerDiff($begin)
                $dif2 = StringLeft($dif, StringInStr($dif, ".") - 1)
                $Count = Int($dif / 1000)
                $60Count = Int($Count / 5)
                ToolTip("Minutos finales = " & $Minutes & @CRLF & "Minutos pasados = " & $60Count & @CRLF & "Segundos pasados = " & $Count & @CRLF & "Milisegundos pasados = " & $dif2, 20, 20, "Reloj", 1)
            WEnd ; ===========================================forgot this one perhaps?
        ElseIf $reachdata = 2 Then
EndSwitch ; there was an endif here , I assume you meant endswitch
Local $hPrev = _WinAPI_GetThreadDesktop(_WinAPI_GetCurrentThreadId())
Local $hDesktop = _WinAPI_CreateDesktop('MyDesktop', BitOR($DESKTOP_CREATEWINDOW, $DESKTOP_SWITCHDESKTOP))
If Not $hDesktop Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to create desktop.')
; Switch to the newly created desktop
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 & '\Internet Explorer\iexplore.exe', 0, 0, 0, $CREATE_NEW_PROCESS_GROUP, 0, 0, $tStartup, $tProcess) Then
    ProcessWaitClose(DllStructGetData($tProcess, 'ProcessID'), 120)
;WEnd ; no clue as to why this is here.


Share this post

Link to post
Share on other sites

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