Switch to last 'window' instead of just 'application'

Hi there,

So i made a simple macro to toggle (activate/hide) an app with a hotkey, which works - most of the time.
However, for example when i have 'Parallels Desktop' open which has multiple (some fullscreen) windows open, the 'switch to last application' bit of the macro (see screenshot) does not work as expected;
It switches back to 'Parallels Desktop', but to its main window (Control Center) instead of the last window i was in before pressing the hotkey.

So, my question is: how can i get the macro to not just switch back the last application, but specifically the last window i was in?

Thank you in advance for any tips :slight_smile:

1 Like

Replace all mentions of Finder in this macro with Obsidian and give it a try:

Obsidian Toggle.kmmacros (24 KB)

Screenshot

Hi, thank you @noisneil for your reply!

It still does not always work unfortunately, i just noticed something weird;

When opening additional VM's you get extra Dock icons for each VM/window that has opened. So what the macro often does, is activate the 'Control Center' window instead of the VM;

  1. move the 'Control Center' window to Space2
  2. move the Obsidian app/window to Space2
  3. Go the Parallels VM (fullscreen) in Space4
  4. Toggle the hotkey.
    :white_check_mark: this activates the Obsidian window
  5. Toggle the hotkey again
    :x: this activates the 'Control Center' window in Space2 (instead of the Parallels VM in Space4)

However, this does work::

  1. move the 'Control Center' window to Space1
  2. move the Obsidian app/window to Space2
  3. Go to the Parallels VM (fullscreen) in Space4
  4. Toggle the hotkey.
    :white_check_mark: this activates the Obsidian window
  5. Toggle the hotkey again
    :white_check_mark: this activates the Parallels VM in Space4

So it seems to only misbehave when they are both in the same Space.
I also noticed this behavior is the same in your Macro, as also in the default Macro i was using before.

Any idea? :man_shrugging:t3:

1 Like

I'm afraid I've never used spaces, so I'm not sure. Does using the macOS app switcher as usual also activate the Control Centre rather than the correct VM, or is it just when using KM?

By 'macOS app switcher' you mean the default macOS Cmd + Tab i assume, yes this does work.
I do notice that the 'Control Centre' (title='Parallells Desktop' in the screenshot) always puts itself first in the order, even when i was in a VM window (the one with the 'f' in the screenshot)... so you always have to tick Cmd + Tab twice to switch from Obsidian back to the VM window.

In that case, could you possibly replace *Activate last application" with two cmd+Tab keystroke emulations? Edit: Ah no, I've just realised that would just switch you back to Obsidian. :man_facepalming:t2:

Ok how about this? I've disabled the actions that bring the previous window to the front, in case this works without them. Again, replace any mention of Finder with Obsidian.

Obsidian Toggle v2.kmmacros (28 KB)

Macro screenshot

Hello @noisneil , so i just had time to test this again, and... it still does not work for some reason :man_shrugging:

I notice the Parallels App does some weird things with the tab switcher for some reason (like for example activating the 'last VM window i had previously activated' when i actually click the 'Control Center' window in the Dock.

The solution i've settled with right now, is to just hide (Cmd+h) the 'Control Center' window, which solves the issue and your first macro works.

The downside is, i have not found any way to unhide and activate the 'Control Center' window... but i'm going to give up and call it a day for now.... :roll_eyes: :smile:

Thank you for your help and assistance!

1 Like

Sorry it didn't work. Hard for me to really develop a better version without having Parallels. Glad you found a temporary workaround at least.