AutoHotkey Community

It is currently May 27th, 2012, 2:34 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: February 12th, 2010, 8:07 pm 
Offline

Joined: October 4th, 2006, 2:15 am
Posts: 250
Location: Louisville, KY
It's easy enough to write to STDOUT, but I can't find a way to write a message STDERR. Am I overlooking something?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 12th, 2010, 8:11 pm 
Offline

Joined: October 15th, 2007, 3:10 pm
Posts: 790
Location: England
OutputDebug? - I think this is what you want.

#ErrorStdOut?

Not sure if any of these help you :lol:

Redirect stdin, stdout and stderr [GUI]

Also, check this thread out:

fincs wrote:
some modifications were done by me in order to support them (FileAppend Asterisk->stdout, OutputDebug->stderr and runtime error messages->stderr are supported).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 12th, 2010, 10:17 pm 
Offline

Joined: October 4th, 2006, 2:15 am
Posts: 250
Location: Louisville, KY
Thanks OceanMachine, but unfortunately OutputDebug doesn't work. It's interesting that the #ErrorStdOut parm lets us redirect STDERR to STDOUT, but we don't actually have a way to write to STDERR that I can find.

Regarding the fincs thread, if I understand it correctly, he's made some modifications to the _L release so OutputDebug will output to STDERR that can then be used by SciTE debugger.

Oh well... it's not that important. I was just trying to test another apps use handling of STDOUT and STDERR and thought I could write something in Autohotkey to output to both quickly. Guess I was wrong... :)

Thanks anyway!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 13th, 2010, 1:54 am 
Offline

Joined: October 15th, 2007, 3:10 pm
Posts: 790
Location: England
Hmm OK, sorry.

I use OutputDebug with Debug Viewer, and I get debug messages appearing from other programs running on my computer at work (McAfee, etc) while I am monitoring it for my AHK scripts, so I thought that you might be able to debug your other code (along with autohotkey) using Debug Viewer. Maybe not :(

Sorry I couldn't help more... maybe someone else knows of a way?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 13th, 2010, 5:01 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
OceanMachine wrote:
OutputDebug?
OutputDebug outputs to a debugger via OutputDebugString if one is attached to the current process. Tools like DbgView can catch it, as can Visual Studio if you're debugging AutoHotkey.exe (useful only to developers like myself). It doesn't output to stderr.
wtg wrote:
It's interesting that the #ErrorStdOut parm lets us redirect STDERR to STDOUT,
Don't be misled by the name; it has nothing to do with stderr:
Quote:
Sends any syntax error that prevents a script from launching to stdout rather than displaying a dialog.
Source: #ErrorStdOut

Quote:
Regarding the fincs thread, if I understand it correctly, he's made some modifications to the _L release so OutputDebug will output to STDERR that can then be used by SciTE debugger.
fincs statement is easily misinterpreted. He was referring specifically to the "stderr" DBGp command, which is ordinarily intended for redirecting the stderr stream to a DBGp (debugger) client. In our case, AutoHotkey doesn't make use of the stderr stream, so fincs repurposed the "stderr" command for redirecting OutputDebug to the DBGP client. The actual stderr stream is not involved.

Try this:
Code:
StdErr_Write("hello, world!")
StdErr_Write(text) {
    if A_IsUnicode
        ; Note: StrLen(text) might be incorrect if multi-byte characters are involved:
        return StdErr_Write_("astr", text, StrLen(text))
    return StdErr_Write_("uint", &text, StrLen(text))
}
StdErr_Write_(type, data, size) {
    static STD_ERROR_HANDLE := -12
    if (hstderr := DllCall("GetStdHandle", "uint", STD_ERROR_HANDLE)) = -1
        return false
    return DllCall("WriteFile", "uint", hstderr, type, data, "uint", size, "uint", 0, "uint", 0)
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 14th, 2010, 10:49 pm 
Offline

Joined: October 4th, 2006, 2:15 am
Posts: 250
Location: Louisville, KY
Lexikos wrote:
wtg wrote:
It's interesting that the #ErrorStdOut parm lets us redirect STDERR to STDOUT,
Don't be misled by the name; it has nothing to do with stderr:
Quote:
Sends any syntax error that prevents a script from launching to stdout rather than displaying a dialog.
Source: #ErrorStdOut


Of course... I noticed that when I first read the help - that it really simply redirected the output that is normally to a dialog - and then forgot it by the time I was posting. Thanks for the clarification.
Lexikos wrote:
Try this:
Code:
StdErr_Write("hello, world!")
StdErr_Write(text) {
    if A_IsUnicode
        ; Note: StrLen(text) might be incorrect if multi-byte characters are involved:
        return StdErr_Write_("astr", text, StrLen(text))
    return StdErr_Write_("uint", &text, StrLen(text))
}
StdErr_Write_(type, data, size) {
    static STD_ERROR_HANDLE := -12
    if (hstderr := DllCall("GetStdHandle", "uint", STD_ERROR_HANDLE)) = -1
        return false
    return DllCall("WriteFile", "uint", hstderr, type, data, "uint", size, "uint", 0, "uint", 0)
}

Works great! Thanks Lexikos!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 6th, 2011, 8:18 am 
Offline
User avatar

Joined: November 7th, 2010, 2:48 am
Posts: 72
Location: Egret Island
I think using WshShell Object maybe a better way. For details, please see:
[AHK&AHK_l]Using COM to interact with command-line progs

_________________
Recommended: AutoHotkey_L My code is based on it or similar versions, e.g. AutoHotkey_H.
Image
Together with AutoHotkey, we grow and march forward. No matter how the future will be, this period of days is still epic.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Alpha Bravo, LazyMan, rbrtryn, Yahoo [Bot] and 21 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group