Jump to content


getfocus.gex -- check if game window is in focus

  • Please log in to reply
2 replies to this topic

#1 Jake Armstrong

Jake Armstrong

    GMC Member

  • GMC Member
  • 510 posts
  • Version:GM8.1

Posted 31 July 2012 - 01:26 AM

Hey I wrote an extension (using the C++ DLL I wrote) that will determine if the game maker window is in focus or not. If you minimize the window, select another window, or alt tab away (including alt tabbing away if the game is in fullscreen) then the function will return false until you go back to the game.

DOWNLOAD: http://www.host-a.ne...ng/getfocus.gex

You are free to use this (commercially if you want) without credit. However, I appreciate credit (as Jake Armstrong or EkajArmstro, whatever), and it would be cool if you posted here if you find this useful.

I've only tested this in game maker 8.1, but I don't see why it wouldn't work in other versions of game maker (let me know!). Note that this will only work in Windows.

Simply install the extension and use:

if (window_has_focus(window_handle())) {

// sound_global_volume(1);

} else {

// sound_global_volume(0);


  • 0

A star pathfinding extension (fast, variable cost tiles, multi-tile objects): http://gmc.yoyogames...howtopic=570621

Multiple mice extension http://gmc.yoyogames...howtopic=575963
extension to check if game is in focus (vs. being alt tabbed, etc.): http://gmc.yoyogames...howtopic=549073

#2 orange08


    Art Game Movement

  • GMC Member
  • 2272 posts
  • Version:GM:HTML5

Posted 07 December 2013 - 10:58 PM

I'm using Game Maker 8.0 and this worked super nice!

Would you care to be credited on my game or..?

Edited by orange08, 07 December 2013 - 11:00 PM.

  • 0

Z8vrE7W.png WRhLqHy.png
"I'm just glad Off-topic isn't being removed. Otherwise I risk actually doing something productive." -RoyTheShort

#3 Black Doomer

Black Doomer

    GMC Member

  • GMC Member
  • 105 posts
  • Version:GM8.1

Posted 07 December 2013 - 11:38 PM

Unfortunately, this extension needs MSVCR or it will not work.

I wrote a better version that smaller and doesn't needs it. I can post it here, if somebody will ask. Or you can take it from Doom 2D Multiplayer sources.

Edited by Black Doomer, 07 December 2013 - 11:39 PM.

  • 0

And sorry for my bad English.

My projects: Doom 2D Multiplayer

My extensions: Codepage Converter | XP Messages | Bit Wizard | Time Library

Other: Download Manager 2 GEX