Try the following script. When you execute it in the [`Text Editor`][1], it will set the [`3D Cursor`][2] at the center of the position of your current view in the 3D Viewport. Notice that after I execute the script, I slightly zoom out so you can see the position of the 3D Cursor where previously the view of 3D Viewport was located at.

[![enter image description here][3]][3]

    import bpy
    
    area  = next(area for area in bpy.context.window.screen.areas if area.type == 'VIEW_3D')
    
    with bpy.context.temp_override(
        window=bpy.context.window,
        area=area,
        region=next(region for region in area.regions if region.type == 'WINDOW'),
        screen=bpy.context.window.screen
    ):
        view = bpy.context.space_data
    
    current_location = view.region_3d.view_matrix.inverted().translation
    
    print("Location of Current View:", current_location)
    bpy.context.scene.cursor.location = current_location


  [1]: https://docs.blender.org/manual/en/latest/editors/text_editor.html
  [2]: https://docs.blender.org/manual/en/latest/editors/3dview/3d_cursor.html
  [3]: https://i.sstatic.net/jAnDS.gif