From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Kernell32 to read command window

Hi.

 

I am trying to use kernell 32 to read the contents of the command window using the GetConsoleScreenBufferInfo windows function with Labview Call Library function. The function at the top of the vi works fine, which reads the computer name but the one below it doesn't return anything. The function is defined at the following site:

 

https://msdn.microsoft.com/en-us/library/windows/desktop/ms683171(v=vs.85).aspx

 

I'v never really used the Call Library function before so I'm not sure if I have it set up right. How do I get the right parameters set up?

 

Thanks,

 

Mark.

0 Kudos
Message 1 of 15
(3,759 Views)

GetConsoleScreenBufferInfo takes 2 input.

You provide none.

handle is the 1st input, not the 2nd.

The 2nd parameter is a pointer to a structure (Cluster in LabVIEW), not size.

 

You are very lucky.  LabVIEW usually crashes when you make this kind of error.

 

George Zou
0 Kudos
Message 2 of 15
(3,744 Views)

Where is this detailed. What type of cluster does it take?

0 Kudos
Message 3 of 15
(3,738 Views)

@MarkGreally wrote:

Where is this detailed. What type of cluster does it take?


the link you provided.

 

 

George Zou
0 Kudos
Message 4 of 15
(3,732 Views)

Yes but how does one convert this to a cluster. What sort of data types are they to which inputs. And in what order should they be in. Its all very vague, unless one is very familier with the windows API's the parameters are difficult to interpret. I would interpret the below as 1 input with 3 outputs.

 

  _In_  HANDLE  (ip1)                    hConsoleOutput (op1)
  _Out_ PCONSOLE_SCREEN_BUFFER_INFO lp (op2)   ConsoleScreenBufferInfo (op3)

 

0 Kudos
Message 5 of 15
(3,727 Views)

What sort of data types are they to which inputs. And in what order should they be in. Its all very vague

 

All defined in the link you provided.

 

George Zou
0 Kudos
Message 6 of 15
(3,716 Views)

I would also point out that you can use the .NET process library to launch a command-line process and you can then interact with it through STDIN and STDOUT to send commands to it, or to read out the current console window. I did post an example on the forums somewhere but I can't find it now.

 

Just thought I'd throw the alternative out there in case you struggle to get this working.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 7 of 15
(3,709 Views)

Sam. i think this the one you are referring to: Does it have a bug as when I run it it seems to run an indefinate loop and I cannot stop it and must use task manager to kill it.

 

With regards to kernell32 and call library function is there any documentation or examples on how to interact with labview?

 

 

 

0 Kudos
Message 8 of 15
(3,683 Views)

Yes - that's the one. It might have a bug, it was just a quick example I threw together for my own interest/the forums so not thoroughly tested - was more to point in the right direction than to be a complete solution.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 9 of 15
(3,673 Views)

I have modified your code to add a seperate button for read and replaced the while loop. This prevents it from hanging. It allows to do one read only. However the write function does not seem to work. It was initially but all of a sudden it has stopped.  i would run it, send string, then read. It only displays the initial run window data. Any ideas to why this may be?

 

Mark.

0 Kudos
Message 10 of 15
(3,659 Views)