CoolTerm Macros using AppleScript

If you have specific questions or problems with any of my Freeware applications, post them here.

CoolTerm Macros using AppleScript

Postby roger » Mon Apr 23, 2018 9:43 pm

While AppleScript doesn't support fancy GUIs, it does support simple dialogs. The following script can be used to create transmit macros for CoolTerm:
Code: Select all
tell application "CoolTerm"
   
   # Get a handle on the open window.
   set w to WindowID (0)
   if w < 0 then
      # there are no open windows
      display alert "There are no active terminals"
      return
   end if
   
   repeat
      # display a dialog with buttons
      choose from list {"Marco Text 1", "Macro Text 2", "Macro Text 3"} with prompt "Please select Macro and click OK to send."
      if the result is not false then
         # send macro to CoolTerm
         set macro to result as text
         Write {w, macro}
      else
         # user clicked "cancel"
         return
      end if
   end repeat
   
end tell
The script creates a dialog with a list of strings and allows the user to select a string from the list and then send it to CoolTerm by pressing the OK button. As long as OK is pressed, the script stays in the "repeat" loop which will keep displaying the dialog. This is a bit of a hack which is necessary because pressing any of the buttons closes the dialog. However, this does the job. Pressing "Cancel" exits the loop and terminates the script.
CoolTerm_Macro.png
You do not have the required permissions to view the files attached to this post.
User avatar
roger
Site Admin
 
Posts: 214
Joined: Fri Apr 24, 2009 12:41 am

Return to Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron