invoking a macro with a key command

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
adventuresofgreg
Posts: 301
Joined: Tue Oct 28, 2008 1:23 am
Contact:

invoking a macro with a key command

Post by adventuresofgreg » Thu Feb 16, 2017 3:41 pm

Hi: I'm trying to send a keyboard key to my system:

ie: "type "m" with commandkey

to fire a "Keyboard Maestro" macro, and can't seem to get that to work.

If I type "m" with commandkey from anywhere, the macro is fired off, but when I do that from a LiveCode script, Livecode seems to trap the message internally (ie: "command "m" is typed into whatever field is currently selected)

??

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5079
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: invoking a macro with a key command

Post by dunbarx » Thu Feb 16, 2017 4:55 pm

Might Applescript help here? You can "do" a handler as "applescript", if Keyboard Maestro is compliant.

Craig

adventuresofgreg
Posts: 301
Joined: Tue Oct 28, 2008 1:23 am
Contact:

Re: invoking a macro with a key command

Post by adventuresofgreg » Thu Feb 16, 2017 5:08 pm

Hi Craig:

I tried this and it did not work:

a field called "ascript" with contents:
tell application "System Events" to keystroke "m" with command down

button script:
do field "Ascript"

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5079
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: invoking a macro with a key command

Post by dunbarx » Thu Feb 16, 2017 7:24 pm

I am no AppleScripter. But I bet that is the best, if not only way.

Anyone else?

Craig

adventuresofgreg
Posts: 301
Joined: Tue Oct 28, 2008 1:23 am
Contact:

Re: invoking a macro with a key command

Post by adventuresofgreg » Thu Feb 16, 2017 7:51 pm

go it!

You have to ADD "as Applescript" after your script.

do tScript as Applescript

Post Reply

Return to “Talking LiveCode”