New function: auto-grab

Thanks to Alexander Nedovizin for coding first version of this function.