Fails to get active window on macOS
See original GitHub issueMac OSX 10.12.6 Sierra, running all modules + aw-watcher-spotify + aw-watcher-web
Python 3.6.3 :: Anaconda, Inc.
I added the last heartbeat for debugging purposes
Inserted:{'id': 1148, 'timestamp': datetime.datetime(2018, 9, 11, 6, 15, 45, 412000, tzinfo=datetime.timezone.utc), 'duration': datetime.timedelta(0), 'data': {'url': 'https://chrome.google.com/webstore/detail/chrome-better-history/aadbaagbanfijdnflkhepgjmhlpppbad', 'title': 'Chrome Better History - Chrome Web Store', 'audible': False, 'incognito': False}} (aw_datastore.datastore.Bucket:120)
/Documents/activitywatch/aw_watcher_window/printAppTitle.scpt: execution error: System Events got an error: Can’t get application process 1 whose frontmost = true. Invalid index. (-1719)
2018-09-11 14:26:19 [ERROR]: Exception thrown while trying to get active window: list index out of range (aw_watcher_window.main:68)
Traceback (most recent call last):
File "aw_watcher_window/main.py", line 65, in heartbeat_loop
File "aw_watcher_window/lib.py", line 46, in get_current_window
File "aw_watcher_window/lib.py", line 23, in get_current_window_macos
File "aw_watcher_window/macos.py", line 17, in getTitle
IndexError: list index out of range
/Users/virenmohindra/Documents/activitywatch/aw_watcher_window/printAppTitle.scpt: execution error: System Events got an error: Can’t get application process 1 whose frontmost = true. Invalid index. (-1719)
2018-09-11 15:10:08 [ERROR]: Exception thrown while trying to get active window: list index out of range (aw_watcher_window.main:68)
and then the same error keeps on getting repeated –
../Documents/activitywatch/aw_watcher_window/printAppTitle.scpt: execution error: sh: -c: lish: -c: line 1: syntax error: unexpected end of file (2)
2018-09-11 22:49:23 [ERROR]: Exception thrown while trying to get active window: list index out of range (aw_watcher_window.main:68)
Please let me know if you need the log files
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:22 (8 by maintainers)
Top Results From Across the Web
Active window deactivates - Apple Support Communities
After installing Mavericks, my active window won't remain active. Whether typing in an active window or not, within 10 seconds the active ...
Read more >Active window loses focus | MacRumors Forums
After I installed Monterey on my M1 macbook air, the active window starts to lose focus randomly -- the active window becomes slightly...
Read more >Getting Active Window via Applescript throws error, "Can't get ...
I get this error quite a lot from other apps, and my guess is that 1. the window sometimes is not yet ready...
Read more >Exception thrown while trying to get active window: error ...
I'm new here and trying to get AW working on my Mac (OS 10.14.6). The AW server is up and running, and I've...
Read more >macOS windows requiring an explicit click to make active ...
(There also used be a hidden focus-follows-mouse option for ... On macOS, the active window finds its menu bar on top of the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hello all. I experienced this as well, it’s not fatal, but it came up when running in the terminal. The context was that Firefox crashed while I was away from the computer and for a while, there might not have actually been an active window? The status messages went back to normal after focusing on other windows. Unfortunately, I have not been able to reproduce the issue despite trying to get into situations with no active window.
It seems like https://github.com/ActivityWatch/aw-watcher-window/blob/cea4bf048ed9e4af66445bff5015e38c510ec892/aw_watcher_window/macos.py assumes that there will always be an active window.
In the AW gui, the watcher_window shows “unknown” for this time period. That seems reasonable as-is, so perhaps the “solution” here is silence the error?
@Patrick3131 Yes that’s why it’s failing. To test the command either move back activitywatch to the Downloads folder or enter the new path to the printAppTitle.scpt in the command.