Key press in a variable

I have a use case where the user might use a different key press for the same effect, namely Home. (Also Enter versus Return.)

So, at the top of the macro I’d like to define a variable that the user can Use to change eg Home to some key press eg Ctrl+h.

Later, throughout the macro(s), this variable is to be used to tailor a key press.

Is this feasible? Is this the wrong approach?

I suppose I could isolate the key press to its own macro but that seems overkill. Already I have a macro that automates one of the low level actions - pushing text on the clipboard into the editor (ISPF Edit).

(The actual use case is an X11/xQuartz app called x3270. It’s a mainframe terminal emulator. I want to ship tailorable versions of my macros.)

As you probably know, the Type a Keystroke does NOT take a parameter.
So, if that is the Action you want to change based on the user's choice/configuration, here are some ideas, mostly untested:

  1. Put alternate keystrokes in a Switch/Case Action
  2. Use the AppleScript key code command
  3. Modify the XML of the Macro by script.


1 Like

So, I have encapsulated “Enter” in its own macro. (It basically does a “Ctrl+e” and the terminal emulator’s .3270pro file translates that reliably into mainframe Enter.)

What I realised is that the time taken to invoke this single-action macro is quite small compared to the neighbouring actions: Typing in text.

(I suppose I could seek a way to append Ctrl+e to the strings I’m entering by typing - perhaps with a variable. I’m not sure how to encode eg Ctrl+e in a variable.)