AutoHotkey Community

It is currently May 27th, 2012, 9:45 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 189 posts ]  Go to page Previous  1 ... 3, 4, 5, 6, 7, 8, 9 ... 13  Next
Author Message
 Post subject:
PostPosted: June 7th, 2006, 3:30 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
Hi corrupt,

Thanks for this function. I have just updated from 1.05 to 1.08

I wonder if the if statement
Code:
    DllCall("CloseHandle", UInt, hWrite)
    DllCall("CloseHandle", UInt, hRead)
  }
  IF (StrLen(CMDout) < TRead) {
    [...]
  }
shouldn't be inside of the previous {} block? Then it would be:
Code:
    DllCall("CloseHandle", UInt, hWrite)
    DllCall("CloseHandle", UInt, hRead)
    IF (StrLen(CMDout) < TRead) {
      [...]
    }
  }

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 13th, 2006, 4:42 am 
Offline

Joined: December 16th, 2005, 3:29 am
Posts: 148
Location: Australia
if anyone is having trouble grabbing text from some Console apps consider reading this:

http://homepages.tesco.net/J.deBoynePollard/FGA/capture-console-win32.html

Hope that sort a couple of issues out :wink:

_________________
Image
546F206C69766520
6973204368726973742C0D746F2064696520
6973206761696E2E0D285068696C20313A323129


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 26th, 2006, 4:35 pm 
Offline

Joined: December 30th, 2005, 5:01 pm
Posts: 448
The function works great, thanks!
But I was wondering, is it possible in some way to run a command via the CmdRet function as a different user, something like RunAs in AHK?
RunAs from Windows itselfs is possible, but that always requires to fill in the password manually.
As a matter of fact I don't know how AHK manages this internally.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: October 24th, 2006, 3:29 pm 
Offline

Joined: July 30th, 2004, 9:08 pm
Posts: 81
Hi
I'm using this extremely useful function successfully in Win2000 SP4, but in WinXP SP2, the output is always empty.
Using CMDRet 1.08 and AHK 1.0.44.14 in both machines.
For testing purposes in WinXP, I downgraded AHK to previous version 1.0.43.11 and it worked perfectly!

So, did AHK 1.0.44.14 break this function in WinXP SP2?

[edit: I just found out that in the W2k machine I had AHK version 1.0.43.11 installed, so probably it doesn't work in W2k either using last 1.0.44.14]


Last edited by jordis on October 31st, 2006, 1:57 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
PostPosted: October 29th, 2006, 10:40 pm 
Ah.. i thought i was just not understanding how to use it. i also have the same problem. i guess it did break it. :( hope it gets fixed, i really need something like this for my script.


Report this post
Top
  
Reply with quote  
 Post subject: FIXED!
PostPosted: November 2nd, 2006, 2:45 pm 
Offline

Joined: July 30th, 2004, 9:08 pm
Posts: 81
The fix suggested by Wdb here: http://www.autohotkey.com/forum/post-85214.html#85214
works wonderfully.
You might want to include it in CMDret function code in first post...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 3rd, 2006, 2:42 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Thanks. I've updated the first post with the change given by rogerg in the other topic.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2006, 8:01 am 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2545
Thanks for the fix and update to the code posted :) . Sorry for the delay. I have updated the .zip file available for download and bumped the version to 1.09 as the fix is necessary for functionality.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2006, 10:11 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Quote:
Loop, 4 {
DllCall("RtlFillMemory", UInt,&pa+A_Index-1, UInt,1, UChar,12 >> 8*A_Index-8 )
DllCall("RtlFillMemory", UInt,&pa+8+A_Index-1, UInt,1, UChar,1 >> 8*A_Index-8 )
}

Loop, 4
DllCall("RtlFillMemory", UInt,&sui+A_Index-1, UInt,1, UChar,68 >> 8*A_Index-8 )


What kind of nonsense is this ?! I sense the short code clan in the background...


Also as suggested by paranoid this is important note on the page he provided:

Quote:
To capture the output and control the input of programs that use high-level console I/O, one redirects their standard input and standard output through pipes, and reads from and writes to the other end of the pipes in the monitoring process.

The advantage of this method is that one doesn't need to worry about missing any output, since this approach doesn't use polling. But, conversely, this method has a problem of its own, in that it won't capture any output generated by low-level console I/O, and that programs that use low-level console I/O for input will bypass the redirection entirely. Alas, all too many DOS programs fall into this category.


Question:
How come that I don't see the process in the list of processess ? I put the Sleep 100000 command after obtaining cmdretPID but can't see the process.

I ask this cuz I wanted to modify this func to support live feed. My idea was to split current function in two parts - first one to create pipes and process, second one that read the pipe. So, one can first call first part to create a process with cmd.exe and then it calls second part to send it command to execute and read the pipe. I hoped I could transmit command to running cmd.exe process by using ControlSend, ,%cmdin%, ahk_pid %cmdretPID% but I am not sure if it can be done (it returns errorlevel 1 if I trie it). I don't see process anywhere..

EDIT: I see its some mambo jumbo in StartUpInfo. Again, as you obfuscated this part of the code its practicly not possible somebody else to tweek this code. I am so pissed off now as its easier to write entire code again than to understand this shit.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 14th, 2006, 10:08 am 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2545
majkinetor wrote:
EDIT: I see its some mambo jumbo in StartUpInfo. Again, as you obfuscated this part of the code its practicly not possible somebody else to tweek this code. I am so pissed off now as its easier to write entire code again than to understand this shit.
Well... that really inspires me to help you out...

There is no obfuscation. It seems readable enough for people to have posted modified code. I just haven't added any comments. The main reason for this is to try and keep the size of the code a bit smaller for people that want to include the function in existing scripts. Another reason is that I find it to be readable without needing to add comments. It wasn't to try and stop people from being able to edit the code. If I wanted that then I wouldn't have posted the code in the first place and/or asked for comments, suggestions, accepted modifications, etc... ;)

As I'm not sure exactly what you are attempting to run and receive output from, I'll guess, that you are possibly not seeing the process listed as it is likely a child process.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 14th, 2006, 10:23 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Quote:
Well... that really inspires me to help you out...

LOL

this is the goal:

1. open the command prompt
2. order it to execute this and that command
3. close the prompt when you are finished

Live feed, in other words.

My idea was to tweek this function and split in tree. First one should open the cmd, create child process, pipe etc... Second one will use ControlSEnd to send command to the cmd.exe and then receive its output. Third one will close everything.

In other words, you can create custom interfaces to cmd.exe or integrate shell into your script.

Thats all :)

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 14th, 2006, 10:33 am 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2545
majkinetor wrote:
[Also as suggested by paranoid this is important note on the page he provided:

Quote:
To capture the output and control the input of programs that use high-level console I/O, one redirects their standard input and standard output through pipes, and reads from and writes to the other end of the pipes in the monitoring process.

The advantage of this method is that one doesn't need to worry about missing any output, since this approach doesn't use polling. But, conversely, this method has a problem of its own, in that it won't capture any output generated by low-level console I/O, and that programs that use low-level console I/O for input will bypass the redirection entirely. Alas, all too many DOS programs fall into this category.
Another method might be to redirect a console and have the application run in the redirected console instead of trying to redirect the application directly. If you are having trouble with a specific application then please give as much detail as possible. If I can reproduce or understand what you are trying to accomplish, then I might be able to give suggestions and/or try and provide a solution.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 14th, 2006, 10:38 am 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2545
majkinetor wrote:
this is the goal:

1. open the command prompt
2. order it to execute this and that command
3. close the prompt when you are finished

Live feed, in other words.

The "this and that" part is the most important unknown variable here. In most cases this is not necessary though. Input can be sent to STDin with a few modifications to the existing code and the output can be split into STDout and STDerr with a few more modifications. Creating full console emulation in most cases might be possible but rather inefficient. Why not just open a console window then and type your commands?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 14th, 2006, 11:02 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Quote:
The "this and that" part is the most important unknown variable here.
Regular things you run in console, like batch script commands etc..

Quote:
Creating full console emulation in most cases might be possible but rather inefficient. Why not just open a console window then and type your commands?
That was just example.. was not very serious about that. The question is life feed. For instance, if you type systeminfo in console, it will first show status in the first line until everything is calculated. Then, lame.exe will show the compreesion status all the time in single screen. There are bunch of console tools that does this way. We want to get this output. Thats why we call it live feed ! :D


So, the question is, can you do it or no?

BTW, I like to keep console on the desktop... I mean, the part of the desktop to be console. Its typical in linux world. If you can make it, I can make it stay on the desktop :)

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 2nd, 2006, 9:49 pm 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2545
majkinetor wrote:
So, the question is, can you do it or no?
I think so, based on the research and testing that I have previously done on the subject, but I'm not currently interested in taking the project in that direction. Sorry. I would be willing to try and help out (if I can) if you decide to code it though. If you already have then please provide a link :) .


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 189 posts ]  Go to page Previous  1 ... 3, 4, 5, 6, 7, 8, 9 ... 13  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users 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