Some typing / key pressing issues with and without modifiers

Thanks everybody for your time and efforts.

Yes. Indeed it is not very straightforward. The "Grouping" idea is good to have but it only saves screen space and not programming time - sorry, but I'm kind of a nerd in terms of time and work efficiency...but I know that KM has some shortcomings in these aspects (thanks Nige_S for showing that you agree) so I have to deal with it as is.

Again @ Peter and all:
Still struggling big time with my application of holding alt(=option) problem:

What I want to to is as follows:
I want to make a key on my USB X-Keys device to just operate like the alt key and another key as the Tab key for the purpose of alt-tab-stepping through the apps and windows in Win11 on Parallels - just like you would do on the native Mac using command instead of alt(option).
None of the variants Peter has named so far in this discussion works.
I've set up the macro like this (referring to a method I've learned in another thread for mouse-jumping to a certain screen location during holding a key and then move back to the original location on release):

Should that for itself work like intended ? (unfortunately we can't see whether alt is hold or not, but in Debugger it is shown that the action is taking place (first line appears on pressing and holding, second line on release after a while):

Now the problem:
The other key on the USB device should now emulate the Tab key being pressed several times, also with some pauses in between in order to select an app / a window in Parallels. The simple macro for the other key goes (or at least in my mind should go) like this:

Doesn't work. Also tried to use "alt-Tab" instead of Tab only in the action - according to Peter's explanations...this leads to the same result like pressing alt-Tab once (directly switching to the last app/window)...

Any clue how I can get to what I want here ?

Please don't put words into my mouth -- that is not what I said.

That I'm having trouble getting into the "KM mindset" is because I'm used to writing scripts that do things rather than macros that control other things. It's no reflection on KM, it's me trying to use KM's screwdrivers in the same way as my AppleScript spanners.

And I'll say again that sending the Alt-Tab event from KM, using a simple "Type the Option-Tab Keystroke" action, worked 100% for me once I'd changed my VM settings as discussed in the other thread. I'd argue that it isn't the events that KM is sending that are the problem, but the way Parallels is interpreting/redirecting those events.

1 Like

Compared to what? Is there another piece of software you know of that does it a different, more efficient way?

It takes me about 3 seconds to enter a Simulate Hotkey action. I can then duplicate that 5 times in about 1 second, then go through and change the hotkeys. From there it takes about 2 seconds to group and collapse them. I think this is just a teething problem, and you'll soon be flying along.

On to your macro...

It's best to actually post your macro rather than just screenshots, as it means we can try to help by editing what you already have. That said...

No, for reasons stated earlier in this thread.


X- Keys - Hold Alt.kmmacros (23 KB)

Macro screenshot

This uses AppleScript, so it takes a fraction of a second for ⌥ to be held down. Just be aware of that. Replace the USB Device Key trigger with your own, remembering to include the ⌥ modifier for the release trigger.
Keyboard_Maestro_Editor_—_X-Keys-_Hold_Alt


Yes, because that's what your macro does. If you want it to repeat the Tab press with pauses, you need something like this. Remember to change the trigger, obviously.

X- Keys - Tab x 3.kmmacros (21 KB)

Macro screenshot


The above macros hold ⌥ and simulate Tab separately. I don't know why you want to do this.

Here's one that does both together, which seems the logical thing to do, unless you have a good reason not to. Again, remember to change the trigger.

X- Keys - ⌥Tab x 3.kmmacros (21 KB)

Macro screenshot

Sorry, was not intended....obviously got you wrong here...and of course I didn't know about your general use of scripts as a workflow...:wink:

Hm. I made a screenshot of the whole macro. What do you mean instead...? Am I supposed to export another view or data of the macro ?

I knew this was hard to understand :wink:
Just to make that a little clearer: I don't want KM to press Tab several times with pauses in between, I want hold the one hardware key to hold alt and then I want to use the other hardware key to use it as a Tab key and tab through with whichever pauses I want to....

I've tried to follow the steps you kindly provided, of course replacing your Stream Deck key by my own but still can't get it to wrk with the second key as the "forwarded" Tab key.....can you do that on your Stream Deck setup ? Maybe you could provide me with the macros I'm supposed to use for the two keys ? And in order to exclude transferring issues from Mac OS to Parallels at first, could you set this up simply with CMD-TAB for me so that I can try it with Mac OS's app-toggling ?

It's always helpful to post the macro itself.

File > Export > Export Macros.

As you read on, you'll notice that I wrote the remainder of this post before I saw your reply. Regardless, you can adjust the actions each key combo performs to suit your needs. In this case, you'd just simulate ⌥Tab.


It crossed my mind that you might be insisting on holding one key while you press another because you want different held keys to make the same trigger do different things.

For example:

Press key A, = Tab
Hold key 1, press key A = ⌥Tab
Hold key 2, press key A = ⌘Tab
Hold key 3, press key A = ⇧ Tab

That's the only reason I could think that someone might want to do that rather than simulate hotkeys with their own modifiers.

In the macros below, I've used hotkey triggers for clarity, but you'll replace them with USB Device Key triggers. Leave the macros disabled until your triggers are set up.


X-Keys Hold.kmmacros (23 KB)

Macro screenshot

Replace the Hotkey triggers with the USB Device Key triggers that you'd like to hold in order to make another key do different things. Enable this macro and the red action and press one of the keys. You'll see its TriggerValue appear in a window. Copy this, ready to paste into the second macro below. (Disable the red action again until you want to get another hold key TriggerValue.)


X- Keys - A-B-C Switch for Held Keys.kmmacros (48 KB)

Macro screenshot

Open up one of the "Do different things when different keys are held" groups and paste the previously copied TriggerValue into one of its Switch fields.

Switch Fields Screenshot

Repeat until you've set up all the hold keys you'd like and then adjust the red actions to do whatever you'd like them to. Set the triggers to the USB Device Keys you intend to press (while another is held), enable the macro and away you go...

When you say "pauses", it implies programmed pauses. Do you mean you just want hitting the key once to simulate ⌥Tab?

  • Which macro that I posted are referring to?
  • Please state clearly what you are trying to do. You never mentioned a "second key" before.

Now it's getting even worse "understanding-wise".... :grin:

Just reset everything I tried to describe in your mind and just think how you use the CMD-Tab for selecting one out of several running apps on the Mac ! Which means holding CMD, then Tab one or multiple times in order to find the app you want to address/make active and then release CMD in order to finish the process. THAT's exactly what I want to accomplish using two keys on my USB device....

This:

might be a more advanced example of a task I'd really find interesting digging into someday.

Do you mean you want to specify the app as part of the macro?

If so, use the Activate a Specific Application action:

If you want your key to just trigger ⌘Tab, then:

You do NOT have to hold the modifier separately. If the above does not satisfy you, then please tell us why you specifically want to trigger the modifier separately.

1 Like

No. It's just the process of using the "carousel" of active apps with CMD-Tab (on the Mac which equals alt-tab on Windows) in order to select one - NOT a specific one each and every time...don't you know what I'm referring to ?

See the video link in brackets....:
(HiDrive)

AAAHHHHHH!!! I get it!!! You want the app switcher to remain visible between presses of Tab!!!!

Of course!!!

This wasn't clear to me until this very moment! :man_facepalming:t2:

I don't think this is what you were initially asking for in your first question. But the answer to replicate this in Keyboard Maestro has already been given:

That will keep the carousel visible and click through three apps. Without the "hold" Action at the start, nothing would happen.

One thing that might help you come to terms with the way Keyboard Maestro works is that each Action completes what it does before the Macro moves on to the next Action. They don't overlap. That is why it is necessary to keep ⌘ being held down in the three Actions that follow the initial "hold" of ⌘.

I'm afraid I've already given the best solution I can think of in THIS POST. I'll post it here again, tweaked to do exactly what I'm 74% sure you want:

X- Keys - Hold Alt.kmmacros (23 KB)

Macro screenshot

X- Keys - Press Tab.kmmacros (20 KB)

Macro screenshot

All you have to do is replace the Stream Deck triggers with your X-Keys ones.
Again, the drawback is that, because it uses AppleScript, you have to wait about 0.5sec before pressing the second key. This is the best I can do, I'm afraid.

1 Like

The following is an answer after completely misunderstanding the question, left for posterity to show what an idiot I can be! Sorry for wasting your time...

@uliauer -- The following works for me:

Movie of it in action at http://www2.gurdon.cam.ac.uk/~nigel/Alt-Tab_Macro.mov -- forgive it looking rather shonky, not easy to do on a remote machine over a VPN and "rural" broadband!

That's with Parallels Desktop v15, Windows 10, and "Send macOS system shortcuts..." set to "Never", as previously discussed. I put the pauses in more to show what's going on, but it might be that they are important. Perhaps try with those in, then steadily reduce the times until something breaks...

Of course, none of the above means it will definitely work for you -- different Parallels version, beta Windows OS, etc, etc. But it shows it can be done, and if it's not working for you it isn't because of a basic deficiency in KM.

He doesn't want to automate multiple presses. He wants to hold Alt so that the Application Switcher (or whatever Windows calls it) appears onscreen. He then wants to press Tab manually to switch through the carousel. This whole time, Alt needs to be pressed down to keep the Application Switcher active. That's the key part of what we were all missing.

I do wonder whether there might be a way to re-map these keys inside Windows or Parallels though. I vaguely remember VMWare could do it... maybe...

Gaah! I'm still on our previous conversation!

OK -- so the Windows "window switcher" doesn't appear when you press Alt, it appears when you press Alt-Tab and remains while you hold down Alt. Same behaviour as Mac's Cmd-Tab in other words (hey, they "borrowed" so much from us, we deserve this one :wink: ).

So my new thought is:
A macro triggered by hardware key 1 that

  • does press-and-hold on the Option key
  • sets aVariable to true
  • repeats while aVariable is true, type Alt-Tab then pause 0.5 seconds

and a macro triggered by hardware key 2 that exits macro 1.

So instead of repeatedly hitting a key to get the window you want, you let the windows cycle then hit the key to stop on the window you want. @uliauer -- would that kind of workflow work for you?

@Nige_S, Ummm... you mean like this? :joy::joy::joy:

@uliauer, have you seen these articles about remapping keys in Parallels? May or may not provide a nicer solution that doesn't involve AppleScript and its inherent (relative) sluggishness.

Ummm... I guess so! TBH, I didn't even know you could set a key-down and a key-up trigger for the same macro to turn it into a "while key is pressed" one. Definitely one to file away for later.

Now all I need is an "insert :man_facepalming: after every stupid post" macro. Should be pretty easy -- something like "If posted by Nige_S, insert..." would be good enough, going by tonight's showing...

1 Like

Don't feel too bad mate. I was going :banana::banana::banana: trying to figure out what @uliauer was after. He hasn't yet confirmed that we're there, but I've already opened the :champagne: in preemptive celebration. Let's hope that moment of headscratching is behind us!

YEAH !!! CONFIRMATION !!! YOU GOT IT !!!! :rofl: :rofl: :rofl:....maybe ?

I think (or better I thought) I've described it already like that but just in order to bring all of your creative ideas on spot again: I really want to use the app-selection with CMD-TAB on the Mac or the equivalent in Windows with alt-Tab just as I use it using a normal keyboard - just with two keys of my USB XKeys keypad instead of the "original" keyboard keys.

No programmed timings or anything else.

No tricks. No magic. No fairy dust.

Just the same dumb action "forwarded" from my USB device keys.


Unfortunately this is exactly what is NOT working either...I've tried that after Peter's explanations that a modifiier being held down stops and later resumes that once another key being pressed - I still don't understand at all what sense this could make - except for Peter's super-special application of a scrolling image... :wink:

So guys - thanks anyway for your time and efforts so far !!! Really appreciate that ! I'll check out noisneil's Links - hopefully that helps...!

BTW:

Yes. I've tried that already during solving other problems on my old machine but as long as it doesn't even work in Mac OS with CMD-TAB it's not an issue now. I personally don't think that this is the problem right now. And hence my intention to go one step back to find a solution on the Mac first in order to narrow it down - once that works and I then have problems transferring it to Parallels I'll adress that !

Good?