Why not do it like this?

#!/usr/bin/env ruby
#-- coding:cp936 --

require ctypes

dll = ctypes.WinDLL(‘user32.dll’)

dll.GetForegroundWindow()
dll.LockWorkStation()