Sign in to follow this  
Followers 0
P4T

Problem with example function of _shellExecuteHidden

5 posts in this topic

Hello,

I'm relative new with autoit, but I can code some simple scripts.

I've created a silent installer, which is working, but now I would like to hide all installation windows.

AutoIt only can hide the first window, but not all, so I searched for a solution and I've found the function >_shellExecuteHidden

I downloaded and installed the requiered WinAPIEx UDF, then I tried to test the function first, because I want to understand how to use it, before I try to make the silent installer with hidden windows.

I tried two simple examples given together with the function:

$hWinHiddenApp = _shellExecuteHidden( @ComSpec , "/c start notepad.exe"  )
ShellExecute( "taskmgr.exe" )
MsgBox( 0 , '' ,  "...´ok look in your taskmanager now. There should be a new notepad.exe entry but no window is visible." )

Func _shellExecuteHidden( $filepath , $parameters = "" , $returnType = 1 , $waitingOption = -1 )


    ; 1 - Create Desktop
    ;Global Const $GENERIC_ALL = 0x10000000
    $hNewDesktop     = _WinAPI_CreateDesktop( "ShellExecuteHidden_Desktop" , $GENERIC_ALL )


    ; 2 - Start Process
    $tProcess = DllStructCreate( $tagPROCESS_INFORMATION )
    $tStartup = DllStructCreate( $tagSTARTUPINFO )
    DllStructSetData( $tStartup , 'Size', DllStructGetSize( $tStartup) )
    DllStructSetData( $tStartup , 'Desktop', _WinAPI_CreateString(  "ShellExecuteHidden_Desktop" ) )

    Local $pid
    If _WinAPI_CreateProcess( $filepath , $parameters , 0, 0, 0, 0x00000200 , 0, 0, DllStructGetPtr($tStartup), DllStructGetPtr($tProcess)) Then
        $pid =  DllStructGetData( $tProcess , 'ProcessID' )
    Else
        Return -1
    EndIf


    ; 3 - Return Process
    if $returnType = 2 Then
        if $waitingOption > -1 Then ProcessWaitClose( $pid  , $waitingOption  )
        Return $pid
    EndIf



    ; 4 - Return WindowHandle
    if $waitingOption =  -1  Then
        Sleep( 1000  )
    ElseIf $waitingOption >  0 Then
        Sleep( $waitingOption  )
    EndIf

    While True  ; keep searching for the window

        $aWindows = _WinAPI_EnumDesktopWindows( $hNewDesktop , $returnType ) ; $returnType = 0 >> means also list hidden windows

        if IsArray( $aWindows ) Then

            for $i = 1 to $aWindows[0][0]

                ;~      MsgBox( 0 , '' , $curPID  & " " & $pid & "      "  & $hWnd & " " & $aWindows[$i][0] )

                $hWnd = $aWindows[$i][0]
                if $pid = WinGetProcess( $hWnd ) Then ; same process?

                    do ; searching through parent windows ...
                        $hLast = $hWnd ; cache it for not loosing it when desktop is reached
                        $hWnd  = _WinAPI_GetParent( $hLast )
                    Until $hWnd = 0    ; ... until root/ desktop is reached
                    $hWnd = $hLast

                    Return $hWnd  ; return the toplevel-window of the process

                EndIf

            Next

        EndIf

        if $waitingOption = 0 Then ; keep searching for the window until it appears ( in worst case endless )
            Sleep( 200 )
        Else
            Return -1
        EndIf

    WEnd


EndFunc

But if run this scrip, I'll get this error message:

 

>"C:Program Files (x86)AutoIt3SciTE..autoit3.exe" /ErrorStdOut "C:UsersP4TDownloadsAutoklickerCaptcha SniperCaptcha Sniper x4.5xx.au3"    

"C:UsersP4TDownloadsAutoklickerCaptcha SniperCaptcha Sniper x4.5xx.au3" (10) : ==> Unknown function name.:
$hNewDesktop     = _WinAPI_CreateDesktop( "ShellExecuteHidden_Desktop" , $GENERIC_ALL )
$hNewDesktop     = ^ ERROR
>Exit code: 1    Time: 0.048
 

 

And the other example, I tried:

MsgBox( 0 , '' ,  "Now we start an editor on the hidden desktop and interact with it programmaticly" )
$hWinHiddenApp = _shellExecuteHidden( @SystemDir & "\notepad.exe" )

Func _shellExecuteHidden( $filepath , $parameters = "" , $returnType = 1 , $waitingOption = -1 )


    ; 1 - Create Desktop
    ;Global Const $GENERIC_ALL = 0x10000000
    $hNewDesktop     = _WinAPI_CreateDesktop( "ShellExecuteHidden_Desktop" , $GENERIC_ALL )


    ; 2 - Start Process
    $tProcess = DllStructCreate( $tagPROCESS_INFORMATION )
    $tStartup = DllStructCreate( $tagSTARTUPINFO )
    DllStructSetData( $tStartup , 'Size', DllStructGetSize( $tStartup) )
    DllStructSetData( $tStartup , 'Desktop', _WinAPI_CreateString(  "ShellExecuteHidden_Desktop" ) )

    Local $pid
    If _WinAPI_CreateProcess( $filepath , $parameters , 0, 0, 0, 0x00000200 , 0, 0, DllStructGetPtr($tStartup), DllStructGetPtr($tProcess)) Then
        $pid =  DllStructGetData( $tProcess , 'ProcessID' )
    Else
        Return -1
    EndIf


    ; 3 - Return Process
    if $returnType = 2 Then
        if $waitingOption > -1 Then ProcessWaitClose( $pid  , $waitingOption  )
        Return $pid
    EndIf



    ; 4 - Return WindowHandle
    if $waitingOption =  -1  Then
        Sleep( 1000  )
    ElseIf $waitingOption >  0 Then
        Sleep( $waitingOption  )
    EndIf

    While True  ; keep searching for the window

        $aWindows = _WinAPI_EnumDesktopWindows( $hNewDesktop , $returnType ) ; $returnType = 0 >> means also list hidden windows

        if IsArray( $aWindows ) Then

            for $i = 1 to $aWindows[0][0]

                ;~      MsgBox( 0 , '' , $curPID  & " " & $pid & "      "  & $hWnd & " " & $aWindows[$i][0] )

                $hWnd = $aWindows[$i][0]
                if $pid = WinGetProcess( $hWnd ) Then ; same process?

                    do ; searching through parent windows ...
                        $hLast = $hWnd ; cache it for not loosing it when desktop is reached
                        $hWnd  = _WinAPI_GetParent( $hLast )
                    Until $hWnd = 0    ; ... until root/ desktop is reached
                    $hWnd = $hLast

                    Return $hWnd  ; return the toplevel-window of the process

                EndIf

            Next

        EndIf

        if $waitingOption = 0 Then ; keep searching for the window until it appears ( in worst case endless )
            Sleep( 200 )
        Else
            Return -1
        EndIf

    WEnd


EndFunc

The error message:

 

>"C:Program Files (x86)AutoIt3SciTE..autoit3.exe" /ErrorStdOut "C:UsersP4TDownloadsAutoklickerCaptcha SniperCaptcha Sniper x4.5xx.au3"    

"C:UsersP4TDownloadsAutoklickerCaptcha SniperCaptcha Sniper x4.5xx.au3" (9) : ==> Unknown function name.:
$hNewDesktop     = _WinAPI_CreateDesktop( "ShellExecuteHidden_Desktop" , $GENERIC_ALL )
$hNewDesktop     = ^ ERROR
>Exit code: 1    Time: 3.789
 

 

How I said, I don't have much experience, but I think it cannot be such a big problem to run a given example script for a function.

I've only installed the required WinAPIEx UDF and copied the code for the example and the function.

So, can anyone explain me what I have done wrong or what I have missed?

I'm using AutoIt v3.3.10.2

Thanks.

Share this post


Link to post
Share on other sites



"Captcha sniper"?

Yes, why do you wonder?

I've saved the script in the folder named Captcha Sniper, because I've build the silent installer for captcha sniper and how I wrote, I want use the _shellExecuteHidden function in my silent installer script.

Share this post


Link to post
Share on other sites

I believe jokky was (apparently too subtly) trying to point you to the forum fules, which prohibit discussion of bypassing security measures, including captchas


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

P4T,

That is not an app we wish to help you install. Thread closed. :naughty:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0