Thanks to @user3439894's response to this post: Create a new space using a keyboard shortcut in macOS Big Sur, and because my System language is French, I use Keyboard Maestro and the following Applescript to create 4 new Spaces when launching an app ↓
do shell script "open -b 'com.apple.exposelauncher'"
delay 0.5
tell application id "com.apple.systemevents"
tell (every application process ¬
whose bundle identifier = "com.apple.dock") to ¬
repeat 4 times
click (button 1 of group 2 of group 1 of group 1)
end repeat
delay 0.5
key code 53 -- esc key
end tell
It works perfectly, and now I'd like to do the opposite: Remove these Spaces when I leave the app.
Unfortunately, I'm too new to this universe to understand what went wrong with the codes I tested here and there… Especially since I think I'm only finding answers that are outdated or don't fit my System language. So I hope I've shared enough info that you can help me, thanks in advance :)