The title is really the full question so here's some more context.
I'm trying to create a macro in Visual Studio Code that executes a sequence of actions. I'm picking between macros and Commands to do this, but regardless I have the problem where the actions I'm trying to execute only bring up the command palette / Quick Open and the user still needs to choose an option, and I can't find a built-in command to send text to the already open and focused command palette / Quick Open.
For example, I want to run Transformer's "Decode Base64" action. That extension exposes the command dakara-transformer.escapes
which brings up the command palette / Quick Open with a list of encode and decode actions, but the user needs to pick the specific entry from the list. Unfortunately, that command takes no arguments that I can use to make this selection.
In that specific case I can work around the problem by using workbench.action.quickOpenSelectNext
and workbench.action.acceptSelectedQuickOpenItem
to manually go down the list and select the item I want, but there are some other similar actions I want to execute where this becomes a hassle. Also, I would like the macro to not break if the order of the list changes.
I've found several similar questions, such as Can I pass a custom text argument to the command palette in vscode?, Can VS Code type text with keyboard shortcuts? and How to enter text in command palette in VSCode extension. (That last question I think is the same as mine, but the OP marked as accepted an answer that doesn't really address their original question.)
Based on the answers to those questions, I've tried
"sequence": [
{
"command": "dakara-transformer.escapes",
},
{
"command": "type",
"args": {
"text": "Decode Base64"
}
}
]
... which opens the command palette / Quick Open in the context of Transformer with the text box focused but nothing is typed in the text box, and
"sequence": [
{
"command": "dakara-transformer.escapes",
},
{
"command": "workbench.action.quickOpen",
"args": "Decode Base64"
}
]
... which dismisses the command palette / Quick Open opened by Transformer, opens a new one not in the context of Transformer, and then types "Decode Base64" into the new command palette / Quick Open. The attempt below has the same problem:
"sequence": [
{
"command": "workbench.action.quickOpen",
"args": ">Transform: Encode / Decode"
},
{
"command": "workbench.action.acceptSelectedQuickOpenItem"
},
{
"command": "workbench.action.quickOpen",
"args": "Decode Base64"
}
]