detect window index
add checkwindow