Are you sure MATLAB can get mouse coordinates only in the graphical interface? It’s actually quite simple to get your mouse position anywhere on the screen, regardless of the graphical interface.
Use the following:
get(0, 'PointerLocation')
, . , . , GUI.
, x , - y . , . , (1,1), .
, , , while , CPU, :
while condition
loc = get(0, 'PointerLocation');
%// Do something
%...
%...
pause(0.01); %// Pause for 0.01 ms
end