FastScripts 3.0 Sneak Peek

@redsweater

Update: This was solved after a restart, but seems to be happening fairly often…

I’m using Shane’s RegexAndStuffLib library available here (Freeware | Late Night Software). It’s installed in my user library, and I’m running macOS 10.15.7 with FastScripts 30.b31.

My script works from Script Debugger and Script Editor, but fails when run from FastScripts with the following error:

Error Number: -1708

NSRegularExpression doesn’t understand the “regularExpressionWithPattern_options_error_” message.

Perhaps this isn’t a new thing, because I opened FastScripts 2.8.3 and get the same error. However, this did not appear to be a happening a few months ago, perhaps in an earlier version of FastScripts v2.

Here’s a simple script for testing:

use AppleScript version “2.4”
use framework “Foundation”
use framework “Quartz”
use scripting additions
use script “RegexAndStuffLib” version “1.0.7”

set someText to “This is a simple test”
set thisResult to regex search someText search pattern “(.)simple.” capture groups 1
display dialog thisResult

Thanks, Ray. I’m looking into this now. I haven’t been able to reproduce the bug but based on the symptoms you describe it makes me wonder if the scirpt runner is somehow getting “tainted” by another script that you’ve run previously. If you can narrow it down at all that would be helpful. I am assuming when you reproduced it in 2.8.3 it didn’t happen first thing after launching the app?

Update: I Googled for the error you’re seeing and, what do you know? The very issue was covered extensively on these forums: Strange ASObjC Error When Running RegexAndStuff Lib from FastScripts It sounds like your experience is very much like what is discussed in that post. Hopefully the lengthy examination of the issue will help you, too.

I’ll keep an eye on it. But it did happen in 2.8.3 when I first launched the app. In other words, quit the beta, launched 2.8.3, ran script, and error occurred immediately.

And just to be clear, the problem didn’t go away until a full system restart. Quitting and relaunching FastScripts itself did not help.

Ah, I see! Well, it sounds so close to the description of that other thread that I think the advice from @ShaneStanley, @ccstone, etc. will certainly be valuable. I’m afraid I don’t really understand the underlying issue myself too well.

Just FYI to all regarding the previous thread: I’m not using a SymLink. The library is in the usual User>Scripting Libraries folder.

The script is saved as .scpt, not a bundle. I do use Dropbox, but the script is in the user library Scripts folder, so not on Dropbox.

So other than the error being the same, I’m not seeing anything that applies from the previous thread.

@rayrobertson one thing to try: you can rename one version of FastScripts, say FastScripts 3, and then have both versions running. It would be interesting to know if the problem, if it appears again, happens in both versions.

(And yes, your issue does sound different from that in the other thread.)

@ShaneStanley It’s probably worth noting that the actual script will always be running in a process named “RSScriptRunner”, so I don’t know if the name of the host app is likely to matter so much. But I wonder if having multiple apps on the system, sometimes running in tandem, and all invoking scripts, could cause the symptom Ray is reporting?

The renaming is really so both versions can live in /Applications.

I don’t think so. I mean, I suspect a lot of FastScripts users still also have Apple’s Scripts menu still running too (for no particular reason).

@rayrobertson could also try removing the unneeded use framework statements from his test script, although I can’t see why it would matter. But it might help narrow things down further.

I keep thinking that the one thing we know about script libraries is that AS caches them on a per-instance basis. I presume you’re using the runner’s default instance, but I wonder whether it would be worth trying with a new instance.

Thanks for the tip. In spite of how much weird stuff I know about AppleScript and making a tool like FastScripts over the years, I’m still a little foggy about some of these finer points. @rayrobertson if you want to drop me a line at support@redsweater.com, I can experiement with making versions of FastScripts that behave differently and see if we can get to the bottom of this!

@rayrobertson, one more question: what version of RegexAndStuffLib are you running?

@ShaneStanley It’s 1.0.7. I’ll see if I can get this to occur again and check out the other suggestions.

I just released FastScripts 3.0b32 which includes a few substantial changes:

  • Running scripts now appear in the FastScripts menu and can be force-stopped
  • Scripts are no longer run on the same script runner process. A fresh process is used for each invocation
  • Fix the ordering of items in the recent scripts submenu so that most recent scripts are at the top

“Check for Update” from a previous beta, or download directly here: https://redsweater.com/fastscripts/FastScripts3.0b32.zip

I’ be curious @rayrobertson if this change to run scripts in a new process every time affects the behavior you’re seeing with RegexAndStuffLib at all.

Thanks, Daniel.

I have not been able to reproduce the error condition yet. I’ll keep an eye on it. FastScripts b32 does seem to be running scripts much faster. I repeated the call to the regex library 10,000 times and it is taking 51 seconds total each time. That’s comparable to a “fresh” launch of SD8 beta. However, SD seems to run in to a low memory state at times, and the same script took 250 seconds (fans kicking on, SD appearing to lock, but not quite).

That’s all very unscientific, though, as with earlier testing both SD and FS appeared to wildly vary from run to run in how long it would take to complete—not sure if that issue is isolate to library calls, or RegEx libraries call only, or vanilla scripts as well. For now, though FS, seems consistent.

Feedback: I’d rather not have “Stop script” in a submenu. Any chance you could just make the menu item “Stop ScriptNameHere” so we can choose it quickly. It would be even better if that menu item were at the very top of the FS menu. And, best of all, if we could have a keyboard shortcut to stop the “last invoked script” or something like that.

And now, getting really greedy, could you make the FastScript menu icon flash or something while a script process is running?

Thanks.

Thanks for the additional feedback and speed sanity check. The “Stop Script” UI is very preliminary. I expect to amend those menu items to show progress information, and probably support a UI to cancel the script in a custom view. Not sure yet, but just wanted to get something functional in ASAP.

I don’t know if I anticipate that many people wanting to have a keyboard shortcut to kill the last script they ran, but your suggestion makes me think it would be a great idea to support accessing and canceling running scripts via FastScript’s own scripting dictionary. With this, you could easily add a script to provide just that functionality.

I do have some thoughts about showing activity in the icon somehow while scripts are running. I’ll probably get to that before the final release.

If you’re looking for work :wink:, I think it would be useful for FastScripts to be able to call a script’s open handler. So if it detected that a script has an open handler, it would send an event to the Finder to get the current selection, and then pass that in an open event to the script.

I’d envisage one of two things:

  • Scripts with an open handler would appear with some signifying icon in the menu; or
  • Some key combination would switch between showing/calling scripts with open handlers versus run handlers.

I know it’s easy enough to have scripts get the selection from the Finder themselves, but I think the real value here would be making it obvious in the UI what’s required for a particular script.

I finally saw the RegEx error again, but can only report that it is intermittent. Removing the use frameworks statements did not seem to help. This time, it only occurred in FastScripts 3 beta, not FastScripts 2, but I can’t report that as a definite case due to the intermittent nature.

The smaller tests versions of the script using regex all worked this time. My larger real-world script sometimes gave the RegEx error for two consecutive runs, but then on the third run, when I had changed nothing, it worked. That’s literally running the script back-to-back-to-back from FastScripts 3.

So intermittent is definitely the word, and I don’t see much hope of replicating this reliably to help anyone find a workaround.

How large a script would that be?

It’s less than 400 lines.

@redsweater, let me describe a interesting workflow.

The multitouch trackpad have 4 zoons,
ex. upper left and right and lower left and right.

I have test with right hand 1 finger to 3 finger (1-3 touch events).

Key = q

Shortcuts possibility:

1 touch upper left + q
2 touch upper left + q
3 touch upper left + q

1 touch upper right + q
2 touch upper right + q
3 touch upper right + q

1 touch lower left + q
2 touch lower left + q
3 touch lower left + q

1 touch lower right + q
2 touch lower right + q
3 touch lower right + q

2 touch upper right + 1 touch lower right + q
2 touch upper left + 1 touch lower left + q
3 touch upper right + 1 touch lower right + q
3 touch upper left + 1 touch lower left + q

1 touch upper right + 1 touch lower left + q
1 touch upper right + 1 touch lower right + q
1 touch upper left + 1 touch lower left + q
1 touch upper left + 1 touch lower right + q

In this example we have made 20 different keyboard shortcuts from the same key q
The trackpad becomes the modifiers key for the key q. (keyboard key q)
Today we use combinations of modifiers keys to extend the key q with shortcuts.
And its not always the best practice to execute. In this example we only use key q
but most keyboards have 100 keys. In other words 20 multiply with 100 is 2000
different shortcuts combinations. :slight_smile:

Happy Valentine