Mirage Source
[Fix] Fixing input - Printable Version

+- Mirage Source (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: Source Code Development (https://mirage-engine.uk/forums/forumdisplay.php?fid=51)
+----- Forum: Mirage Source 4 (Visual Basic 6) (https://mirage-engine.uk/forums/forumdisplay.php?fid=44)
+------ Forum: Tutorials (https://mirage-engine.uk/forums/forumdisplay.php?fid=13)
+------ Thread: [Fix] Fixing input (/showthread.php?tid=2975)



[Fix] Fixing input - Nean - 28-07-2009

Wrote this up for RootSource on OGC, figured you guys could benefit from it?

Nean Wrote:I just spent the last two and a half hours working on this, so somebody better appreciate it. For spending so long, it's a very few lines of code. Anyways here goes

Add:
Code:
Public Declare Function GetForegroundWindow Lib "user32" () As Long
in ModInput

Then replace:
Code:
Call CheckInputKeys ' Check which keys were pressed

With:
Code:
If GetForegroundWindow() = frmMainGame.hwnd Then
            Call CheckInputKeys ' Check which keys were pressed
        End If

Voila, done. Now it only responds if the current window is RootSource



Re: [Fix] Fixing input - Robin - 28-07-2009

I rated this topic:

[Image: icon_topic_rating.gif] [Image: icon_topic_rating.gif] [Image: icon_topic_rating.gif] [Image: icon_topic_rating.gif] [Image: icon_topic_rating.gif]

Good job.


Re: [Fix] Fixing input - Nean - 28-07-2009

DFA Wrote:fully tested? wow if it works right
the best thing i've found was a pretty lengthy module that checks if a window has focus

Haha yeah, I spent two hours alternating writing functions/using booleans trying to determine if the window had focus, and then I stumbled across a GetActiveWindow API, but that didn't work. Another thirty minutes of research, trying to figure it out lead me to the GetForeGroundWindow API which worked flawlessly.


Re: [Fix] Fixing input - Robin - 29-07-2009

James Wrote:Fail how? it works with only a few lines of code to fix a mistake you made.

lol, Dmitry got burned.


Re: [Fix] Fixing input - Nean - 29-07-2009

Wait, so this is unsatisfactory? Elaborate.


Re: [Fix] Fixing input - Matt - 29-07-2009

Lol. DFA was kidding, he was just mad you fixed something he broke. Tongue


Re: [Fix] Fixing input - Nean - 29-07-2009

Damn, I need to stop posting drunk. I don't figure these things out.


Re: [Fix] Fixing input - Robin - 29-07-2009

Nean Wrote:Damn, I need to stop posting drunk. I don't figure these things out.

Dmitry is high on crack. I never understands anything.


Re: [Fix] Fixing input - Robin - 31-07-2009

Added it to Silverdale. Modded it a bit to allow game input on several forms, but it works like a charm.

+1 rep.