For some reason the window_command_run function won't work if inside a mouse_check if statement.
for example, this doesn't work even in the example project:
if(mouse_check_button_pressed(mb_left)) window_command_run(window_command_maximize);
Check/disable/dispatch window commands in GameMaker · By