Is There a Better Way

I have macro that reconciles my credit card statement every month which ends with the reconciliation report being opened in the Excel. The macro is as follows:

The purpose of the four teal coloured actions are:

  1. Wait until Excel is open and at the front with the desired file open
  2. Select the Excel with the desired file open via mouse click
  3. Pause for 1 second
  4. Centre the window using the ⌃⌥⌘M

I feel as though there is a better way (i.e., Step 2's need baffles me) because it makes so sense to me:

  1. Why Pausing until Excel is at the front does not work (i.e., is not enough). And it is not, it fails without the mouse click?
  2. Whatever else I try does not work (i.e. Active, etc..),

Worth noting -- and perhaps this is my problem -- is that I have Keyboard Maestro Editor open on the same display so what happens without the mouse click / Step 2 is that ⌃⌥⌘M generally operates one Keyboard Maestro Editor.

Would appreciate help with (though I feel I should know this by now).

  1. Is this Excel for macOS, or are you still running MS apps via Parallels and Coherence? That may not make a difference, but knowing will stop people from testing in the wrong setup
  2. You've only uploaded an image and not the actual macro so it can't be checked -- but have you tried setting the "Type a Keystroke" Action's "Send To" option to explicitly target Excel?

As always, you have a great memory.

Confirmed, it is Excel via Parallels in Coherence mode.

As I was unaware of the "Send To" option , I did not previously try it. I have since tried it and it appears to work.

As to its implementation, the image and macro are included below. The one follow up that I have is whether there is a better keystroke to send that "Home" which I selected because it should be "benign" to the resulting spreadsheet.

Macro Image

Run Reconciliation.kmmacros (11.5 KB)

As always great suggestion and much thanks for both helping me and teaching me!!

Why have you added that? Can you not just send the ⌃⌥⌘M to Excel? What's that doing anyway, and do you need to keystroke it?

As always, I'm on Intel not Apple silicon so my Parallels may behave differently to yours...

Pausing until Excel is frontmost is probably not enough, since Excel will activate and then load your document. Try pausing until the "the front window of: Excel; title contains: someText" -- you can get someText from your file path variable, everything after the last / but before the . should do it.

For me, even that isn't enough as the window is frontmost but not visible -- I have to activate Finder then activate Excel again to truly frontmost the window.

Even then I have to explicitly send keystrokes to Excel -- no relying on it being the frontmost app.

The above is still fragile -- but, since this isn't a Mac app and isn't running in macOS, it's amazing it works at all...

To properly answer your post's title -- yes, there is. If you must use Excel, use the macOS-native version!

1 Like

Ahhh, brilliant and excellent idea!!

As noted in my OP, the ⌃⌥⌘M is the keystroke to Move and Resize a window (thank you Rob!) to a preset configuration.

I therefore cannot send the ⌃⌥⌘M to Excel as it tries to insert the ⌃⌥⌘M into cell A1, not good.

With testing -- and based on your great idea -- I changed the Pause Until condition to "UNTIL the front window of Excel title contains reconciliation" where reconciliation is one of the words in the spreadsheet name and it seems to work.

With time, I will know whether I need to add back the original condition (i.e., Excel is frontmost) but I should not have to as Excel was just activated by the previous actions Open command.

The macro is now as follows:

Macro Screenshot

Run Reconciliation.kmmacros (18.2 KB)

I wish but for work purposes I need Power Query and Excel's full VBA capabilities so macOS-native Office 365 is not an option until MSFT give sit equal capabilities (which will very likely not happen in my lifetime).

A Moom thing? A remapped macOS window management shortcut? Just making sure you aren't trying to fire a macro...

Ah, gotcha. You could always install both then pick the one you need for the particular job :wink:

Correct and not a concern as the ⌃⌥⌘ modifier combination is reserved for window positioned, and nothing else.

In my setup:

; followed by text is reserved fro text replacement
⌃⌥ is reserved for application specific macros (i..e, when an app must be frontmost)
⌥⌘ is reserved for system wide macros that (i.e., no specific frontmost app needed)
⌃⌥⌘ is reserved for window positioning

It works well for me, others likely not so much!

Agreed but in case you have missed it through my posts I like things tidy and organized so prefer sticking with one version of an app. So gar it has been challenging but have been able -- with the help of others -- to find work arounds (and even learn a little more along the way)! :smiley:

Thanks for the help, the result is far better than what I had!

There were two questions and a comment there -- "Correct" doesn't help! But as long as you aren't using "Type a Keystroke" to fire a macro it doesn't matter.

But that would be only one version -- one version of Excel for Windows, one version of Excel for Mac :wink:

Next you'll be trying to delete macOS so you only have one version of an OS installed on your machine...

Alright, let's see whether I can pick off both questions (as I initially thought were was only one):

RE Moom: Yes a Moom thing.

RE Remapped macOS window management shortcut: No, it is a keystroke combination that to the best of my knowledge is not used by macOS's window management and, to avoid any conflict, I have turned off. The keystroke is purely "native Moom" where it is set, no Keyboard Maestro pass through.

RE Firing another macro: Not possible given the modifier key assignment.

As to your sense of humour, love it, keep it coming! No, next (as in before wanting to delete macOS) will hopefully be retirement and I will no longer have a need for Windows or Parallels, I am an "old guy"!

Excellent.

I'd still be suspicious of this with Parallels in general and Coherence Windows apps in particular because of the shenanigans Parallels must be doing to correctly interpret key strokes. I have no idea how that plays with Moom's interactions with the Event queue (paging @griffman!).

IIRC, Moom can also have its actions triggered by AS. It'll be slower (AS instantiation time in the KM Action) but might be more reliable since there's no doubt about who gets what...

Phew, I was able to answer all questions, I was concerned!

I confirm that there is the ability call Moom via AppleScript which I have done in the past. I will keep that in mind should the current method fail.

In my experience Moom is capable of moving and resizing Paralells windows without any issue just that it can take longer.

To be clear -- it isn't Moom's resizing ops that I'm worried about. It's the keystroke(s) that trigger those ops and whether Parallels, with its overly-sharp elbows, may get to the Event queue before Moom and snaffle them.

Probably needless worry on my part, but hardware key strokes and simulated key strokes can be treated differently (see, for example, the issues with "Insert by typing" capitals/symbols into a Parallels-hosted app).

As the non-programming half of Many Tricks, I don't have any real idea either :). I really don't want to bother Peter (the other half of Many Tricks, not Keyboard Maestro Peter) with the question, but I would assume we're probably using the RegisterEventHotKey API, or possibly the modern replacement (CGEventTap). How that plays with the event queue, I don't have a clue :).

-rob.

1 Like

I understand and have encountered this problem with Parallels and/or Windows (it is hard to tell which in a VM) gobbling up the keystrokes.

It is for that reason my "Parallel triggers" are generally set to when I release the key instead of when I press the keys, I find this makes them more reliable.

It was either @JuanWayri or you who suggested to me and it has worked great ever since!

@Nige_S

I found a reliable way to make a Named Parallels Window the frontmost window and am sharing it with anyone interested. I have it setup to be called as a macro which passes all / part of the targeted window name as a parameter.

Screenshot

The macro is:

Window_Make Named Parallels Window Frontmost.kmmacros (4.9 KB)

It has been tested for a while and so far so good noting I use it primarily before executing Moom commands (which is a good test!).

Thanks.

@Joel, may I suggest the following, with the aim of making your macro and the preceding discussion easy to find for anyone who may be looking for such information in future?[1]

(1) Post your new macro in a new thread (“topic”).
(2) Rename this thread in order to make it clear what the subject matter is.



  1. “We are all interested in the future, for that is where you and I are going to spend the rest of our lives.”
    – Criswell, in ‘Plan 9 from Outer Space’. :flying_saucer: ↩︎

Apologies but this is the same topic.

The original question was, why opening a file in Parallels did not result in that window becoming frontmost and whether anyone had a better solution that I did, to which various solutions were suggested. I thought all I was doing here was posting a solution that works, and works well.

Thanks.

There’s no need to apologise; my suggestion was… well, exactly what it said, for the reason it said! It’s entirely your call.