Troubles with "application process" in debugging mode


if I run this little script in debugging mode more than once my computer freeze.
If the debugging mode then … everything is ok.

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

tell application "System Events"
	set frontApp to first application process whose frontmost is true
	set frontAppName to name of frontApp
	set windowTitle to "no window"
end tell

I wonder if it occurs only with my mac or if it is a general problem.

No problem here. Runs multiple times with debugging on and off. Steps through just fine too

–> Script Debugger 7.0.9 (7A81)
–> Mac OS 10.11.6 (15G22010)

Your script runs fine here.

Since on both by MacBook and iMac I get the same problem.
Initially for 3-4 times the script runs well. After that it stops working.

Look this movie, at the 00:35 sec you will see what I am referring to. (3.4 MB)

it looks like you might be triggering a loop: the frontmost process is Script Debugger, and when it tries to build the description of itself and its UI elements to show, the act of trying to show them changes the collection. Try switching from Best to Source view and see what happens.

The previous one was using my MacBook (at home).
This one is on iMac (at work). (2.3 MB)

You’re triggering the same loop: entire contents is triggering more items to be added to entire contents, by definition, as long as Script Debugger is the frontmost app.

Are you trying to view something in particular here?

I just wanted to grab the name of the frontmost application.
I might do it in a single step, which should prevent this “looping”.

Something like:

tell application "System Events"
	set frontAppName to name of first application process whose frontmost is true
end tell

Thanks for guiding me to the error.


get the name of the application named (path to frontmost application)