Monday, April 22, 2019

#1 2018-11-10 09:55:14 am

Riku
Member
Registered: 2016-05-23
Posts: 43

Stop AppleScript apps being referred to by incorrect names?

Time to take the bull by the horns: How do I fix this and stop it from happening in the future?


AppleScripts using UI scripting:
When I have to give them access to use the UI, OR when I have some dialogs coming from AppleScript apps being logged to the notification center, why do some AppleScript apps have their names on those lists displaying correctly but some turn into a long randomly generated hash of capital letters and numbers? I think I've been saving them the same way and I just can't figure out where that name is stored and where that hash randomly comes from.

• Selecting such app in Finder and pressing the space bar: name displays correctly (I know sometimes you find residue of old names this way if you've created a new script based on an old one and renamed it later)
• Inside the package at Contents, I checked on Info.plist and don't see references of the weird name (I suppose that info is the same you would see in the Bundle info view if in Script Editor)


The hash names are also too long to be fully displayed in the UI scripting access window, so whenever I edit or upgrade my script app and have to re-enable UI access for it, I basically can't tell which one of the hash named apps it is so I have to untick and tick all of those with a weird name so it'll be one of them.

I noticed another thing:
If I remove a script from a given folder completely, copy-paste its contents into a new script and save that as a completely new fresh app, the moment I save it, the name in the script window's top center changes to display a very old name of a version way, way back, in a form that contains a dash instead of a space (like I would've named it); The dash making the form look like the type of name I see in the Bundle Info tab, Identifier box. But where on earth does it pull those old names from, even for a freshly saved app?

Offline

 

#2 2018-11-10 08:09:13 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5626

Re: Stop AppleScript apps being referred to by incorrect names?

It's possible you have a corrupt Launch Services database. A Goggle search will show you haw to rebuild it. It's also possible you have an issue with your AppleScript preferences, in which case running this script should help:

Applescript:

use framework "Foundation"

set scriptDefaults to (current application's NSUserDefaults's alloc()'s initWithSuiteName:"com.apple.applescript")
scriptDefaults's removeObjectForKey:"ApplicationMap"


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#3 2018-11-19 08:24:12 am

Riku
Member
Registered: 2016-05-23
Posts: 43

Re: Stop AppleScript apps being referred to by incorrect names?

Okay, that script didn't seem to do anything but I backed up my disks and downloaded Onyx which had an action to rebuild Launch Services.

Now the list at Security/Privacy/Accessibility window just seems to load for ages and every time I try to scroll or do anything on that interface, I get the spinning beach ball for a while and System Preferences doesn't respond. I have to wait for it to load and then a nudge on the scroll can send it loading for a while again. Also get a beach ball if I try to delete or add an item to the list, for example. It doesn't freeze, it just turned really sluggish.
I was about to report that all the weirdly named ones were gone on the list, but then scrolling this to and fro, I spotted an anomaly that could also be spotted because I give my AppleScript apps distinguishable icons; I spotted this one app that sometimes appears with its correct name and sometimes with its hash name! This happens only some seconds apart, I scroll that app to view on the list, then scroll out of view, and when I scroll back to display it, it may have a different name!
EDIT: Restarted the computer, the sluggishness in Accessibility window is now gone, and now I see that one specific app permanently showing up with its hash name. Removing and adding it again doesn't change this. The name in its bundle contents is correct.

It didn't seem to fix the traces of old names on scripts that had been renamed, but when pressing space bar on a selected .app file to preview, you'd still see the old name format. But unlike before the fix, now if I open such script in Script Editor and display the bundle contents side bar, the old name is visible there, and manually correcting it from there and saving the file also fixes the name for the Finder preview. So you have to do it manually but that issue has been repaired.

In the Notification Center window that lists apps to be shown in there, I'm still seeing hash names. But then actually I'm not sure if those are deprecated or old apps that don't even exist anymore, or apps that I still use but they just show up like that. I wasn't always using custom icons on my scripts so I can't trace what those scripts are, the hash names also get clipped because they're so long.

Last edited by Riku (2018-11-19 08:51:26 am)

Offline

 

#4 2018-11-20 02:13:44 pm

Riku
Member
Registered: 2016-05-23
Posts: 43

Re: Stop AppleScript apps being referred to by incorrect names?

Ehh. Seems that the issue is back, Accessibility window shows some of the scripts with a weird name and some with their real one. I have been updating this certain bunch of scripts a lot recently, and when I've gone through them, I select and drag the newly processed ones to the Accessibility list to re-enable them (realized only now that it was possible! So much easier than having to find it from the list, uncheck and re-check!)
Now that I know exactly what I've been working on, I can at least rule out that the name weirdness does not happen because of an updated/modified script. The oddity can happen or not happen completely regardless of when the script has been updated and re-enabled. I just keep wondering what that hash name is a reference to, where is that data located!

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)