Dual functionality for a single hotkey (S for Scale) - similar to the G hotkey for Move and Slide Move If you press "S" you activate the scale tool, but I'm trying to create a script where if you press "S" again while the tool is already active... you start to cycle between pivot point modes (median and individual specifically). It's similar to pressing the G key; press it once and you get the Move operator, press it again and it switches to Slide Move.

What command can I use to check if Scale is already running and ONLY THEN switch pivot modes?

I know it's easier to just do the cycling with a separate hotkey, but the point is to re-use the "S" key to both activate the tool and then start switching pivot modes if you keep tapping it.

My script already switches between two Pivot Modes, but I'm missing the "IF SCALE IS RUNNING" check. How can I go about doing that?

#OPERATOR WILL RUN WHEN "S" IS PRESSED

import bpy

#Using this in case I want to add more modes later
pivot_modes = ['MEDIAN_POINT', 'INDIVIDUAL_ORIGINS']
i = 0

#IF SCALE IS ALREADY ACTIVE:

#Store the original Pivot Point
pivot_point = bpy.context.tool_settings.transform_pivot_point[:]

#Change Pivot Modes
if pivot_point == pivot_modes[i]:
    bpy.context.tool_settings.transform_pivot_point = pivot_modes[i+1]   

elif pivot_point == pivot_modes[i+1]:
    bpy.context.tool_settings.transform_pivot_point = pivot_modes[i]

#ELSE:

    #Make sure we always start with Mediant Point Mode
    #bpy.context.tool_settings.transform_pivot_point = 'MEDIAN_POINT'

    #bpy.ops.transform.resize('INVOKE_DEFAULT')




Edit 1

I found out I can do this:

#If tool is already running
if bpy.ops.transform.resize('INVOKE_DEFAULT'):
    #Toggle Pivot Modes
else:
    #Turn it on
    bpy.ops.transform.resize('INVOKE_DEFAULT')


... which I feel is a step forward but doesn't work because the IF statement also activates the Scale operator, so it's always going to be True.

Plus, the script doesn't seem to run again while the Scale operator is active so there's a deeper issue I haven't solved.
I found the answer in a different post which goes into more detail on how to get it to work.

I don't know if this is allowed but I will link to the original post for a more detailed answer:

Link: How to define double shortcut like GG

Here is the code I used. The explanation on how to set up the keymap so this works is in the post I linked. Once everything is set up, I can tap the S key multiple times, first to activate the scale operator and any subsequent presses toggle between two Pivot Modes I specified.

import bpy
from bpy.props import IntProperty, FloatProperty


class ARC_CustomScale(bpy.types.Operator):
    """Allow SS with the Scale operator, similar to pressing GG to toggle functionality
       of the move tool while the operator is still active"""

    bl_idname = "arc.scale"
    bl_label = "Scale (ARC)"
    bl_options = {'REGISTER', 'UNDO'}

    count=0

    def modal(self, context, event):
        self.count +=1
        if self.count ==1:
            bpy.context.tool_settings.transform_pivot_point = 'MEDIAN_POINT'
            bpy.ops.transform.resize('INVOKE_DEFAULT')
            print("First Press")

        elif event.type == 'S':
            bpy.context.tool_settings.transform_pivot_point = 'INDIVIDUAL_ORIGINS'           
            bpy.ops.transform.resize('INVOKE_DEFAULT')
            bpy.context.tool_settings.transform_pivot_point = 'MEDIAN_POINT'
            print("Second Press")
            self.count = 0
            #return {'CANCELLED'}

        elif event.type == 'LEFTMOUSE':
            return {'FINISHED'}

        elif event.type in {'RIGHTMOUSE', 'ESC'}:
            return {'CANCELLED'}

        return {'RUNNING_MODAL'}

    def invoke(self, context, event):
        if context.object:

            context.window_manager.modal_handler_add(self)
            return {'RUNNING_MODAL'}
        else:
            self.report({'WARNING'}, "No active object, could not finish")
            return {'CANCELLED'}


def register():
    bpy.utils.register_class(ARC_CustomScale)


def unregister():
    bpy.utils.unregister_class(ModalOperator)
ARC_CustomScale

if __name__ == "__main__":
    register()