Jump to content
aVen9er

How to detect if au3 was launched from Visual Studio Code?

Recommended Posts

I would like my script to do something different depending on whether my * .au3 file was launched from Visual Studio Code (by pressing F5) or by double-clicking in Windows Explorer.

How to detect if *.au3 file was launched from Visual Studio Code?

Share this post


Link to post
Share on other sites

I think you can check parent process of your process. Something like

 

_WinAPI_GetProcessName(_WinAPI_GetParentProcess())

 

PD: sorry for don't using sintaxis highlight I'm by phone. I'll update later.

Saludos

Share this post


Link to post
Share on other sites

I think you would need to use 2 get parent process.  With Scite at least it is working...

MsgBox ($MB_SYSTEMMODAL,"",_WinAPI_GetProcessName(_WinAPI_GetParentProcess(_WinAPI_GetParentProcess())))

 

Share this post


Link to post
Share on other sites
#include <Debug.au3>
#include <WinAPIProc.au3>
_DebugArrayDisplay(WhereAreMyParents(), "WhereAreMyParents")
Func WhereAreMyParents($iPID = @AutoItPID)
    Local $s, $a[11][3] = [[0, "", ""]]
    $a[1][0] = $iPID
    $a[1][1] = _WinAPI_GetProcessName($iPID)
    $a[1][2] = _WinAPI_GetProcessCommandLine($iPID)
    For $n = 2 To 10
        $iPID = _WinAPI_GetParentProcess($iPID)
        If $iPID = 0 Then ExitLoop
        $a[0][0] = $n
        $a[$n][0] = $iPID
        $a[$n][1] = _WinAPI_GetProcessName($iPID)
        $a[$n][2] = _WinAPI_GetProcessCommandLine($iPID)
    Next
    ReDim $a[$a[0][0] + 1][3]
    Return $a
EndFunc   ;==>WhereAreMyParents

..I know I'm late but I type with 2 fingers and I was quite invested so, there !  :D 

Share this post


Link to post
Share on other sites

@argumentum Kudos for the effort!

@aVen9er You might also want to consider an alternative method of detection, maybe you can pass custom command line parameters, or maybe even use the @Compiled macro. All of my suggestions of course are generic, it is not possible to suggest the best method without knowing the use case :)


A cross-platform implementation of the AutoIt language

My contributions to the AutoIt Community ##AutoIt at freenode, real-time chat

3fHNZJ.gif

Spoiler

If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) intend to do that to anybody.

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...