osx service menu call to Livecode app
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
osx service menu call to Livecode app
Hello again,
Does anyone have experience with creating a service menu item in OSX to call a livecode app? Typically these can be exposed either via a context menu or have a keyboard command (system wide) assigned to them - which when called will activate the app and pass the command in.
It seems like something that others here may have figured out, so before I research this just wanted to ask...
~ Rodney
Does anyone have experience with creating a service menu item in OSX to call a livecode app? Typically these can be exposed either via a context menu or have a keyboard command (system wide) assigned to them - which when called will activate the app and pass the command in.
It seems like something that others here may have figured out, so before I research this just wanted to ask...
~ Rodney
-
- VIP Livecode Opensource Backer
- Posts: 7237
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: osx service menu call to Livecode app
I haven't used it but have you seen "macStatusMenu" in the dictionary? That seems to cover most of it.
Edit: oops, I think you mean the Services menu under the Apple menu. I don't see support for that.
Edit: oops, I think you mean the Services menu under the Apple menu. I don't see support for that.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- VIP Livecode Opensource Backer
- Posts: 9669
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: osx service menu call to Livecode app
Jacque.
"Services Menu"?
Craig
EDIT.
Oh, under the "Finder" menu.
"Services Menu"?
Craig
EDIT.
Oh, under the "Finder" menu.
-
- VIP Livecode Opensource Backer
- Posts: 7237
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: osx service menu call to Livecode app
Now that I'm at my Mac I see the Services menu is under the app menu in any application. It's also available in Finder when you right-click on an item.
I suspect the only way to access it from LC is to use LCB or submit an enhancement request.
I suspect the only way to access it from LC is to use LCB or submit an enhancement request.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: osx service menu call to Livecode app
This looks like the other option:
https://developer.apple.com/library/arc ... rvice.html
... then get it to call your app via Applescript.
https://developer.apple.com/library/arc ... rvice.html
... then get it to call your app via Applescript.
Re: osx service menu call to Livecode app
Building off the AppleScript idea, you can use Automator to create a new Quick Action that can be added to the Services menu and can also appear in the Touch Bar and Finder.
Start a new Quick Action, then in the Utilities category drag Launch Application into the workflow area on the right. A pull down will allow you to choose your compiled LiveCode app to launch. By dragging other items into the workflow, you can add documents or files for you app to work on or do post processing or other options. You then save the workflow with the name you want your users to see (perhaps the name of your app). Use the offered default folder location to save the workflow, and your new action will immediately appear in the services menu.
If you copied this Quick Action and you shipped it with your app, it could be available in an optional install folder. If the user chose to install it, all they would have to do is double click the icon. The finder then confirms that you want to install the service and automatically moves the file and icon to the hidden services folder where it needs to be - and the user will then see your app (or a shortcut to your app) in the Services folder.
Hope this helps
Kelly
Later...
just read your link and Apple has supplied better instructions than mine! No AppleScript required though.
Read before you Write! - someday I might remember that!
Start a new Quick Action, then in the Utilities category drag Launch Application into the workflow area on the right. A pull down will allow you to choose your compiled LiveCode app to launch. By dragging other items into the workflow, you can add documents or files for you app to work on or do post processing or other options. You then save the workflow with the name you want your users to see (perhaps the name of your app). Use the offered default folder location to save the workflow, and your new action will immediately appear in the services menu.
If you copied this Quick Action and you shipped it with your app, it could be available in an optional install folder. If the user chose to install it, all they would have to do is double click the icon. The finder then confirms that you want to install the service and automatically moves the file and icon to the hidden services folder where it needs to be - and the user will then see your app (or a shortcut to your app) in the Services folder.
Hope this helps
Kelly
Later...
just read your link and Apple has supplied better instructions than mine! No AppleScript required though.
Read before you Write! - someday I might remember that!
Re: osx service menu call to Livecode app
Thanks Kelly, very interesting.
What's the correct way to send an event from an Applescript script (e.g. a script I could run in Script Editor) to send to a Livecode compiled application?
Appreciate this may require having support for running in Development mode (when event is targeted at Livecode) and compiled (when targetting the built application)
For those interested, you can handle incoming events using an AppleEvent handler.
Incidentally it seems the Livecode dictionary doesn't seem to have an entry for this at the moment (just for the send to program entry).
What's the correct way to send an event from an Applescript script (e.g. a script I could run in Script Editor) to send to a Livecode compiled application?
Appreciate this may require having support for running in Development mode (when event is targeted at Livecode) and compiled (when targetting the built application)
For those interested, you can handle incoming events using an AppleEvent handler.
Incidentally it seems the Livecode dictionary doesn't seem to have an entry for this at the moment (just for the send to program entry).
Code: Select all
on appleEvent pClass, pEventID, pSender
if pClass is "aevt" then
request appleEvent data
answer "Appleevent received: class"&&pClass&&"eventid:"&&pEventID &&"sender:"&&pSender &&"Data:" && it
end if
pass appleEvent
end appleEvent
Re: osx service menu call to Livecode app
Here's how to call a Livecode handler from an Applescript e.g. from Script editor
I'd still be interested in an example of how to send an Appleevent from script editor to Livecode, to be intercepted using the Applescript handler (see example in my previous post above)
Thread: viewtopic.php?t=633
Code: Select all
tell application "LiveCode ..."
activate
do script "send \"testCallFromAS\" to stack \"mystackname\""
end tell
Thread: viewtopic.php?t=633
Last edited by rodneyt on Fri Aug 06, 2021 8:53 am, edited 1 time in total.
Re: osx service menu call to Livecode app
You can use appleevents to get the name of a file dragged to your application as described here:
https://lessons.livecode.com/m/4071/l/1 ... le-onto-it
Can anyone provide an example of how to send other types of apple events to a Livecode app?
What's the best way to pass in data to a Livecode app? The method I describe above allows you to call a Livecode handler from Applescript but it doesn't seem to allow you to pass a variable in with it. Just wondering if anyone else has experimented in this area and can advise.
https://lessons.livecode.com/m/4071/l/1 ... le-onto-it
Can anyone provide an example of how to send other types of apple events to a Livecode app?
What's the best way to pass in data to a Livecode app? The method I describe above allows you to call a Livecode handler from Applescript but it doesn't seem to allow you to pass a variable in with it. Just wondering if anyone else has experimented in this area and can advise.
Re: osx service menu call to Livecode app
On the subject of Service menu. I had a go creating a system wide shortcut to activate Livecode IDE. I did this by following the instructions (see thread above) =>> open automator, creating a new service item, and choosing action to Launch then select Livecode application. Save this, it then appears under Application menu -> Services -> Launch Livecode.
You can then assign a system wide keyboard shortcut to call and activate. To assign the keyboard shortcut you go to System Preference -> Keyboard -> Shortcuts ->Services and select the shortcut you created then assign a keyboard shortut.
Keyboard shortcuts for applescript seem to have some weird-ities:
There is a weird bug where sometimes you have to go to the services menu first before the keyboard shortcuts work, apparently this issue has been around for ages and is discussed here: https://stackoverflow.com/questions/363 ... n/46060932.
So.... I am not sure how useful this is. However for anyone else running across this thread via search I include for completeness...
You can then assign a system wide keyboard shortcut to call and activate. To assign the keyboard shortcut you go to System Preference -> Keyboard -> Shortcuts ->Services and select the shortcut you created then assign a keyboard shortut.
Keyboard shortcuts for applescript seem to have some weird-ities:
There is a weird bug where sometimes you have to go to the services menu first before the keyboard shortcuts work, apparently this issue has been around for ages and is discussed here: https://stackoverflow.com/questions/363 ... n/46060932.
So.... I am not sure how useful this is. However for anyone else running across this thread via search I include for completeness...
-
- Posts: 627
- Joined: Wed Apr 24, 2013 4:53 pm
- Contact:
Re: osx service menu call to Livecode app
Yes, I'm sure this could be done with LCB FFI.
I've actually just recently come across the docs for services menu on Apple's Dev site while looking at other things (added native darkMode to my LCB macTools), but Services is not something I personally use much in my day to day work, so I probably won't be getting to that myself any time soon.
https://developer.apple.com/documentati ... guage=objc
-
- Posts: 627
- Joined: Wed Apr 24, 2013 4:53 pm
- Contact:
Re: osx service menu call to Livecode app
Not long before Trevor DeVore created an LCB wrapper for mac Status Menu, I had worked out a bit of a hack to achieve a Status Menu of sorts, using an AppleScriptObjC applet that did bidirectional communication back and forth with my LC Stack/Standalone via AppleScript (but it had some wonky behaviors, blocking code execution waiting for user for example). I saved it somewhere. I'll try to dig out that specific code and post it here later.
Messing with that is when I discovered the bug (that's been on the "This Week In LiveCode" bug list ever since), where a standalone doesn't get an AppleScript dictionary/definition plist file included with it, which makes using LC+AppleScript in a standalone much less convenient. You can work around the problem by copying the plist from LiveCode's app bundle into the standalone or by changing the AppleScript to use Apple Events codes ( looks something like <<<exmp>>>) for certain things instead of their corresponding usual AppleScript keywords.
Messing with that is when I discovered the bug (that's been on the "This Week In LiveCode" bug list ever since), where a standalone doesn't get an AppleScript dictionary/definition plist file included with it, which makes using LC+AppleScript in a standalone much less convenient. You can work around the problem by copying the plist from LiveCode's app bundle into the standalone or by changing the AppleScript to use Apple Events codes ( looks something like <<<exmp>>>) for certain things instead of their corresponding usual AppleScript keywords.