 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
wtg
Joined: 04 Oct 2006 Posts: 210 Location: Louisville, KY
|
Posted: Fri Feb 12, 2010 7:07 pm Post subject: Can a script write to STDERR? |
|
|
| It's easy enough to write to STDOUT, but I can't find a way to write a message STDERR. Am I overlooking something? |
|
| Back to top |
|
 |
OceanMachine
Joined: 15 Oct 2007 Posts: 780 Location: England
|
Posted: Fri Feb 12, 2010 7:11 pm Post subject: |
|
|
OutputDebug? - I think this is what you want.
#ErrorStdOut?
Not sure if any of these help you
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). |
|
|
| Back to top |
|
 |
wtg
Joined: 04 Oct 2006 Posts: 210 Location: Louisville, KY
|
Posted: Fri Feb 12, 2010 9:17 pm Post subject: |
|
|
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! |
|
| Back to top |
|
 |
OceanMachine
Joined: 15 Oct 2007 Posts: 780 Location: England
|
Posted: Sat Feb 13, 2010 12:54 am Post subject: |
|
|
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? |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7295 Location: Australia
|
Posted: Sat Feb 13, 2010 4:01 am Post subject: |
|
|
| 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)
} |
|
|
| Back to top |
|
 |
wtg
Joined: 04 Oct 2006 Posts: 210 Location: Louisville, KY
|
Posted: Sun Feb 14, 2010 9:49 pm Post subject: |
|
|
| 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! |
|
| Back to top |
|
 |
amnesiac
Joined: 07 Nov 2010 Posts: 41 Location: Egret Island
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|