Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

dsaponaro

macrumors regular
Original poster
Jul 18, 2002
111
129
Hi all,

Recently in the past couple weeks or so I've noticed while working on my Mac the front most current window of whichever application I am in will loose focus at random times and act as if I clicked on another window of that app and recede to the background etc... There doesn't seem to be any method to the madness nor have I installed anything new as of late that I can think could be causing this. It happens several times a day and is very frustrating. It's specially annoying while working in any image editing apps causing all sorts of slow down to my workflow.

Can anyone tell me how to go about tracking down the cause? Ive done a bit of research online and there seems to be some terminal commands that should be able to give me an idea but I haven't had any luck here. Probably because all of the threads I saw were outdated by several years and MOST likely because I'm not very familiar working in the terminal etc....

Anyone have suggestions? Much thanks in advance.

-Dom


Machine Specs:
iMac (Retina 5K, 27-inch, 2017)
Mac OS High Sierra (10.13.5)
4.2 GHz Intel Core i7
40 GB 2400 MHz DDR4
1 TB Flash Storage (300 GB Free)
Radeon Pro 580 8192 MB
Wacom Cintiq 27QHDT Display
 
Heres a link where it looks as if someone has found a solution...

https://apple.stackexchange.com/que...ram-is-stealing-focus-on-my-mac/148094#148094

Could someone help clarify and/or walk me through it as I don't have much experience with python scripts and the terminal etc...

Much thanks!
[doublepost=1528570690][/doublepost]Copied from the link....

Here is improved version of script mentioned in the @Ace answer:

#!/usr/bin/python
# Prints current window focus.
# See: https://apple.stackexchange.com/q/123730
from AppKit import NSWorkspace
import time
workspace = NSWorkspace.sharedWorkspace()
active_app = workspace.activeApplication()['NSApplicationName']
print('Active focus: ' + active_app)
while True:
time.sleep(1)
prev_app = active_app
active_app = workspace.activeApplication()['NSApplicationName']
if prev_app != active_app:
print('Focus changed to: ' + active_app)


It will print active application which has the focus and will detect any change every second.

Related script: Identify which app or process is stealing focus on OSX at Gist

Usage:
  1. Save above script into get_active_focus.py file.
  2. Assign execution attributes by: chmod +x get_active_focus.py command.
  3. Run it as: ./get_active_focus.py.
Output:

$ ./get_active_focus.py
Active focus: Terminal
Focus changed to: Google Chrome​
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.