question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fails to get active window on macOS

See original GitHub issue

Mac 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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:22 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
5tefancommented, Jan 24, 2019

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.

/.../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)
2019-01-23 22:16:00 [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

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?

2reactions
johan-bjareholtcommented, Dec 2, 2018

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found