views:

42

answers:

1

How to implement "record macro" like that in Microsoft Excel? PS: any language/platform. I just want an idea of how to do that. as far as i know, i can embed a script interpreter(maybe javascript) and make c++ object visible to scripts, just DOM in web browser. My question is that how to record user actions and then generated javascript code. you know, in Excel we can record a macro and Excel will generated some VBA code. Does someone know how to implement this feature in C++ or other languages.

A: 

One way to do it is have dual event handlers for each menu item / button click.

As the standard event handlers fire, your secondary macro-builder events fire. As the macro event builders fire you record a list of actions performed e.g.

ActiveDocument->Save.
ActiveDocument->SaveAs.
ActiveDocument->Print.
Find (AllDocument,"ThisText").SelectFirst
Edit.Cut
Find().SelectNext

You can then translate those actions into your desired scripting language.

Hope this helps.

Binary Worrier