Why on earth would we want a button in a macro?
A button can run any OS command, so you can do a lot. I am however going to keep this practical and for all the people out there that make macros for others. Our button will open a webpage, this webpage could be your website or even a YouTube video with instructions.
NB. A button can execute a script, run a fuse, or any known operating system command.
Adding a button is the same as adding a label or drop-down and can be completed inside resolve. However, you may want to edit the code to ensure the button works correctly on both Mac & Windows. Also, we can move the button to any location via the code.
Assumptions
- You are on the fusion page
- You are either modifying an existing tool/effect or creating your own.
- The result will be a GroupOperator/MacroOperator
- The result can be for fusion, edit page, or cut page.
- Select the node you want the Button on.
- Right-click and choose "Edit Controls"
- Over Type Name: "New Contol" with your button title
- Leave "Type" as "Number"
- Select the "Page" you want the label to be on (User)
- Uncheck "Animatable"
- Check "Passive"
- Input Crtl select ButtonControl
- Enter in the Execute box "os.execute('start "" "your url"') --Windows
- Select "OK"
9A. Enter "os.execute('open "" "your url"') --Mac
10. Select "OK"
The button will now appear at the bottom of the inspector on the page you selected. As long as the URL you entered is correct when you click on the button, the default web browser will open and navigate to it. The computer terminal or command prompt will flash on the screen for a millisecond as we have just triggered an OS command.
Hold the phone! What if you don't know the operating system this will be used on, well we are back to coding. (Although I have read that "open" will work on Mac or Windows).
The section of code we need to tweak will be the section created when we went into "Edit Controls" This generates the section called UserControls.
- UserControls = ordered() {
- Button = {
- LINKS_Name = "Button",
- LINKID_DataType = "Number",
- INPID_InputControl = "ButtonControl",
- INP_Integer = false,
- INP_External = false,
- INP_Passive = true,
- BTNCS_Execute = [[
- os.execute('open "" "https://www.blackmagicdesign.com/"')
- os.execute('start "" "https://www.blackmagicdesign.com/"')
- ]],
- },
Adding lines 9, 10, 11 & 12 sets the button to open in Mac or Windows.
BTNCS_Execute = is a powerful command and can run almost anything.
The URL does not have to be a webpage it can also be a file path on the computer, so you could open a local webpage or a pdf file.
If you require 2 buttons then just add another button to the same node, and then set the "width" to 0.5. width is above the execute box.
That's it!
Thanks for taking the time to read this post and if you would like to buy me a coffee, pizza, narrowboat then it is greatly appreciated.
NIce. I learn a lot by reading your post.
ReplyDeleteMany Thanks
Thanks for reading the post. I have started a new website resolvebrowser.co.uk which includes more tips and tricks. Enjoy!
Delete