Jump to content

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?

Link to comment
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

Link to comment
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())))

 

Link to comment
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 

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
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 :)

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...