Sign in to follow this  
Followers 0
polps

Detect how the script is launched

15 posts in this topic

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

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

get the parent process

and check if it's Scite or AutoIt3Wrapper. If not it's properly done by double click

Share this post


Link to post
Share on other sites

get the parent process

and check if it's Scite or AutoIt3Wrapper. If not it's properly done by double click

How do you get the pid of a no compiled script ?

because _WinAPI_GetParentProcess works by pid...


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

Share this post


Link to post
Share on other sites

How do you get the pid of a no compiled script ?

because _WinAPI_GetParentProcess works by pid...

@AutoItPID :x

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

@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

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Why so complicated? Just check the last three characters of @ScriptName. If exe then compiled, if au3 then uncompiled (AutoItWrapper).

If StringRight( @ScriptName, 4 ) ....

Jeez .... KISS!

Cheers :mellow:

Henk-Sjoerd.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

What about @Compiled ? :)

Edit: Just saw ... very old thread :mellow:

Edited by Hannes123

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

Share this post


Link to post
Share on other sites

Hahahahaha! Even more elementary.

Thanks Hannes, didn't know that one, though it being on top of the macro list in the help file :mellow:.

Cheers.

Share this post


Link to post
Share on other sites

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

Cheers.

Share this post


Link to post
Share on other sites

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:

Share this post


Link to post
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.

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
Sign in to follow this  
Followers 0