Thanks for sharing this solution. What i could understood that this tool captures Matlab windows, where else i want to capture current screen, which may include any running program. Please correct me if i have misunderstood this.
I just fixed this issue when using a Mac. You have to go to System Preferences -> Security & Prvacy -> Privacy and allow Matlab to record the contents of your screen.