Newbie question about moving windows

OK, I'm relatively new to Keyboard Maestro and am having an issue. I am trying to create a macro that should do the following:

  1. Launches Safari
  2. Moves the Safari window to the right half of the screen.
  3. Then selects the Safari address bar
  4. Paste in a particular web address
  5. Types the 'Return' key to go to that website
  6. Launches Discord
  7. Moves the Discord window to the left half of the screen.

Everything seems to work except the two move steps (2 & 7 above).

The image below is what I have set up to move the Safari window.
It is like it skips over the move command but will paste in the web address as intended and goes to the site.

Any insight into what I am doing wrong?

I have also tried "Safari" for the "in" selection instead of "Front Application"

Regards,

John

The main problem is that you are setting the top, left of the window to the RIGHT position of the screen:
SCREENVISIBLE(Main,Right)

Also, "Main" refers to the main screen in your setup, which is not necessarily the same as the Front screen.

Try this:

image

Download ACTION
Manipulate a Window.kmactions (987 B)
Importing this file inserts the Action immediately below the Action currently selected.

I can vouch that this example macro does everything that you say you want to accomplish, at least on my own Mac, and it also has the benefit of using a more effective way to go to a desired website in Safari; all you have to do is change the default Keyboard Maestro site URL to the web address you want it to use.

Example Macro.kmmacros (5.5 KB)
image

The Activate a Specific Application action already pauses until the application is at the front, so the two Pause Until actions are redundant as written.

Note that you will sometimes need a pause in that location because an application can be at the front but not finished launching or reopening windows. So instead, you probably want to add a Front Window condition to wait for a front window to exist.

1 Like

Thank you for the reply.
I'm not sure I understand your statement about setting the top, left of the window to the Right position of the screen? Could you explain? I have been looking at the manual and have not found anything in the Move & Resize instructions that talkd about the 'left' of a window.

The settings I originally posted were just what KM automatically populated when I chose the "Right Column" from the options. Is there another selection that I should have used that would use the 'MidX' or is that just something that I will have to edit each time I create a macro that uses the "Right Column" option?

With regards to the "main" vs "front", it turns out that my computer thought I had two monitors, I don't. However I did have my computer connected to my monitor with two connections. One directly to the monitor with HDMI and another thru and External EGPU using Thunderbolt. So, the computer must have thought I had two monitors. I disconnected the direct connection from computer to monitor and now it only sees one. I changed to the "Front" window.

Still does not seem to be working though. Any thoughts?

Thank you for your reply.

Based on your and JMichaelTX's comments I tried a simple experiment. I used just the first three steps of the Macro that you suggested. So, it should launch Safari, Pause until Safari is at the Front and then move the window using the settings that both of you suggested for the "Move and Resize" settings.

Safari will launch, but the window will not move to the right. Does not move at all.

Any other suggestions?

AHHH HAAA! I believe I am getting there. I used your suggestion to change the Pause Until conditions to "The Front Window of: Safari: Exists". That worked. I then added the "set URL", "Activate Discord" and "Pause until Front Window of: Discord: Exists. then perform the move to the left.
Everything seems to work except for the last move but I think I know why. When Discord launches, it puts up a small square window with animation showing that the app is launching. That window is getting moved. Then, that window goes away and the actual Discord window appears but it stays where ever it appears (the second move was used by the launch animation).

So, what I did was replace the second "Pause until Condition met" with a straight "Pause for 4 seconds". This gives the startup animation time to complete and the main window to open.

I'm sure there is a better way and would love to hear it.

Regards

You may be able to say something like "Pause Until the window title is (or contains or is not) something.

In particular, that small square window probably has a window title that is fixed and different to all other windows (perhaps empty). You can have Keyboard Maestro display the FrontWindowName token after the Pause Until front window exists in Discord (when the square window is up), and then add in another condition related to that name.