microsoft / VS-Macros

An extension for Visual Studio 2013+ that enables the use of macros in the IDE. The extension can record most of the features in Visual Studio including text editing operations.
Other
131 stars 41 forks source link

Support recording actions on Modal Windows #23

Open Korayem opened 8 years ago

Korayem commented 8 years ago

I am trying to automate Scaffolding.

I record a Macro for Solution > Project > Add > New Scaffolded Item > I Choose Template > I Enter Entity Name

The macro records following steps only:

dte.ExecuteCommand("ProjectandSolutionContextMenus.Project.Add.NewScaffoldedItem");
dte.ExecuteCommand("File.SaveAll");

Ideas?

justcla commented 8 years ago

Macros does not support recording of interactions with dialogs. So it does not capture the entity name you entered.

The DTE object provided, which records and plays back interactions with Visual Studio, does not have APIs for capturing dialog input.

One possible solution for recording interactions with dialogs would be to use CBT hooks to capture window events (like create and destroy) and trigger a separate keyboard capture/screen scraper to record the actions until the dialog is destroyed (then switch back to using the inbuilt Shell capture tool.)

And to playback the macro: Create and import an object that can be executed from Javascript that would perform UI Automation (in order to focus on dialog input boxes and buttons and enter text or keyboard commands). Note: Depending on which dialog is being used, you might get more functionality if working with the specific flavor of UI automation (ie. Win32, WinForms, WPF).