Jump to content

How to detect when ConsoleWrite() invisible?


Recommended Posts

https://www.autoitscript.com/forum/topic/153782-help-filedocumentation-issues-discussion-only/?do=findComment&comment=1477633

I shouldn't but I do. I find more attitude than humble appreciation. Even more attitude than common sense. It's discouraging. I've seen good coders quite posting and I'd bet is due to this overdemanding attitude. Give me, give me, give me. This is a technical thread, we should put our code where our mouth is, and let the code speak.

In any case using _WinAPI_GetParentProcess() you can find what ran what in a loop.

Once you're satisfied with an answer, post your solution for the next guy and change the title adding "[solved]"

cheeers

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

The thing is, Scite is never running the script, just starting the script using the command below:

<path to script.au3> /ErrorStdOut "<path to script.au3>"

Using @ScriptFullDir and $CmdLineRaw you could check to see if it's using that command to help determine if it's being run in Scite. 

Global $g_bIsConsole = (StringStripWS($CmdLineRaw, 3) = '/ErrorStdOut "' & @ScriptFullPath & '"') And (@Compiled = 0) ? True : False

I've always used the code I posted above in my first post especially when using #RequireAdmin, although rather than using a MsgBox I would normally log the information using FileWrite.

Just my 2 cents.

 

Link to comment
Share on other sites

6 minutes ago, argumentum said:

I shouldn't but I do. I find more attitude than humble appreciation. Even more attitude than common sense. It's discouraging. I've seen good coders quite posting and I'd bet is due to this overdemanding attitude. Give me, give me, give me. This is a technical thread, we should put our code where our mouth is, and let the code speak.

Yes, you shouldn't.

Not attitude, but exasperation with TL;NR answers that go far above and beyond the simple question.

The simple answer of which should have been "No.", and left at that. At which point a suggestion type entry could be made, and we all move on.

Then I am beaten up for having such a quite reasonable opinion.

It's not overdemanding - it's underdemanding. And given the simplicity of the initial question, looking for an 'underresponse' as it were.

It may be a 'technical thread', but the lack of the simple no, then the deep technical dive on what one would have thought simply a missed help entry - and quite overwhelming, - especially when a merely simple answer was expected and looked for.

- which was clearly inappropriate as, it turns out, there isn't one. (But there was no way to know that before posing the question.)

I am a technical guy, and I too have inadvertently done a technical deep dive at times.

Don't beat me up for looking for K.I.S.S. - and having it pointed out there isn't such on this. The follow on posts have been quite informative, and triggered quite a bit of googling / reading / studying - for which I thank all of you.
[Sight can easily be lost that all of this is drinking from a fire hose, and one can only swallow and consume so much in one go. I have had many gulps over the years, and no doubt face many more.]

Link to comment
Share on other sites

12 minutes ago, Subz said:

The thing is, Scite is never running the script, just starting the script using the command below:

<path to script.au3> /ErrorStdOut "<path to script.au3>"

Using @ScriptFullDir and $CmdLineRaw you could check to see if it's using that command to help determine if it's being run in Scite. 

Global $g_bIsConsole = (StringStripWS($CmdLineRaw, 3) = '/ErrorStdOut "' & @ScriptFullPath & '"') And (@Compiled = 0) ? True : False

I've always used the code I posted above in my first post especially when using #RequireAdmin, although rather than using a MsgBox I would normally log the information using FileWrite.

Just my 2 cents.

 

Thanks for that. With the responses here, I had discovered such macros and planned to delve into such further. Thanks for the leg up.

Link to comment
Share on other sites

Just now, argumentum said:

did the code I showed you served your need ?

Don't know yet, haven't had a chance to beat on it.

But I looked at the reference / link and had a sense of ... nice, that could be what I need.

So cut and pasted it into the top of a script to dig into further when I get a chance. Won't be minutes, probably hours, but not days.

As you noted, I expect to:

Once you're satisfied with an answer, post your solution for the next guy and change the title adding "[solved]"

Link to comment
Share on other sites

12 hours ago, bs27975 said:

How to tell when being run from SciTE?

#include <WinAPIProc.au3>

ConsoleWrite (_WinAPI_GetParentProcess(_WinAPI_GetParentProcess()) & @CRLF)
ConsoleWrite (ProcessExists("Scite.exe") & @CRLF)

If both result are the same, the the script is being run from Scite...

Link to comment
Share on other sites

Haven't dug into this yet, but I've no doubt

_WinAPI_GetParentProcess(_WinAPI_GetParentProcess())=ProcessExists("Scite.exe")

is part of a solution.

However, ConsoleRead() also returns an error at EOF, so is not definitive.

I'm thinking more: $bIsConsoleWriteVisible = ( @compiled or _WinAPI_GetParentProcess(_WinAPI_GetParentProcess())=ProcessExists("Scite.exe" )

Inherently:

- you've compiled to console, or you don't care about ConsoleWrite() visibility.

= but you may still be in SciTE / development mode.

- if you haven't so compiled, or did to GUI, or aren't so running, again, you don't care about ConsoleWrite() visibility.

Edited by bs27975
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...