Tweaked method used to grab window for auto profile in X.