Also it would be nice to have some thing like a Modifiers() Function and tokens like %LeftShiftKey%, %RightShiftKey%, %LeftCommandKey%, %RightCommandKey%, %LeftOptionKey% and %RightOptionKey% as an enhancement to the Versatility of the possibilities using Variables, Functions and Calculations.
Yes I know this could be done using a built Submacro or Subroutine if Version 10+ is in use that contains an AppleScriptObjC-Code like the one that is included in this Macro Library Post from me which doesn’t distinguish between left and right ones at the moment (but is also possible) - or if the code I am mentioning is put into a Script Condition inside the Macro - but it would have the the ability to let the macros have less more weight and would bring way more flexibility to Keyboard Maestro as well.
I'm no expert, but just to play devil's advocate...
The way I was doing that was by detecting whether a certain USB device key was pressed in order to determine which modifier is being held. Different keyboard hardware may return different USB device key identifiers, so I'm not sure if KM will be able to reliably determine which modifier is held.
Hello Neil (@noisneil) thanks for your reply here … I am am no expert at all, too - but let’s see what our Developer Peter is going to do to implement - normally it should be possible because of the base of Apple’s Objective-C API’s that my code uses - and of course of the fact that it is even possible to rewrite my code so that it can even detect whether a modifier from the left most is held down or one from the right most ones on a keyboard.
I am currently working on this - but it is hard to find the resources for that - so much bookmarks to search for and only 10% of them are tagged - what I have to fix at the same time my search goes … shame on my self….
Unfortunately there's no such thing as "left" and "right" modifiers in the public APIs -- either a modifier is in effect or it isn't.
You might be able to re-write your code to do so -- I'd love to see it if you do manage such a thing -- by that might be short-lived since eg NSCommandKeyMask is deprecated. Maybe have look at the various NSEventModifierFlags instead?
Again -- not an expert. And I would be overjoyed if @peternlewis proved me wrong!
The naming convention is more strictly since the introduction of swift to help for better integration if I remember it correctly - but it is still possible to use the old deprecated naming convention checking modifiers though - you just need to remember that this naming convention requires that this part of your code has to run under AppleScript‘s Version 2.3 at least and every thing is fine.
If you tend to use the newer naming convention for these Enums you’ll have to use at least Version 2.4 - but be careful when running code based on the newer API’s naming convention on systems from Yosemite to Sierra.
To catch up any issues you should put them into properties what then should solve any issues at runtime because their numeric values are still the same even though their Labels have changed with the release of High Sierra.
Long story short - it is up to you what you tend to use - is it NSShiftKeyMask or NSEventModifierFlagShift.
The tricky part - checking which side of the Keyboard is used - is the same for both API’s - the old and the new ones. For detecting this kind of thing we can use the enums we already have a tool like the Application Key Codes (maybe from ManyTricks - I don’t remember it right currently) and time to write the code that does the math for die MaskInformation based on which combination of modifiers is used for the Keyboard shortcut.
The most of this reply is based on information I have from Posts by Shane Stanley on the Script Debugger Forum.
I’ll make a post with the full code in the Macro Library if I finished it.
Edited On March, 1st 10:02 GMT +1
I‘m going to bed now because it is nearly half past one in the morning in Germany and I fall asleep while typing…
Generally, "deprecated" means "still works but will be removed in the future, so don't use it". While it's fine for us to use in our own stuff, I'm simply suggesting that if this something you are are going to release to the public then you'll save yourself some headaches in the future if you go with the new form.
I did have a look for NSEventModifierFlagLeftShift etc as you suggested (but have since removed) because that looked really promising -- but zero hits on the Googles
Have things changed recently? Because I thought Shane said you couldn't do this with ASObjC. Again -- really hoping things have changed!
This does appear to be possible via actual Objective C or Swift, by getting the raw value of the modifier flag (eg this Stack Overflow thread), but perhaps not with ASObjC. But those are beyond my understanding...
Whether this could be usable as a KM trigger is another matter. We might be able to use what you come up with inside a macro though, and I'm really looking forward to seeing it. So thanks in advance for the work you are putting into this!
I suppose that I have to give up …. The stuff I was after is all based on the Core Graphics API …. but I if it has changed and you could use it in ASObjC it would be great - but maybe there has some time to go because even when this seems to be possible now - my knowledge in writing scripts of this kind of thing will have to get better first …
But since this is all there Peter could make the detection for left and right modifier keys in KM possible …
And yes I be changed my reply completely because I searched my Notes that I’ve made about the whole thing so far - and badabang - I was able to provide more information as before I edited the post.
I’ve to go offline - suffering from very Strong headaches…
@Nr.5-need_input First the bad news. There will never be an app that does everything the way you want it to. You can keep waiting and hoping for a miracle to happen. Or you can resign yourself to it and see what else is out there.
And here's the good news. You want full control over all modifiers? BTT offers that. Right now, not maybe in three years. This is just an example to show what many here already know. KM and BTT together are the best you can ask for. What one app can't do, the other can and vice versa.
In case you don't know the difference between these apps, let me sum it up like this, without going into specific features.
quiet, stable and reliable at sea for many, many years. Unsinkable (unlike the Titanic). A child of the Belle Epoque. Everything works, is clean and well ordered. She always arrives, but always goes the same way. It takes an eternity to change her course even by a little. There is hardly any interest in new equipment, because the old is outstanding and has proved its worth.
The uneducated child next door that constantly gets on your nerves, because it keeps doing things you don't want it to. It sprints hectically across the water, makes unpredictable changes of direction and occasionally goes in circles. But it is always at the very front when it comes to trying out new things.
So, we all want to stay on the Queen Mary, but we should make sure that the speedboat is always nearby because we will need it, sooner or later.