LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Record a Macro in LabVIEW :) ?

Hi All,

I was asked recently if there's any way to "record" a series of operations on the front panel and save them off for later re-execution within LabVIEW... possibly using VI server, or some such? E.G. Click button 1, change value of input numeric, click "ok" button, etc. etc. Something very akin to being able to record macros in MS Excel or any other packages, I guess. Has anybody come across anything which might be of use to me here? Or know of somebody who's done this already?

Cheers,

M.J.
0 Kudos
Message 1 of 16
(5,357 Views)

Years ago I wrote many a macro for NIH Image.... I know what you want but have not seen it exactly in LV. Aside from just making the LV code do the work one can create a list of VI's that do the task. Have this list as a string that can be added to and changed in a textfile. Read in the string array of "tasks", or vi's to call that do the operations one by one, and dynamically execute them by using a loop. Not exactly a macro but close.

 

Mark

0 Kudos
Message 2 of 16
(5,349 Views)
What you could do is register for every possible event for all controls, and store those in some queue and save the data. Maybe some nice excercise...

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 3 of 16
(5,341 Views)

I have done something along those lines. Basically, I had a series of LV demos I wanted to run continuosly when we were presenting somewhere, so I wrote a VI which monitored the mouse in a loop (using the input VIs) and logged the position and timing of every click in a file.

Then, when I wanted to replay it, I had the program load the list and calculate the trajectories and timing and moved and "clicked" the mouse using Windows API functions (SetCursorPos and Mouse_event, probably. You can search for example in the forums). Keyboard clicks can be recorded and simulated as well. The important point about this is that it was completely stupid - it had no idea what it was clicking on, just that that was the location where the click was made. If for any reason the window would have moved, the click would not have worked.

If you want to make this more intelligent, then you can log the label of the control being modified and then when you need to replay use its properties to decide where to click.


___________________
Try to take over the world!
Message 4 of 16
(5,331 Views)
Hi,

I'm a newbie with LabView but record and re-play a macro is basically what I want to do.

Imagine a front panel with buttons, numeric commands...

I managed to record in a text file all the events on the commands.

Here is an exemple of the text file:

03:21:14    1    Booléen 2
03:21:16    0    Booléen 2
03:21:17    2    Numérique
03:21:20    3    Numérique
03:21:28    1    Numérique
03:21:30    0    Numérique
03:21:34    1    Booléen
03:21:36    0    Booléen

Now I want to re-play one of theses macros.
Where to begin?!
I understood how to extract the name of a control and its value and I think it can be possible to respect the timing between each action with a "timed loop" and the difference between the time of an action and the time of the following one but I don't understand how to automatically fire the action with the name of a control and its value...

Can somebody turn on the light please?! Smiley Happy
0 Kudos
Message 5 of 16
(5,208 Views)

If I understand your description correctly, you should be able to use the Value(Signaling) property to set the control's value and fire an event.

Start by building an array of references for all the controls in the front panel (you need to do this recursively because of tab controls and clusters. There have been several VIs posted for doing this) and get their labels. You can then search the labels array for the label and use that index to get the reference to your control from the second array and use that reference to change the value of the control.

You should note that this will not work for latched boolean controls.


___________________
Try to take over the world!
Message 6 of 16
(5,196 Views)
Hello,

THX for your answer... Smiley Happy
I made some progress.

Here it is...
My vi may be badly drawn but it works! Smiley Tongue

Now I have to respect the timing between each action, at the moment the timing between an action and the following one is "hardcoded" to 2 sec...
I think I'll have to use "timed loop" but how to extract the difference between the time of an action and the following one?

Any lead would be appreciated!

Have a nice WE!
0 Kudos
Message 7 of 16
(5,152 Views)
to control the timing you can simply use the "wait" VI after each action, using the correct "delta_time" read from your sequence file.
Message 8 of 16
(5,139 Views)
THX!

It's easier!

Here is the result...

I have still a problem: I can't record a second macro just after the first I recorded... Same for the re-play...

Can somebody take a look and explain me why?

0 Kudos
Message 9 of 16
(5,093 Views)
your "REC event" is in a event structure that is NOT included in a while loop. Then it can't be repeated more than once.
 
You have to redesign your VI. You must place the "REC event" inside a unique "while loop" that also checks your controls.
 
0 Kudos
Message 10 of 16
(5,070 Views)