View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Bill Pfister Bill Pfister is offline
external usenet poster
 
Posts: 132
Default How to get data from CMD line

Is there a sendkey command for mouse functions??

Yes - you can essentially emulate anything you do with an input device from
an API call. I usually use http://www.allapi.net for reference.

One approach is to
1) find the windows handle for your CMD box (use "FindWindows" API call)
2) find the location of the window title (I don't recall the api function)
3) use "mouse_event" to simulate a mouse right-click on the title bar
4) use the "sendkeys" to move around on your context/right-click menu and
press enter for confirming your menu selection

Unfortunately, I don't have any examples on handle, but allapi should get
you headed in the right direction.



"Kevin" wrote:

I dont think its going to work for me, the CMD app that Im running doest even
have a way to select and copy with the keyboard. I cant even hit Alt to get
a drop down menu. The only way to get hte options to come up is to right
click the title bar. This is a lousy interface.....

Is there a sendkey command for mouse functions??

Unfortunatly I dont know anything about using the API, and dont know if that
will work either.

"Bill Pfister" wrote:

Try using SendKeys (the API version is more robust than the Excel
implementation) to send a Select All / Copy. Then you can read the clipboard
and parse in Excel. Not the best solution but it should work.

Regards,
Bill


"Kevin" wrote:

Unfortunatley that wont work for me, the CMD shell Im using is a striped down
version for a storage array and I cannot change directories or direct to a
file. It is a CMD window that is interating with the storage array and the
commands are VERY limited. the only way I can get the data into excel now is
to select the text and paste it. The only traditional CMD functions I have
on it are to right click the title bar and choose Mark,Copy, Paste, Select
all, Scroll and Find.

"moon" wrote:


I think it's less work if you just send your output to a file.
So 'C:\dir' gives a directory, but to flush the directory contents into a
text file, use:
C:\dir C:\dir.txt

Once you have the text file, it's quite easy to open that with Excel.


"Kevin" schreef in bericht
...
I need a way to run a command in the CMD window and retrieve the output
back
into Excel. Is there a way to do this?

For example if my output below is in the CMD window I want to capture the
Items starting with DEVA.
------------------------------------------------
Systems available on this Manager:
DEVA01-0BF0
DEVA02-0290
DEVA03-0CD0
NoSystemSelected
------------------------------------------------