Code:
var wndf=0;
function pause_game_at_alt_tab_startup()
{
	while (1)
	{
		if (window_focus == 0){
			if (!wndf){
				wndf=1;
				reset(camera,VISIBLE);
				fps_max=4;
				freeze_mode = 1;
			}
		}else{
			if (wndf){
				freeze_mode = 0;
				fps_max=40;
				set(camera,VISIBLE);
				wndf=0;
			}
		}
		wait(1);
	}
}

I tested it, it works!