Automatic focusing is an important technology for image measurement and machine vision. The basic principle of automatic focusing is analyzed and the key problems of automatic focusing are researched,then a new kind of method based on multiple focusing windows and improved Roberts focused evaluation function is proposed for automatic focusing. First,the image is pre-processed by filtering and denoising. Second,image is evaluated with improved roberts focused evaluation function in many focusing windows. Third,focus of images is quickly located based on global search and binary sorting. Experiments show the method can perform fast autofocus process with sensitivity and stability.