[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.vb.general.discussion

Automating Console Application (Best Approach?

christianlott1

2/17/2011 8:54:00 PM

Hi,

I wanted to automate this purely in VB(A) but I'm thinking about using
AutoHotKeys or maybe even Expect 4 Windows.

The problem: client is forced to look up data in a text application
probably dating back to the mid 80's.

Requirements: Send various keys to the application. Response time is
usually pretty good. At the end client is required to capture the last
text page as a print out report - so some kind of text screen capture
if that's possible, which I'd probably like to dump into a string
variable.

Using an MS Access db (VBA).

Thanks


17 Answers

GS

2/17/2011 11:02:00 PM

0

5k3105 laid this down on his screen :
> Hi,
>
> I wanted to automate this purely in VB(A) but I'm thinking about using
> AutoHotKeys or maybe even Expect 4 Windows.
>
> The problem: client is forced to look up data in a text application
> probably dating back to the mid 80's.
>
> Requirements: Send various keys to the application. Response time is
> usually pretty good. At the end client is required to capture the last
> text page as a print out report - so some kind of text screen capture
> if that's possible, which I'd probably like to dump into a string
> variable.
>
> Using an MS Access db (VBA).
>
> Thanks

If the file is a text file could you not just read it using standard
VBa I/O?

--
Garry

Free usenet access at http://www.eternal-sep...
ClassicVB Users Regroup! comp.lang.basic.visual.misc


Dee Earley

2/18/2011 9:43:00 AM

0

On 17/02/2011 20:54, 5k3105 wrote:
> Hi,
>
> I wanted to automate this purely in VB(A) but I'm thinking about using
> AutoHotKeys or maybe even Expect 4 Windows.
>
> The problem: client is forced to look up data in a text application
> probably dating back to the mid 80's.
>
> Requirements: Send various keys to the application. Response time is
> usually pretty good. At the end client is required to capture the last
> text page as a print out report - so some kind of text screen capture
> if that's possible, which I'd probably like to dump into a string
> variable.

If it's "plain text" out (not curses or similar) then CreateProcess and
pipe will do what you want.
If it is a GUI console app then it's still possible, but you'll need to
put a lot more effort into it.

> Using an MS Access db (VBA).

Ah...
Good luck :)

--
Dee Earley (dee.earley@icode.co.uk)
i-Catcher Development Team
http://www.icode.co.uk...

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)

christianlott1

2/18/2011 3:59:00 PM

0

GS, like Open, Close and Input?

Dee, I looked at

http://www.codepedia.com/1/...

to use pipes and the example worked fine for me.

I'd like to find a way to get the hwnd of the created process (from
the process id) but I haven't found an example that works - I've tried
several.


Thanks.

GS

2/18/2011 4:42:00 PM

0

It happens that 5k3105 formulated :
> GS, like Open, Close and Input?

Yes, that's what I meant. I don't see why you need to automate an
instance of a text program to get the contents of a text file. If VB's
I/O functions won't do it then maybe ADO would be a possible way to go.

--
Garry

Free usenet access at http://www.eternal-sep...
ClassicVB Users Regroup! comp.lang.basic.visual.misc


christianlott1

2/18/2011 5:04:00 PM

0

On Feb 18, 10:42 am, GS <g...@somewhere.net> wrote:
> It happens that 5k3105 formulated :
>
> > GS, like Open, Close and Input?
>
> Yes, that's what I meant. I don't see why you need to automate an
> instance of a text program to get the contents of a text file. If VB's
> I/O functions won't do it then maybe ADO would be a possible way to go.

I can automate a console application with ADO? Can you show me an
example?

Thanks

GS

2/18/2011 5:11:00 PM

0

5k3105 has brought this to us :
> On Feb 18, 10:42 am, GS <g...@somewhere.net> wrote:
>> It happens that 5k3105 formulated :
>>
>>> GS, like Open, Close and Input?
>>
>> Yes, that's what I meant. I don't see why you need to automate an
>> instance of a text program to get the contents of a text file. If VB's
>> I/O functions won't do it then maybe ADO would be a possible way to go.
>
> I can automate a console application with ADO? Can you show me an
> example?
>
> Thanks

No, you can't automate an app with ADO. You can read the text file
contents into a recordset, though, same as if you're reading a dbase
file. Just set the connection string for "Text" as the data source.

--
Garry

Free usenet access at http://www.eternal-sep...
ClassicVB Users Regroup! comp.lang.basic.visual.misc


Dee Earley

2/18/2011 5:13:00 PM

0

On 18/02/2011 15:58, 5k3105 wrote:
> GS, like Open, Close and Input?
>
> Dee, I looked at
>
> http://www.codepedia.com/1/...
>
> to use pipes and the example worked fine for me.
>
> I'd like to find a way to get the hwnd of the created process (from
> the process id) but I haven't found an example that works - I've tried
> several.

The hWnd shouldn't come into it.
Create the pipes, then call CreateProcess with them to be able to
send/receive the data.

--
Dee Earley (dee.earley@icode.co.uk)
i-Catcher Development Team
http://www.icode.co.uk...

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)

christianlott1

2/18/2011 5:17:00 PM

0

On Feb 18, 11:12 am, Dee Earley <dee.ear...@icode.co.uk> wrote:

> The hWnd shouldn't come into it.
> Create the pipes, then call CreateProcess with them to be able to
> send/receive the data.

Yes, but I wanted to get the hwnd to position the screen inside my
form so we can have a reference to what's being automated.

Thanks

christianlott1

2/18/2011 6:01:00 PM

0

GS, I'd still need to send commands to it. I'm already using ReadFile:

Do
retVal = ReadFile(ReadPipe, tmpRead, 1256, bytesRead, 0&)
readData = readData & Left(tmpRead, bytesRead)
DoEvents
Loop While retVal > 0

The example works fine for 'ping' but now I'm testing on the command
prompt (CreateProcess 'cmd') and it crashes.
retVal = 1

then stalls my program the second time through the loop.


GS

2/18/2011 7:32:00 PM

0

5k3105 presented the following explanation :
> GS, I'd still need to send commands to it. I'm already using ReadFile:
>
> Do
> retVal = ReadFile(ReadPipe, tmpRead, 1256, bytesRead, 0&)
> readData = readData & Left(tmpRead, bytesRead)
> DoEvents
> Loop While retVal > 0
>
> The example works fine for 'ping' but now I'm testing on the command
> prompt (CreateProcess 'cmd') and it crashes.
> retVal = 1
>
> then stalls my program the second time through the loop.

Sorry, but I don't work with console apps and so can't advise you
there. I was assuming (rightly or wrongly) that you wanted to automate
the text app's open file, suggesting you can modify the text file
directly from VB. Hopefully, someone with console app experience will
step in to assist you.

--
Garry

Free usenet access at http://www.eternal-sep...
ClassicVB Users Regroup! comp.lang.basic.visual.misc