1{-# LANGUAGE CPP #-} 2{- | 3 Module : Graphics.Win32.Window.ForegroundWindow 4 Copyright : 2012 shelarcy 5 License : BSD-style 6 7 Maintainer : shelarcy@gmail.com 8 Stability : Provisional 9 Portability : Non-portable (Win32 API) 10 11 Get/Set Foreground Window. 12-} 13 14module Graphics.Win32.Window.ForegroundWindow 15 ( getForegroundWindow 16 , setForegroundWindow 17 , c_SetForegroundWindow 18 , allowSetForegroundWindow 19 , c_AllowSetForegroundWindow 20 ) where 21 22import Control.Monad ( void ) 23import Graphics.Win32.GDI.Types ( HWND ) 24import Graphics.Win32.Window ( getForegroundWindow ) 25import System.Win32.Process ( ProcessId ) 26 27#include "windows_cconv.h" 28 29---------------------------------------------------------------- 30-- | Setting Window to Foreground. 31-- See: <https://github.com/haskell/win32/pull/9>, 32-- <http://stackoverflow.com/questions/14297146/win32-setforegroundwindow-in-haskell>. 33---------------------------------------------------------------- 34setForegroundWindow :: HWND -> IO Bool 35setForegroundWindow = c_SetForegroundWindow 36 37foreign import WINDOWS_CCONV safe "windows.h SetForegroundWindow" 38 c_SetForegroundWindow :: HWND -> IO Bool 39 40---------------------------------------------------------------- 41-- | Allow other process to set Window to Foreground 42-- by using 'setForegroundWindow' function. 43allowSetForegroundWindow :: ProcessId -> IO () 44allowSetForegroundWindow = void . c_AllowSetForegroundWindow 45 46foreign import WINDOWS_CCONV safe "windows.h AllowSetForegroundWindow" 47 c_AllowSetForegroundWindow :: ProcessId -> IO Bool 48