Gui4Cli is an interpreted, untyped, procedural programming language for easily creating Windows apps. It has a wide set of commands, it can be easily extended and can create self-standing executables. It is Event-driven, and intuitive and geared to creating stand-alone guis or interfaces for other, console driven programs (as it's name implies). The new version can also handle Unicode. Below is the simplest gui possible.
G4C MyGui
xOnLoad
MsgBox "Hello world." OK
xOnLoad
MsgBox "Hello world." OK
If you write this in any text editor, save it with the ".gui" or ".gc" extensions (assuming you have installed Gui4Cli), then when you double-click it, it will present a standard message box with "Hello World."
- The "G4C" is a marker that must be present in all guis. It tells Gui4Cli it's a gui script.
- The "MyGui" can be any name you want to give your gui. You can then refer to this gui from any other gui and call it's functions, access it's variables, etc.
- "xOnLoad" is an Event. Events mark the start of blocks of code. They all start with "x". Events such as xOnLoad, xOnQuit, etc, are triggered when the given event happens. In this case, xOnLoad is triggered when the gui is loaded and the "MsgBox" command is executed. You can have any number of commands after it, calling routines in this or other guis. There are also visual events, like xButton, xTreeview, etc and the xRoutine event, which is the equivalent of a "function" in other languages.
- "MsgBox" is a Command. Gui4Cli has a wide set of commands, specifically geared to making your life with Windows easier.
G4C MyGui
Window 10 10 200 300 "My window"
xOnLoad
GuiOpen MyGui
xButton 10 10 100 20 "Double it!"
Input "Enter a number" var
var2 = $($var * 2)
MsgBox "$var times 2 equals $var2" OK/INFO
GuiQuit #this
Window 10 10 200 300 "My window"
xOnLoad
GuiOpen MyGui
xButton 10 10 100 20 "Double it!"
Input "Enter a number" var
var2 = $($var * 2)
MsgBox "$var times 2 equals $var2" OK/INFO
GuiQuit #this
The first thing to note is the WINDOW declaration. This is like an Event, ie it stands on it's own, but it will never be triggered so there's no point attaching code to it. It will define a window.
- Note the numbers next to it - 10 10 200 300. This is the Left, Top, Width and Height of the window. The same further down for the xButton event. You enter these when you create the gui, but thereafter you can visually alter them by resizing and moving the window and all the controls (buttons, treeviews, etc), while the gui is running. You can even drag & drop controls from one gui to another, or clone them in the same gui. See the "Tutorials & Visual Editing" video and here for more.
- Since v 20.10 there is also a "Preferences" system which is always present and allows you to alter the look of your gui and the controls within it very easily creating something like a CSS file for your gui (click here for more)
- Put up an INPUT requester to get input from the user (a number) and place it in a variable called "var".
- var2 = $($var * 2) - will then multiply this number by 2 and put it into variable "var2". Note the use of variables - "var" is the variable's name, and "$var" is the variable's contents. Variables are untyped and need not be declared before-hand. Also note the math calculation - it's done inside brackets with a "$" in front and can be quite complex.
- Then we use a MsgBox to display the result.
- After the user presses OK, the "GuiQuit" command will be executed. The "#this" is a shortcut for the gui's name. We could have written "GuiQuit MyGui" instead. GuiQuit will unload the gui from memory. If we did not give this command the gui would just remain in memory, waiting until we open/unload it from somewhere else, or until Gui4Cli itself quits, unloading everything.

On the left is a simple File Explorer type file manager, complete with Listview, Treeview, Spliter bar, Resizable window, DragDrop, the ability to copy or move files, run programs etc. There is full shell context menu support by default and a few Gui4Cli goodies, such as assigns, thrown in. Several things to note..
- First of all, the Editor. You can use any text editor you want, but the following have text highlighting, code folding, etc:
- "Notepad++" - (see screenshot below) A very capable and well known editor for many programming languages. The new version (in 2022) has Gui4Cli syntax highlighting by default. You just have to choose it from the menu. See here for help in installing it.
- "SciEd" - (see screenshot to the left) This is itself a gui, written in Gui4Cli, using an external dll (from scintilla.org) which is added as an event within Gui4Cli.
- Then there's "attributes" - "winattr" which are Window Attributes and "attr" which are event attributes. These tell the window and the events how to resize, what colors to use, what frames, styles, etc. Version 20.10 of Gui4Cli also has a "Preferences" system which allows you to do this visually (like CSS for your gui)
- Note also the use of "$$" as in "$$lv.dir". The double-dollar indicates an "internal variable". These give you information about the gui, the controls and the system in general. In this case, the $$lv.dir will be replaced with whatever directory the current listview is currently in.
- Comments follow the C language design - // starts a line comment and /* text... */ is a block comment.
- The order of the events doesn't usually matter. You can have your Window and xOnLoad events at the bottom if you wanted.
The language structure of Gui4Cli is simple. It began life on the Amiga computer and was designed to work smoothly with the command line.
Example: On the right is some code which will recurse through a xTreeview, and print to the output window all it's branches and sub-branches, complete with indentation. It uses a simple push-pop mechanism. Guis can be "compiled" into executables. There is a wizard included that will take the guis, images, DLLs that you need, compress them all together and inject them into a copy of Gui4Cli. The result is an efficient executable that's very easy to create. There is also a full explanation and examples of how to create DLLs to add commands and events to Gui4Cli. It's very simple. For a simple DLL example click here.. |