Jump to content


Photo

Getfocus Dll


  • Please log in to reply
15 replies to this topic

#1 Daniel-Dane

Daniel-Dane

    GMC Member

  • New Member
  • 3581 posts

Posted 25 July 2007 - 04:22 PM

Info
GM Version: 7
File Type/Size: RAR/16 KB
Includes: .DLL, .GML, and .GMK.

Description
This DLL will return whether the GM window is in focus. Might become handy when using keyboard_check_direct() (for example with the tab key).

Download

Edited by Daniel-Dane, 19 July 2008 - 06:49 PM.

  • 1

#2 the_doominator

the_doominator

    Eight Star

  • New Member
  • 925 posts

Posted 25 July 2007 - 08:18 PM

Pretty cool. How are you supposed to check? The only way you could is by step event or alarm.

Anyway, I'm presuming you are using the GetFocus function, and then seeing if it is the GM window. 'Cause that is what I'm doing in my DLL.

Anyway, good job.

6/10 (Works fine, but too basic, as in "Needs more functions")


-the_doominator

Edited by the_doominator, 25 July 2007 - 08:18 PM.

  • 0

#3 Daniel-Dane

Daniel-Dane

    GMC Member

  • New Member
  • 3581 posts

Posted 25 July 2007 - 08:41 PM

There's an GetFocus?! Man!

Well, I didn't need more crap anyway for my project.
  • 0

#4 the_doominator

the_doominator

    Eight Star

  • New Member
  • 925 posts

Posted 25 July 2007 - 08:44 PM

What did you use then?
  • 0

#5 Daniel-Dane

Daniel-Dane

    GMC Member

  • New Member
  • 3581 posts

Posted 25 July 2007 - 09:04 PM

http://msdn2.microso...y/ms633505.aspx
  • 0

#6 torigara

torigara

    GMC Member

  • GMC Member
  • 6507 posts

Posted 26 July 2007 - 02:39 AM

In precise, there are three slightly different concepts: window in focus, foreground window and active window.

Focus window is a window that receives keyboard events. It isn't necessarily a top level window but a window control (e.g. an edit box, push button, list box etc.) Note that GetFocus succeeds only when the window in focus is owned by the thread you're running.

Foreground window is a top-level window that the user is currently working with. There is always one foreground window throughout the system. The focused window is usually one of child windows of the foreground window, or the foreground window itself.

Actvive window is a top-level window which is active in your application; it is equal to the foreground window if the window is owned by the thread you're running. If the current foreground window isn't owned by your thread, GetActiveWindow returns 0.

As GameMaker games has no child window inside, GetForegroundWindow will be the appropriate one in this case.
  • 0

#7 the_doominator

the_doominator

    Eight Star

  • New Member
  • 925 posts

Posted 26 July 2007 - 03:02 AM

Cool! That cleared up some questions I had.
  • 0

#8 Daniel-Dane

Daniel-Dane

    GMC Member

  • New Member
  • 3581 posts

Posted 26 July 2007 - 10:31 AM

As GameMaker games has no child window inside, GetForegroundWindow will be the appropriate one in this case.

<{POST_SNAPBACK}>

Maybe not GameMaker, but Game Maker DOES have a child window.

Edited by Daniel-Dane, 23 September 2007 - 11:05 AM.

  • 0

#9 tangibleLime

tangibleLime

    Lunatic

  • GMC Elder
  • 2520 posts
  • Version:GM:HTML5

Posted 26 July 2007 - 12:25 PM

As GameMaker games has no child window inside, GetForegroundWindow will be the appropriate one in this case.

<{POST_SNAPBACK}>

Maybe not GameMaker, but Game Maker DO has a child window.

<{POST_SNAPBACK}>

Nice grammer :ph34r:

I also used, as someone in the topic previously pointed out, the GetFocus command, and I just had it check against the GM window's handle.

If anyone wants to learn about how the source might look, here are a few functions. Please ignore my incorrect casting. HWND should be a 'long', if I remember correctly.
//C++

//-- window_get_focus();
export double window_get_focus() {
   return (int) GetFocus();
}

//-- window_get_active();
export double window_get_active() {
   return (int) GetActiveWindow();
}

//-- window_get_foreground();
export double window_get_foreground() {
   return (int) GetForegroundWindow();
}

//-- window_set_focus(hwnd);
export double window_set_focus(double hwn) {
   HWND handle=(HWND)(DWORD)hwn;
   
   HWND reth;
   reth = SetFocus(handle);

   int ret = (int)(HWND)reth;

   return (int) ret;
}

//-- window_set_active(hwnd);
export double window_set_active(double hwn) {
   double AllowSetForegroundWindow(-1);

   HWND handle=(HWND)(DWORD)hwn;

   HWND reth;
   reth = SetActiveWindow(handle);

   int ret = (int)(HWND)reth;

   return (int) ret;
}

//-- window_set_foreground(hwnd);
export double window_set_foreground(double hwn) {
   HWND handle=(HWND)(DWORD)hwn;
   
   int ret;
   ret = SetForegroundWindow(handle);

   return (int) ret;
}

Edited by Roach, 26 July 2007 - 12:26 PM.

  • 0
Posted ImagePosted Image

#10 Daniel-Dane

Daniel-Dane

    GMC Member

  • New Member
  • 3581 posts

Posted 23 September 2007 - 11:15 AM

Yeah, I guess it's not much. But it's what I needed and I like sharing. :medieval:
  • 0

#11 Alex

Alex

    3lite Member

  • New Member
  • 3098 posts

Posted 23 September 2007 - 12:12 PM

This would be a good way to prevent people from using memory scanners such as Cheat Engine. If the game loses focus, you could immediately close.
  • 0

#12 Daniel-Dane

Daniel-Dane

    GMC Member

  • New Member
  • 3581 posts

Posted 23 September 2007 - 03:52 PM

No way. I do minimize and change windows in the middle of games. :medieval:
  • 0

#13 daz

daz

    GMC Member

  • GMC Member
  • 804 posts
  • Version:GM:Studio

Posted 23 September 2007 - 03:53 PM

Woah no Alex that's a bad idea (if you're saying it like I'm understanding it..) Let's say you're like "z0mg firefox! google! fri3nd!" and minimize the game then it'll close? Psh.. now you might be thinking of something different if then disregard this post

Daniel beat me to it xD Anyways I have never been able to get user32.dll to work with game maker so dang if c/c++/c# can do it then I'm set =D although my knowledge of c is quite lacking cause I hate it and I don't even know how to import a library sooo time to google eh w0ot?

Edited by daz, 23 September 2007 - 03:56 PM.

  • 0

#14 Daniel-Dane

Daniel-Dane

    GMC Member

  • New Member
  • 3581 posts

Posted 04 October 2007 - 07:12 PM

Well, some of the libraries use a conversion that GM supports, however they use variables that GM does NOT support. I tried anyway but ended up freezing the game.
  • 0

#15 Ed Games

Ed Games

    GMC Member

  • New Member
  • 2 posts

Posted 19 July 2008 - 02:45 PM

Um, How do u download this.
when i clicked on ure link then it just came up with a page with no download button or popup
??
  • 0

#16 Daniel-Dane

Daniel-Dane

    GMC Member

  • New Member
  • 3581 posts

Posted 19 July 2008 - 06:51 PM

AwesomeSoft doesn't exist anymore, and someone then parked the site's name. Luckily the old host still had the files. Re-uploaded.
  • 0