Something Like Photoshop Action

Hi
As you know In Photoshop we can record work on one file and play it on other files.
Photoshop tracks every move, filter, export, and anything
Did glyphs track changes? can we have Something Like Photoshop Action?
maybe like this (Not working now)

import GlyphsApp
from vanilla import Window, Button, List
import json
import os

# Define the path for saved files
saved_files_path = os.path.join(GlyphsApp.GSGlyphsInfo.applicationSupportPath(), "Recordings")
if not os.path.exists(saved_files_path):
    os.makedirs(saved_files_path)

class GlyphRecorder:
    def __init__(self):
        # Define UI Window
        self.w = Window((400, 300), "Glyphs Recorder")
        
        # Buttons
        self.w.record_button = Button((10, 10, -10, 20), "Record", callback=self.start_recording)
        self.w.stop_button = Button((10, 40, -10, 20), "Stop", callback=self.stop_recording)
        self.w.save_button = Button((10, 70, -10, 20), "Save", callback=self.save_recording)
        
        # Saved recordings list with Run and Delete buttons
        self.w.saved_files = List((10, 100, -10, -40), [], selectionCallback=self.load_files)
        self.w.run_button = Button((10, -30, 180, 20), "Run", callback=self.run_recording)
        self.w.delete_button = Button((200, -30, -10, 20), "Delete", callback=self.delete_recording)
        
        # Initialize variables
        self.recording = []
        self.is_recording = False
        self.update_file_list()
        
        # Open window
        self.w.open()

    def start_recording(self, sender):
        self.is_recording = True
        self.recording = []

    def stop_recording(self, sender):
        self.is_recording = False

    def save_recording(self, sender):
        if not self.recording:
            print("No actions recorded.")
            return

        # Get the save file name from the user
        save_name = GlyphsApp.GetSaveFile("Save Recording", saved_files_path, ["json"])
        if save_name:
            with open(save_name, "w") as file:
                json.dump(self.recording, file)
            print(f"Recording saved as {save_name}.")
            self.update_file_list()

    def load_files(self, sender):
        print(f"File selected: {sender.getSelection()}")

    def run_recording(self, sender):
        # Get selected file and run actions
        selected_file = self.w.saved_files.getSelection()
        if selected_file:
            file_path = os.path.join(saved_files_path, selected_file[0])
            with open(file_path, "r") as file:
                actions = json.load(file)
            # Replay actions in Glyphs App
            print(f"Replaying actions from {selected_file[0]}...")

    def delete_recording(self, sender):
        # Delete the selected recording
        selected_file = self.w.saved_files.getSelection()
        if selected_file:
            file_path = os.path.join(saved_files_path, selected_file[0])
            os.remove(file_path)
            print(f"{selected_file[0]} deleted.")
            self.update_file_list()

    def update_file_list(self):
        # Load saved files but do NOT call selection callback when updating
        saved_files = [f for f in os.listdir(saved_files_path) if f.endswith(".json")]
        self.w.saved_files.set(saved_files)

GlyphRecorder()

Yohoo? Anybody home?

Please note that there will be less activity over the weekend and that we also need time to think about solutions to your question.

I don’t think recording activity is possible currently as Glyphs does not track modifications in a way that can be generalized to a macro. Glyphs does track modifications, but it does so for the undo feature and cannot be reused to replay the action on a difference selection.

Instead, you can automate Glyphs with Python macros and scripts. These are more powerful than recorded macros, but they require some Python knowledge and time to write. Maybe there is already a script that does what you would want to automate?

Sorry for not answering earlier.

building the UI for this is obviously easy. The actually recording is more tricky. It would need to put support for it in every method or function. That would be a lot work and overhead. In most cases it is more convenient and useful to write (or adapt) a python script. I understand that it would be more convenient for beginners to record …

Thanks, Georg
So, the answer for all work recordings is No. Is it possible to track and record work with a transformation panel?

Transformations are quite easy to script:
https://docu.glyphsapp.com/#GSLayer.applyTransform

I am not looking to write a transformation script. Instead, I want a script that can track user actions, record them, and save those actions for application to other glyphs. Additionally, if possible, I would like to know how many panels, menus, filters, and other elements can be tracked and recorded for this purpose.

Why? What actions are you trying to perform?

Writing scripts for every simple task is not the best approach; instead, we should automate them. If we can work on and edit one glyph, record the actions we’ve taken, and then apply those actions to another glyph, that would be a Great script.

But in most cases you need more than just a simple replay of the actions you do from the transform panel. e.g. you might need selection. And as you mentioned the transform panel, you can use Path > Transformations for all selected glyphs at once.

Can you give an example? I have never needed this.

No need to select. everything including numbers, values, filters, and … are recorded and fixed.

In one font file, yes. But this can be used for any font files.

Yes.
This is a simple example:
correct path direction + round coordinates + tidy up path + add extremes can record and run with one click

Then, what you’re describing is entirely feasible with a Python script.

Photoshop doesn’t have an interface for code-based interaction, which is why Actions are useful. For Photoshop, this approach makes sense; however, with Glyphs, it’s different since you can interact with the software using GlyphsAPI and Python.

This is much faster with keyboard shortcuts.

Select all glyphs, run:
Cmd+Option+Shift+R (Correct Path Direction for all Masters)
Round Coordinates for all Masters
Cmd+Option+Shift+T (Tidy up Paths for all Masters)
Cmd+Shift+E (Add Extremes, currently you have to go through all masters for this)

I don’t see how you need an action or even a Python script for this.

What exactly do you mean by this? You can interact with Photoshop using ExtendScript, UXP, Apple Script, VB Script, etc.

I don’t see any fundamental difference between Glyphs and Photoshop in the ability to interact with the application through code, apart from which languages are supported, and perhaps how ‘deep’ user code can go in controlling the application.

I can see the usefulness of recording actions. And if only to get a basis for a script. If I would implement something like this, the recorder would spit out some python code. Doing it like in Photoshop where you get a list with the actions would “A” be too much work and “B” to inflexible. When I was using Photoshop actions a long time ago I alway wanted to edit the action stack, change parameters …

And do you know any other app that is doing this?

Maybe I am misunderstanding what you want to do but why do you need to record this? Simply select all glyphs you want to process and then use the commands.

That example was very simple. In Photoshop and Illustrator, all commands have shortcuts or you can define a shortcut for it. Also, both programs support scripts, so why do they have action panels? Because it is not wise to write scripts or remember many shortcuts for a very simple task. And what is better if the same work can be done in two different ways

Illustrator