Selecting a specific section in the active track with python

Hello, I’m trying to write a script to edit a project with multiple tracks. This is my current snippet to select a section of audio:

def specific_selection():
    
    # Set the start and end times for the selection
    start_time = 25.0
    end_time = 45.0  

    # Build and send the Select command
    select_command = f"Select: Start={start_time} End={end_time}"
    
    
    client.write(select_command, timer=True)

This selects seconds 25 to 45 (as intended) in the first track in the project, (not intended) even when a different one is active and selected.
What i ultimately want to accomplish is a loop, which selects the defined part, edits it, jumps to the next track, selects the same section, edits it in a different way, and so on…
This would be the full loop:

def testloop():
    frame_count = 20
    for f in range(frame_count):
        delay_start = 0.01
        delay_end = 3.01
        delay_incr = (delay_end - delay_start) / frame_count
        delay_value = delay_start + delay_incr * f  # Calculate the delay value
        
        client.write(f"Echo: delay={delay_value} ", timer=True)
        
        # Select next track
        client.write("NextTrack:", timer=True)
       
        client.write("specific_selection:", timer=True)
        
def specific_selection():
    # Set the start and end times for the selection
    start_time = 25.0
    end_time = 45.0  

    # Build and send the Select command
    select_command = f"Select: Start={start_time} End={end_time}"
    
    client.write(select_command, timer=True)

I’ve tried using macros, passing the track number as a parameter in specific_selection, switching track in a seperate command, nothing has worked so far. Is there a way to select part of the audio in the track that is in focus without switching to a different one?
Thank you in advance.

Perhaps you will find the clue you need here: MACRO to go to specific track, perform operations, go to next track, etc

The problem is that for the “Select:” command, if the “Track” and “TrackCount” arguments are not specified, it defaults to the first track (only) being selected.

To retain the original track selection, use the “SelectTime:” command instead.