On Loss_of_focus, set a flag.
on gain_of_focus, check that flag and immediately check MouseZspeed() if its set. This results in the single erraneous value being used up by the check you threw in. then, reset the flag.
on gain_of_focus, check that flag and immediately check MouseZspeed() if its set. This results in the single erraneous value being used up by the check you threw in. then, reset the flag.