 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
SanskritFritz
Joined: 17 Feb 2005 Posts: 283 Location: Hungary, Budapest
|
Posted: Wed Feb 23, 2005 4:16 pm Post subject: |
|
|
A quick and dirty solution, save this as file.cmd:
| Code: | "d:\Program Files\AutoHotkey\AutoHotkey.exe" /ErrorStdOut %1 > stdout.txt
type stdout.txt | Works in EditPlus (tested), but unfortunately not in stupid TextPad the reason being TextPad not recognizing cmd files as console app. AAARRGH! _________________ Is there another word for synonym? |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Wed Feb 23, 2005 6:05 pm Post subject: |
|
|
| SanskritFritz wrote: | on the command prompt when I redirect the output into a file, the file contains the error!  | Thanks for the info. I was unaware of it and will add it to the help file.
Also, rather than redirecting it to a file, you could use cb.exe to pipe it directly to the clipboard:
"C:\Program Files\AutoHotkey\AutoHotkey.exe" /ErrorStdOut "C:\Scripts\My Script.ahk" |cb.exe
Also, this trick might help too. Get PipeSplit.exe (8 KB) and try the following example to redirect stdout back to the console. This allows the error message to be displayed on the console:
"C:\Program Files\AutoHotkey\AutoHotkey.exe" /ErrorStdOut "C:\Scripts\My Script.ahk" |pipesplit.exe nul
Last edited by Chris on Wed Sep 13, 2006 2:03 pm; edited 1 time in total |
|
| Back to top |
|
 |
SanskritFritz
Joined: 17 Feb 2005 Posts: 283 Location: Hungary, Budapest
|
Posted: Wed Feb 23, 2005 6:41 pm Post subject: |
|
|
Looks like its not my day PipeSplit freezes, i dont receive the prompt back
I tried this on the command prompt:
| Code: | | "d:\Program Files\AutoHotkey\AutoHotkey.exe" /ErrorStdOut MyStuff.ahk | PipeSplit.exe stdout.txt | and the CommandPrompt window froze, the file stdout.txt was locked by the PipeSplit.exe process, I had to close the CommandPrompt window. _________________ Is there another word for synonym? |
|
| Back to top |
|
 |
SanskritFritz
Joined: 17 Feb 2005 Posts: 283 Location: Hungary, Budapest
|
Posted: Wed Feb 23, 2005 7:01 pm Post subject: |
|
|
PS.
Opps, only if the output is empty!
If the sript contains an error, i get the message on the command line.
Probably because if the script has no errors, AHK does not send any output to the stdout. Can you correct this? If this was solved, i will be able to catch the output in TextPad  _________________ Is there another word for synonym? |
|
| Back to top |
|
 |
Mats Guest
|
Posted: Wed Feb 23, 2005 9:41 pm Post subject: |
|
|
You can also patch AutoHotKey's PE Header to make it a console application.
That way you will get all messages printed to the console (this patch can of course be reverted, so that you don't have to see a console window each time you start AHK!)
I've written a little program to do that. Anybody interested?  |
|
| Back to top |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 3004 Location: Minnesota
|
Posted: Wed Feb 23, 2005 9:57 pm Post subject: |
|
|
Eep! Gimme gimme!  |
|
| Back to top |
|
 |
Mats Guest
|
Posted: Wed Feb 23, 2005 10:05 pm Post subject: |
|
|
| jonny wrote: | Eep! Gimme gimme!  |
Ehm - ok, howto? Don't have a webspace.  |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Thu Feb 24, 2005 2:57 am Post subject: |
|
|
Titan provided some community webspace: http://www.autohotkey.com/forum/viewtopic.php?t=2420
| SanskritFritz wrote: | Looks like its not my day PipeSplit freezes, i dont receive the prompt back
Opps, only if ... the script has no errors, AHK does not send any output to the stdout. Can you correct this? | I'm not sure how to fix it, but perhaps you or someone else here can spot a way to do it in the following C++ program: | Code: | #include <windows.h>
// The UNIX tee command, included with cygwin, probably does the same thing as this program.
int main(int argc, char* argv[])
{
DWORD cb;
HANDLE hStdIn = GetStdHandle(STD_INPUT_HANDLE);
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
HANDLE hStdErr = GetStdHandle(STD_ERROR_HANDLE);
HANDLE hUserOut = NULL;
if (argc < 2 || !strcmp(argv[1], "/?"))
{
char msg[4096];
wsprintf(msg,
"Reads from stdin and writes it to both stdout and the specified file.\n"
"Example usage: dir |pipesplit filename.txt A\n"
"Where A, if specified, causes append rather than overwrite.\n"
, argv[0]);
WriteFile(hStdErr, msg, lstrlen(msg), &cb, NULL);
return 1;
}
int overwrite = 1;
if (argc > 2)
if ((char)CharUpper((LPTSTR)argv[2][0]) == 'A') // CharUpper() vs. toupper() reduces EXE by 8KB
overwrite = 0;
if (argc > 1)
if ( (hUserOut = CreateFile(argv[1], GENERIC_WRITE, 0, NULL
, overwrite ? CREATE_ALWAYS : OPEN_ALWAYS, 0, NULL)) == INVALID_HANDLE_VALUE )
{
char errmsg[1024];
wsprintf(errmsg, "Could not open file \"%s\".\n", argv[1]);
WriteFile(hStdErr, errmsg, lstrlen(errmsg), &cb, NULL);
return 1;
}
else
if (!overwrite)
SetFilePointer(hUserOut, 0, NULL, FILE_END);
char buf[1024];
while (1)
{
ReadFile(hStdIn, buf, sizeof(buf), &cb, NULL);
if (!cb)
break;
WriteFile(hStdOut, buf, cb, &cb, NULL); // Be sure to write no more than was read.
if (hUserOut != INVALID_HANDLE_VALUE)
WriteFile(hUserOut, buf, cb, &cb, NULL);
}
if (hUserOut != INVALID_HANDLE_VALUE)
CloseHandle(hUserOut);
return 0;
} |
| Mats wrote: | | You can also patch AutoHotKey's PE Header to make it a console application. | Good idea, though it might have the side-effect of creating a new console window every time you launch a script from somewhere other than the command prompt. That's the reason I didn't compile AutoHotkey in "console" mode, but perhaps there is a way to have the best of both worlds (preferably without increasing memory utlization and without causing an extra delay during script launch). |
|
| Back to top |
|
 |
SanskritFritz
Joined: 17 Feb 2005 Posts: 283 Location: Hungary, Budapest
|
Posted: Thu Feb 24, 2005 9:12 am Post subject: |
|
|
A console version would be awesome!!
The c++ file you provided is pipesplit. I dont think the error is in pipesplit, it is rather in AHK, that it does not send any output to the stderr, when no errors occured. _________________ Is there another word for synonym? |
|
| Back to top |
|
 |
Mats Guest
|
Posted: Thu Feb 24, 2005 10:45 am Post subject: |
|
|
Great - thanks Titan!!!
Ok, i've uploaded it on Titan's server.
http://pub.inspiration3.com/ahk_console_patcher.zip
The programm takes 2 parameters:
1. The full path (and name) of autohotkey.exe
2. Either the word 'console' to make AHK a console application
or the word 'windows' to make it a normal windows application again.
| Quote: | | Good idea, though it might have the side-effect of creating a new console window every time you launch a script from somewhere other than the command prompt. |
Yep, exactly that is the case. I suggest to keep 2 versions of AHK - one 'debug-console-enabled' and the original (for when the script is ready to run). So you can point your editor to the debug version and let the original handle files with the .ahk extension.
Have fun,
Mats
btw.: no guaranty whatsoever - make backups!  |
|
| Back to top |
|
 |
Rajat
Joined: 28 Mar 2004 Posts: 1718
|
Posted: Thu Feb 24, 2005 10:57 am Post subject: |
|
|
@Mats
great stuff! if you make a .bin patcher available then we can keep 2 .bin files. one for compiling normal scripts, and another for compiling console apps. i don't know of the practical problems, if any... but it sounds good! _________________
 |
|
| Back to top |
|
 |
SanskritFritz
Joined: 17 Feb 2005 Posts: 283 Location: Hungary, Budapest
|
Posted: Thu Feb 24, 2005 11:09 am Post subject: |
|
|
I tried it, thanks for it!
It has the same problem as my batch file: if there is no error in the script, AHK does not produce any output whatsoever on the stdout, thus the editor freezes. If there is an error, TextPad captures the output nicely.
So, I think we need a bug fix in AHK itself? _________________ Is there another word for synonym? |
|
| Back to top |
|
 |
Mats Guest
|
Posted: Thu Feb 24, 2005 12:26 pm Post subject: |
|
|
| Rajat wrote: | @Mats
great stuff! if you make a .bin patcher available then we can keep 2 .bin files. one for compiling normal scripts, and another for compiling console apps. i don't know of the practical problems, if any... but it sounds good! |
That's already working. Use the .bin file as first parameter instead of the AutoHotkey.exe. |
|
| Back to top |
|
 |
Rajat
Joined: 28 Mar 2004 Posts: 1718
|
Posted: Thu Feb 24, 2005 12:31 pm Post subject: |
|
|
i hadn't tried it earlier... thanx!
 _________________
 |
|
| Back to top |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 3004 Location: Minnesota
|
Posted: Thu Feb 24, 2005 2:58 pm Post subject: |
|
|
| If the beta testing here goes well, perhaps Chris could implement this with a switch? |
|
| 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
|