Love to try what you are talking about but like to see a script example from your solution or Stefan’s
Can you post it here or link to a page with this info.
I never try that but it is not really what I want. Will be great if it is possible and can be used then but we are not used at add-ins that have more then one file needed. I see if I can get it working to call a script file and get the answer back in the VBA from this script so my code can use the answer.
I think Stefan’s is a separate app. My script is this:
use framework “AppKit” – for NSEvent
on checkModifier:keyName
if keyName = "option" then
set theMask to current application's NSAlternateKeyMask as integer
else if keyName = "control" then
set theMask to current application's NSControlKeyMask as integer
else if keyName = "command" then
set theMask to current application's NSCommandKeyMask as integer
else if keyName = "shift" then
set theMask to current application's NSShiftKeyMask as integer
else
return false
end if
set theFlag to current application's NSEvent's modifierFlags() as integer
if ((theFlag div theMask) mod 2) = 0 then
return false
else
return true
end if
end checkModifier:
But you’d have to save the main script as a .scptd, and then save this in a subfolder. So it is a bit complicated to set up.
On reflection, the idea I suggested isn’t going to work. Saving as a temporary .scpt and inserting the library file sounds fine, but there’s a not-so-subtle problem: you can’t compile a script that uses a library without the library existing in one of the library paths at compile time.
You could try saving the library to the user’s Script Libraries folder, but that’s probably in breach of at least the spirit of your self-imposed restrictions.
It seems that the command line file may be embedded in the script’s package. Am I wrong ?
If this scheme is wrong there is always the ability to embed ASObjC Runner.app.
I already ran a script using this scheme : Lion DiskMaker.
I think you can cut out the do shell script by running the python script. You might need to upgrade your python setup with a download. I can’t remember what it was.
Edited: just remembered that you can run a unix python script.
Edited: also, you can check for all the modifier keys in one python script. So, you don’t need to check for each on individually.
Edited: I didn’t get why you couldn’t use Shane’s Script Library script. That should be quick.
Edited: maybe you can place an alias to the library script in the user’s Script Library. I don’t know if it would work. Still checking on these ideas.
Edited: too many ideas and not enough time. Just thought of another idea. A pepper scented car cover to keep the cats off the truck. Hope someone can help you.
Hope Shane will send me a tester so I can test the script myself, I am to stupid to use/test his script because I am a VBA guy. Love to learn from you all but sometimes my head is spinning, I am sure you have that also with some VBA code.
The do shell script is actually not the problem, it’s initializing the PyObjC bridge that is causing the delay. So calling directly Python or not doesn’t make much difference.
For the command the entire AppKit module is loaded which needs some time to setup (Python has an init script for a module inside a package) including a file containing 10K lines. The file contains constants, enums, constant strings and additional methods to existing cocoa classes, including the enum NSControlKeyMask = 262144.
Initially Ron was clearly looking for a solution that he can simply copy and paste into VBA’s MacScript function without any external resources needed. The MacScript function in VBA also accepts script files as it’s argument which I think Ron is trying to use now.
My personal objection would be that globally (according to statistics in July 2014) still only 62% of all macs are Mavericks. The second largest group is still Snow Leopard and not even Lion or Mountain Lion. I can see for myself that Snow Leopard is much used because some world leading multi billion dollar companies as my clients (with tens of thousands of work stations world wide), are for 90% still working on Snow Leopard. I had to downgraded some of my own machines back to Mountain Lion because Mavericks is one of the worse releases when it comes to stability. I think therefore a Mavericks only solution is narrowing down your audience, something you don’t want on a tutor site.
FWIW, ASObjC also has to load the .bridgesupport file. That does take time – but not much, and only once per process.
I agree with your conclusion, if not your polemic ;).
But if there is a problem with the time it takes for the Python one to load, and if it is considerably quicker using a Script Library (and I have no idea if that’s the case), I’m not sure that the idea of hosting two versions, one marked Mavericks-only, would be such an outrageous idea. Penalising users in the name of a common denominator seems a bit short-sighted to me.
But what would I know. Mavericks here is every bit as stable as Mountain Lion ever was, and a lot more sensible than Lion.
Totally agree. When someone has a newer system, the user should make use of the benefits.
I do believe that. It’s the backward compatibility that is my issue in Mavericks and gets me frustrated. Of course I would be lying if I said that I would have no crashes at all in ML, when it happens once or twice a day I can live with that.
Thanks all for this very useful thread
I add an example that use a script bundle file to get the same speed as that the API in Windows thanks to Shane.