Command List

In order for these functions to be available, you need to include the Shu.swc in your AIR project.
Instructions can be found here.


Executing other applications

shu.System.exec(filename:String, showGui:Boolean=false):Number show

Overview:
Executes an external application and waits for it to exit.
Parameters:
filename - String specifing path to an application to execute.
showGui - Boolean specifing whether to display the application's GUI.
Returns:
The exit code of the program launched.

shu.System.execAsync(filename:String, showGui:Boolean=false):Number show

Overview:
Executes an external application asynchronously. The return value is the application process ID which can be used to check if the application is still running by calling shu.System.isRunning.
Parameters:
filename - String specifing path to an application to execute.
showGui - Boolean specifing whether to display the application's GUI.
Returns:
The process ID of the launched application.

shu.System.isRunning(pid:Number):Boolean show

Overview:
Determine if the application specified by process ID is still running.
Parameters:
pid - The process ID to check.
Returns:
A boolean value of true indicates the application is still running, false otherwise.

shu.System.launchFile(filename:String):Boolean show

Overview:
Opens a file in the systems default assigned application.
Parameters:
filename - The file to open.
Returns:
A boolean value of true to indicate the file was opened, false otherwise.

shu.System.lastOutput:String show

Overview:
This property has the output of the last executed application (either executed via shu.System.exec or shu.System.execAsync).
Returns:
A string of the last executed applications output.

Database access

shu.MySQL.connect(host:String, port:Number, user:String, pass:String, dbName:String):Boolean show

Overview:
Connect to a MySQL database.
Parameters:
host - The URL to connect to.
port - The port number the MySQL database is running on.
user - The username to use when connecting.
pass - The password to use when connecting.
dbName - The database to use.
Returns:
A boolean value of true if succesfuly connected, false otherwise.

shu.MySQL.disconnect():void show

Overview:
Disconnect the MySQL database.

shu.MySQL.runQuery(query:String):Boolean show

Overview:
Run a query on the connected MySQL database.
Parameters:
query - A string of the query.
Returns:
A boolean value of true if the query executed succesfuly.

shu.MySQL.fetchRow():Array show

Overview:
Fetch the next row of a resultset from the last query. This can be called repeatidly to get all the results.
Returns:
An array of the row. Each element is a string.

shu.MySQL.seekRow(which:Number):Boolean show

Overview:
Seek to a specific row in the last resultset.
Parameters:
which - The row index, zero based.
Returns:
A value of true if the row was moved to, otherwise false.

shu.MySQL.rowCount:Number show

Overview:
This property has the number of rows in the last resultset.
Returns:
A number indicating the number of rows.

shu.MySQL.lastError:String; show

Overview:
This has the last error message encountered. This can be useful in diagnosing unexpected results.
Returns:
A string of the last error message.

Prompts and message boxes

shu.Dialogs.messageBox(message:String, caption:String, style:Number):Number show

Overview:
Displays a modal system messagebox.
Parameters:
message - The message to display.
caption (optional) - The caption to display in the title bar of the messagebox.
style (optional) - The buttons and icons to show. This is constructed by OR'ing the style properties :
  • shu.Dialogs.MB_OK
  • shu.Dialogs.MB_CANCEL
  • shu.Dialogs.MB_YES_NO
  • shu.Dialogs.MB_ICON_ERROR
  • shu.Dialogs.MB_ICON_INFORMATION
  • shu.Dialogs.MB_ICON_QUESTION
  • shu.Dialogs.MB_ICON_EXCLAMATION
Returns:
The numerical ID of the button clicked. It will be one of:
  • shu.Dialogs.MB_OK
  • shu.Dialogs.MB_CANCEL
  • shu.Dialogs.MB_YES
  • shu.Dialogs.MB_NO

shu.Dialogs.inputBox(message:String, caption:String, defaultValue:String):String show

Overview:
Displays a system input box dialog. The user enters a one line string and presses OK.
Parameters:
message - The message above the input textfield.
caption (optional) - The text to appear in the titlebar of the dialog.
defaultValue (optional) - An initial string of text to appear in the input textfield.
Returns:
The string of text the user entered.

Paths

These properties give you some common file system paths. Note they are all read-only.

shu.Paths.app:String show

Returns:
A string specifing the location the application resides at.

shu.Paths.desktop:String show

Returns:
A string specifing the location the users desktop.

shu.Paths.documents:String show

Returns:
A string specifing the location the users default documents directory.

shu.Paths.temp:String show

Returns:
A string specifing the location the systems temporary directory.

Screen

shu.Screen.capture(filename:String,left:Number,top:Number,right:Number,botton:Number):Boolean show

Overview:
Capture an image of the screen (or part of the screen) to a file.
Note that this function either takes just the first parameter or all parameters. If only the filename is supplied, the whole screen is captured. Otherwise the area specified by left, top, right and bottom is captured. The file to save to can be either a png, jpg, tiff or bmp and will be determined by the filenames extension.
Parameters:
filename - A string specifing the path to save the file to.
left (optional) - The leftmost position to capture.
top (optional) - The topmost position to capture.
right (optional) - The rightmost position to capture.
bottom (optional) - The bottom-most position to capture.
Returns:
A boolean value of true if the file was saved successfully, false otherwise.

Extend via custom DLL/dylib

N.B. The DLL/dylib must be an shu extension (eg it must implement the extapi)

shu.Extension.call(handlerName, ...):* show

Overview:
This function is used to call a function in an external shared library.
Parameters:
handlerName - The name of the registered handler function to call.
... - Any other parameters to pass to the handler function.
Returns:
Whatever the actual handler function returns.