As part of a larger project I am trying to determine applications that are i) running and ii) not hidden.
I created the below macro which:
Creates a list of foreground applications that are running.
Filters that list by removing applications included on that list because of Parallels.
Next step is to further filter the list in 2. by removing the applications that are hidden / minimized. The below macro uses the function WINDOWCOUNT to convey the idea knowing that WINDOWCOUNT is not a valid function (i.e., I did read the Wiki).
Applications cannot be minimised, and all an application's windows can be minimised without an application being hidden. Which do you mean?
There's no way (AFAIK) to limit the KM %Application% tokens to unhidden apps -- foreground, yes, but that includes hidden. So you will need to reach for AppleScript. For example:
tell application "System Events"
return name of every application process whose visible is true
end tell
Why do you care if apps running under Parallels can be reached via AppleScript if you are deliberately omitting them?
Remember that KM can only process the windows of the frontmost app. Are you going to iterate through every (unhidden) app to do this?
I've a feeling I know where you're going with this. Does Moom register/set Parallels-managed windows? You may be better off grabbing all the positions in Moom, doing the thing that moves them about, then re-applying that saved Moom "set".
Apologies, my Windows side is showing, I mean hidden.
Appreciated, I ran the script and the Parallels applications came up as WinHelper App. While they are identified by Keyboard Maestro as a foreground app, System Events does not see them.
I wonder whether passing AppleScript the Keyboard Maestro list of foreground apps would help.
I am not omitting them, I actual want to grab / include them!
I will ignore all hidden apps,
I want to take the list of foreground apps (which I have) and remove those apps that are hidden. The reason is in my response to your below comments on Moom.
As a long time Moom user, I like the idea, perhaps that is easier except the "set" is dynamic.
The idea tracks back to display preset change that you assisted with (latest versions attached) and in particular Step 7 therein.
The macro works very well save for one aspect; repositioning the Parallels windows after the preset change.
The result of the display preset change is that the Parallels apps that are not hidden all shift to the top right left corner of screen 1. What I would like to do is to determine the screen, position and size of each visible application including the "facing application" on screen 1 and screen 2 and restore all application windows to the exact screen. position, and size that they were in before the display preset change.
What I have hobbled together in Step 7 of the macro more or less works other than:
Cycles through a defined list of all Parallels applications which means whenever I add a new Parallels application (as rare as that is), I would need to update the macro.
If the front application is not on screen 1 when the display preset changes then screen 1 defaults to Outlook as the "facing" application after the windows are repositioned. Would love to remove the default and perfectly restore.
Screen 2 code / logic for the facing application is not included (as I wanted to solve screen 1 first).
NOTE If we ignore the bit about the "facing" application then there is no need to concern ourselves with macOS apps other that those of screen 2 (which is usually just Calendar) need to be resized because the Dock temporarily transfers to screen 2 resizing those apps.
Worth noting the key focuses are repositioning the Parallels windows to the proper screen and size where they were before the change with the correct "facing application" on each screen. **Perhaps you have a better idea how to do this or improve on my process".
Worth noting the macros is well documented so should be easy to read.
Not a user, but I thought a point of Moom was that you could grab a "point in time" snapshot of all windows of all apps, then later reapply that to put them back in position. So
Grab to Moom tempSet
Display change
Apply Moon tempSet
Failing that, it would seem from your description that the problematic items are windows for Parallels Coherence apps that are not hidden. So you don't need to grab all the windows of all the apps -- just those of unhidden Parallels apps. I'm not saying that's easier, but it does reduce the amount of work required!
If the above is correct then two other possible approaches suggest themselves:
Hide the unhidden apps, make the display change, unhide the apps, or
Take Parallels out of Coherence, make the display change, turn Coherence on again
Apologies for spitballing rather than given tested solutions -- but I'm not risking doing any of this remotely on my work Mac in case it all goes horribly wrong. I don't fancy a 50-mile round trip to go and hard-reset it!
I will look into that, I will also need to check the two screen issue!
Agreed and should you look in the macro I sent earlier I have that part figured out. The issue is that is the 80% solution, not teh full monte as it leaves i) fixing the macOS apps on screen 2 and ii) "facing apps", albeit these are minor issues.
I like solution 1 as well!
It all tracks back to your comment of define the problem and find the best solution! Need / will work at getting better at that!
I greatly appreciate any and all idea / time you can provide so all good, no worries. Wishing you an enjoyable rest of your vacation!