At the most basic level, a script is nothing more than a text file containing a series of commands to be run serially. It doesn't matter if the command is cli, gui, or built-in. When one command exits, the script will launch the next one on the list.
At higher levels, there's also a scripting language that allows you to run commands conditionally, or in loops, or in other programmatic ways, and of course there are exceptions and special cases, but underneath it all it's still a one-command-at-a-time process.
If you gave us some details about what you're trying to accomplish, maybe we could help you more directly.
Edit: seeing your reply above, what you probably want is a macro recorder. These are programs that record a series of actions, mouse-clicks, key punches, etc. Then you can play the whole sequence back again.
Check out cnee/gnee/xnee or jw_record/playback
If you want something more flexible, then it depends on the specific program you want to work with. If the program is controllable through cli, then you can probably script something for it.