private void HandleForegroundWindow(IntPtr windowHandle)
        {
            bool BLIsForeground = false;

            // Get a combined list of processes matching BL2 and TPS, and
            // iterate over them.
            var BLProcesses = new List <Process>(Process.GetProcessesByName("Borderlands2"));

            BLProcesses.AddRange(Process.GetProcessesByName("BorderlandsPreSequel"));
            foreach (Process BL2Process in BLProcesses)
            {
                // If the BL2 or TPS process's main window matches that of the
                // one which was just brought to the foreground, set our flag.
                if (BL2Process.MainWindowHandle == windowHandle)
                {
                    BLIsForeground = true;
                    break;
                }
            }

            // If BL2 or TPS were switched to, create the correct BLIO object
            // for said game if we have not already, then register our hotkeys.
            if (BLIsForeground)
            {
                // Bind the F7 key.
                F7Binding.Register(Handle);
                // If the user has not disabled hotkeys, enable them now.
                if (HotkeysEnabled)
                {
                    foreach (KeyBinding keyBinding in KeyBindings)
                    {
                        keyBinding.Register(Handle);
                    }
                }

                UdpControl.BlWindowHandle = windowHandle;
            }
            // If another process was switched to, unregister our hotkeys.
            else
            {
                UdpControl.BlWindowHandle = UdpControl.INVALID_HANDLE_VALUE;
                // Unbind the F7 key.
                F7Binding.Unregister(Handle);
                // Disable all of our other hotkeys.
                foreach (KeyBinding keyBinding in KeyBindings)
                {
                    keyBinding.Unregister(Handle);
                }
            }
        }