Jump to content

Detect how the script is launched


polps
 Share

Recommended Posts

Hello people,

in my script I want detect if the script is launched directly by windows explorer (double click on the file) or by scite menu (tools - go).

Anyone know if it's possible?

Thanks

I don't think so, you can see if scite is running but that's all !

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

@AutoItPID :x

@AutoItPID is the PID of the process running the script

you're right !

Edit : i have tried your solution and in scite it returns pid of autoitwrapper.exe and with contextual menu it return explore.exe pid !

What genius this Yashied ! Posted Image

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

#Include <WinAPIEx.au3>

$parent = _WinAPI_GetParentProcess(@AutoItPID)
$parent = _WinAPI_GetProcessName($parent)

IF $parent = "AutoIt3Wrapper.exe" or $parent = "SciTE.exe" Then
    MsgBox(0,'Info','Script run from Scite')
Else
    MsgBox(0,'Info','Script run by DoubleClick')
EndIf

Seems to work fine, have always the full scite package. So added also SciTE.exe.

Link to comment
Share on other sites

#Include <WinAPIEx.au3>
$parent = _WinAPI_GetParentProcess(@AutoItPID) 
$parent = _WinAPI_GetProcessName($parent)
IF $parent = "AutoIt3Wrapper.exe" or $parent = "SciTE.exe" Then
     MsgBox(0,'Info','Script run from Scite')
Else
     MsgBox(0,'Info','Script run by DoubleClick')
EndIf

Yes, it's works perfectly!

Thanks all.

Link to comment
Share on other sites

  • 7 months later...

Yes, I know, it's an old thread. But I stumbled in to it en couldn't resist enlightning people. You know, Google and so ....

Someone who is standing in the shadow can not enlightening anyone.

Please read the topic again :mellow:

Link to comment
Share on other sites

That's right, JohnOne. But a simple problem definition as "in my script I want detect if the script is launched directly by windows explorer (double click on the file) or by scite menu (tools - go)" can be interpreted in many ways, therefore answered in many ways. All the more since it's not at all clear what should be achieved and why.

Someone who is standing in the shadow can not enlightening anyone.

"Hear yee! Hear yee! The judge enters the theatre." You must have good eyes, JFX, to see from there where I'm standing. Or have we met before?

Anyways, that's all completely off topic, I'm sorry.

Cheers.

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...