>> I don't know why, but sometimes `window-at' returns 'nil'. > > `window-at' is pretty useless anyway. Try the below instead. > > (defun window-at-pos (x y &optional frame) Thanks. Now after tweaking I finally found what changes would make the workable version: