Thursday, October 6, 2022

#1 2022-06-12 08:01:46 pm

farmingmoney
Member
Registered: 2020-01-13
Posts: 22

If the keynote is not running, can the shortcut be bypassed?

Hello~

I am currently working on a menu bar app written in Swift.

When the user presses a shortcut only when the front app is a keynote, I want the Apple Script built into the menu bar app to work to influence the keynote.

If the keynote is running when the user presses the shortcut key, the Apple script inside the menu bar app is executed.

If the keynote is not running, can the shortcut be bypassed? At this point, does this shortcut just disappear? Or will it influence the other apps that depend on this hotkey?

I would like to know how.

Thank you~


Filed under: shortcut, menubar app

Offline

 

#2 2022-06-13 05:13:01 am

KniazidisR
Member
From:: Greece
Registered: 2019-03-03
Posts: 2535

Re: If the keynote is not running, can the shortcut be bypassed?

As I understand, you should write keyboard controller, which checks for keys pressed of shortcut. One by one in the method pressBegan:With:. Handling Key Presses on Phisical Keyboard. After checking all keys of shortcut is pressed, this controller should check running property of Keynote.app, then do nothing when it is false, or do some actions if it is true.

The question is for AppleScriptObjC and xCode forum or, better, for some Swift forum.

Here is one other tutorial very close to your question:
How to detect keyboard input using pressesBegan() and pressesEnded()

Last edited by KniazidisR (2022-06-13 06:00:02 am)


Model: MacBook Pro
OS X: Catalina 10.15.7
Web Browser: Safari 14.1
Ram: 4 GB

Offline

 

#3 2022-06-13 04:56:59 pm

farmingmoney
Member
Registered: 2020-01-13
Posts: 22

Re: If the keynote is not running, can the shortcut be bypassed?

Oh, there is a way. I'll try it. Thanks KniazidisR. smile

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)