If game is minimized then

I am trying to make a system where if you minimize the screen of a game then something happens.

Ive tried doing this by detecting mouse to see if its still there but it doesnt seem to work.

Could anyone help?

oops meant this 1