Compare the result of the "GetForegroundWindow" API call to the window handle of your process (i.e maplestory)
Example use (obviously not the most efficient solution)
API:
[highlight=vb.net]
Private Declare Function GetForegroundWindow Lib "user32.dll" () As IntPtr
[/highlight]
Usage:
[highlight=vb.net]
Private Function isForeground(ByVal proc As Process) As Boolean
Return GetForegroundWindow() = proc.MainWindowHandle
End Function
[/highlight]
[highlight=vb.net]
MessageBox.Show(isForeground(Process.GetProcessesB yName("maplestory")(0)).ToString())
[/highlight]