move focus to next window for current app in another desktop macOS Mojave

Under the conditions you've expressed, here's an alternative that I use when ` isn't a viable option.

Using the example AppleScript code below, saved as a .scpt file in Script Editor, and using FastScripts to assign a keyboard shortcut to it, it clicks the frontmost application's Dock Tile so it will switch between Desktops. For this particular script in FastScripts, I use keyboard shortcut ⌃⇧⌘D to trigger it.

tell application "System Events" to click UI element ¬
    ((get name of application processes whose frontmost is true) as text) ¬
        of list 1 of application process "Dock"

Or, if you do not want to use a third party app to trigger the .scpt file, the example AppleScript code can be used in an Automator Quick Action1, setting Workflow receives no input in any application and add a Run AppleScript action, adding the example AppleScript code where is says: (* Your script goes here *), then save the Quick Action.

You can then assign a keyboard shortcut in: System Preferences > Keyboard > Shortcuts > Services


Note that using either method may require accessibility privileges be granted.

Also keep in mind that when assigning global keyboard shortcuts, there is always the potential to conflict with an already assigned shortcut, so you may have to use a different one and or add error handling to the example AppleScript code


1 In versions of macOS prior to Mojave a Quick Action is called a Service.


Note: The example AppleScript code is just that and does not contain any error handling as may be appropriate. The onus is upon the used to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors.


I am not affiliated with the the developer, Red Sweater Software, of FastScripts... just a satisfied user.