4.16 FAQ-375 How do I create custom toolbar buttons that run my script macros?

Last Update: 4/12/2016

Buttons on a toolbar are a convenient way of running LabTalk script files. To create your own buttons, you need 3 files in order to create a new button group. The first is the LabTalk script file that contains the script that is executed when the user clicks a button. The second is the bitmap file that contains the image that is displayed on your button(s). The third file, automatically created for you, is an INI file.

The INI file stores the name of the button group, the name of the bitmap file used to create the group, and the number of buttons that the group has.

When creating a custom button group for export to an .OPX file, consider saving your button group's initialization file, bitmap file(s), script file(s), and any other support files to a user-created subfolder in your User Files Folder. When another Origin user installs your .OPX file, your custom subfolder will automatically be created in the user's User Files Folder, and this subfolder will contain the files for the custom button group. This allows you to keep your custom files separate from the other Origin files.

Please follow these steps to put everything together.

  1. Use Code Builder to develop your LabTalk script OGS file, which contains one or more scripts, organized into different sections, to be associated with one or more buttons.
  2. Create a bitmap file, using any program that will create a 16 color bitmap such as Window's Paint.
  3. You can start with the built-in user defined toolbar bitmap with Window's Paint. Open Userdef.bmp found in your User Files Folder.
  4. The image height needs to remain at 16 and should not be changed. The image width should be 16 times the number of buttons needed. Each button is 16 pixels high by 16 pixels wide.
  5. Edit each button as needed.
  6. Save the BMP as a 16 Color Bitmap.
  7. In Origin, select View: Toolbars to open the Customize Toolbar dialog.
  8. Click on the Button Groups tab.
  9. Click the New button in the Button Groups to open the Create Button Group dialog.
  10. Enter a new Group Name.
  11. Specify the Number of Buttons.
  12. Click the Browse button to locate your bitmap file. This file should be in your User Files Folder.
  13. Click OK.
  14. The Save As dialog will open. Enter the same name as that of your bitmap file. Click OK to save the INI file. Your group is added to the Groups list. When you select it you will see your button(s).
  15. Click on one of the buttons to select it.
  16. Click the Settings button, to open the Button Settings dialog.
  17. Click the Browse button to locate your OGS file.
  18. Enter the Section Name of the OGS file and any arguments in the Argument List.
  19. Enter something descriptive in the Tool Tip Text box.
  20. Enter a status bar message in the Status Bar text box.
  21. Click OK.
  22. Repeat steps 15-21 for each of the buttons in your Button Group.
  23. Drag the first button out onto your Origin workspace. A toolbar is created. You can now drag all other buttons onto this toolbar.

Keywords:automate, click, repeat, button, bitmap, custom