I will try to avoid posting any actual code but I will explain what you need to do.
You don't want to use any loops or anything that will halt the program.
You will need to use a variable as a flag to tell the program when to freeze the mouse and when to release it.
Use a condition to check that the flag is true and put Valentine's code in there.
Then you need a small routine to turn the flag on/off.
Here is a useful function for managing input:
rem Silverman's SilKey Function
rem return values: 0=idle, 1=pressed, 2=released, 3=held.
function silkey(trigger,oldstate)
newstate = 3&&(oldstate<<1||trigger)
endfunction newstate
You use it like this:
[variable a] = silkey([key to monitor], [variable a]).
For example:
spacebar = silkey(spacekey(), spacebar).
Place this code in a loop and the variable 'spacebar' will have the value 0 by default, then when the spacekey() is pressed 'spacebar' will have the value 1 for one loop after which it will change value to 3. When the spacekey() is released 'spacebar' will have the value 2 for one loop before returning to 0.
Formerly OBese87.