Run function when addon start

how can I run a function when the addon or blender just starts?

put a function in your __init__.py and call it, simple as that. the init script gets run when the addon is loaded.

sorry for the late response…
the problem with that is that i get “RestrictContext’ object has no attribute scene” error.
I read about it and I understand that I cant run a function that use the “bpy.scene” at this stage.

So how can i call a function after the addon get active and when i open a new blender?
I try to use the load handler and its work for me well when i open a new file, but i can’t find a way to call my function after i active my addon

yeah that’s different- you’re trying to access things that don’t exist yet. Blender loads addons and scripts right after it finishes loading the python environment, so there is no context, etc. The only solution is to use an app handler or a timer. You can, for example, use an app handler to run something directly after a scene is loaded (the default.blend does not trigger this if i’m not mistaken). You could also set a timer for a few seconds after __init__.py is loaded to give Blender a chance to finish loading.