I have a nice little macro that launches my main applications. Usually I have my MBP connected to an external display, and I want some of those applications (generally those not directly involved with work, such as Mail, iTunes, Messages and Calendar) to appear on the external display.
So I’m interested in if there’s a way to do this with Keyboard Maestro. It it possible to use an If clause to say "If there’s an external display connected, then move the main Mail window to the external display).
I did look through the documentation and poked around the available macros, but didn’t seem to see anything that would do the job. Is this possible?
You’ll probably need to wait until everything finished launching and then activate Mail and the move the window.
Also, in Yosemite when you move a window to another monitor it tends not to notice the monitor change, so you need to simulate a click in the menu bar (72,20 relative to the front window’s top left corner). In this case, you probably don’t care since you’re going to be activating some other application anyway.
How about the second portion, where I want to move the window to the second display. I found the Move Front Window to Position action, but it seems to only offer options for exact pixel placement. What I want is (the displays have the same resolution), “Move this app’s window to its same relative position on the other display.”
As a possible workaround if this isn’t possible with KM, I have a Moom shortcut that does exactly that, so maybe just faking the keyboard combo set there would do.
Use the SCREEN and WINDOW functions to determine the old and new position.
To determine which screen it is on, use a calculation something like:
WINDOW(1, MidX) < SCREEN(2, Left)
To move the window to the same relative coordinates, assuming they are the same size and at the same height, then to move from screen 1 to screen 2 you just need a Move By action with right movement of:
SCREEN(2, Left)-SCREEN(1, Left)
Ie, something like this:
The other side of the condition is left as an exercise.
Hi, I found that this only works if no screens are mirrored. This only seems to count the number of unique screens, so if you have 3 screens but 2 are mirrored SCREENCOUNT will still equal 2. How can I detect the number of screens connected regardless of whether they are mirrored or not?
That is a hardware issue, below the level that Keyboard Maestro operates at.
I imagine there is a scripted way, perhaps by interrogating the hardware in some way, but I don’t know what it is, and a quick web search didn’t find any obvious solutions.
Do you think others could benefit from it? Perhaps you could post your solution, at least a high-level overview of it? Even if it's not KM-specific, it might be helpful. Someone else will undoubtedly try to do something similar, at some point in the fugure...
Sure, it’s not a true solution but it could be useful to others.
I am using a MacBook with two external monitors. I wanted to be able to have 1, 2, or 3 unique screens and have different macros for each case. This would require detecting when screens were mirrored. I gave up on trying to get this to work.
Instead, I found a downloaded SwitchResX. This allowed me to switch my MacBook to the same exact resolution as my external display, even when it is not connected. I always keep my MacBook mirrored to one monitor now. Therefore I only have 2 modes: single screen and double screen. I never have to change resolution settings or mirror settings, since I just never use the default MacBook display settings even when I’m on the go.
Could you clarify on this? I tried making this macro but not sure if I understood your instructions correctly. I'm thinking that the If Calculation Screencount command needs to be in a trigger instead of an action, but there is no trigger that i see for this.
Also wondering, would this only be triggered when the monitor is connected or at all times continuosly as the monitor is connected? I would want it to only trigger when the monitor is connected so that i am still able to manually move the window to other monitors if i choose after its connected.
Could you please be more specific about what you are trying to achieve, what you want to automate? The best way is to list the detailed steps you take manually. Be sure to include the name of all apps involved, and/or the URL of all web pages used.
I thought that adding another monitor would be something that I could monitor on a trigger level. Hope you can consider raising this to a trigger event. In the meantime thanks for offering the calculation solution.