I use ffmpeg to record a window using this code:
ffmpeg.exe -f dshow -y -i video=\"screen-capture-recorder\":audio=\"virtual-audio-capturer\":audio=\"Microphon
ffmpeg -rtbufsize 1500M -f dshow -i audio="virtual-audio-capturer" -f gdigrab -framerate 30 -draw_mouse 1 -i title=RecordWindow -pix_fmt yuv420p -profile:v baseline -y Huangbaohua.mp4
the RecordWindow is the title of a specified window.