Automation to trigger from highlighting text

I would like to be able to create style & GPT menus that appear once any text is highlighted. This could be done as an automation trigger, or as a variable in the keyboard/mouse functions (such as show menu on right click when text is highlighted)