Newbie: window positioning issues

I’m a newbie using Keyboard Maestro 6.4.7 on Yosemite. I’m trying to make a macro that

  1. When I type the trigger string ‘radiopp’
  2. Open a Chrome window to URL ‘http://www.radioparadise.com/
  3. Move and resize that window flush against the upper-left corner of the screen, but below the menu bar

#1 and #2 work fine.

for item #3 above, I have a “Move and resize window with name containing ‘Radio Paradise’” action. When I execute the action using the “Try” button in the KM editor, it works. When I execute the whole macro by typing the trigger string, the new Chrome window appears, but doesn’t move. I can move it by clicking the “Try” button in the KM editor.

What is the problem?

Hey Pete,

Chances are that you’re not giving Chrome enough time to establish the new window before KM moves on to the next step.

Insert a short pause between steps 2 & 3, and see if that is indeed the issue.

Better yet use an AppleScript to more organically perform the actions desired:

set _url to "http://www.radioparadise.com/"
tell application "Google Chrome"
  set newWin to make new window with properties {bounds:{0, 22, 1086, 1196}}
  set URL of active tab of newWin to _url
end tell

Bounds are: {x1, y1, x2, y2} with the first two being the upper-left corner of the window, and the second two being the lower-right corner of the window.

You can use AppleScript from the AppleScript Editor to get those values for a designated window.

tell application "Google Chrome"
  bounds of front window
end tell

Look in the Result pane for the returned set (list).


Best Regards,
Chris

1 Like

Sounds like you need to put a short pause before the third step. Try 1.5 seconds. If that works you can shorten it until it stops working.

Mike AlluredSent from my Underwood

Thanks, guys! Chris’s AppleScript solved the problem nicely.

Generally you should not use Typed String triggers to open a URL or for similar global actions (see the wiki article on the subject).

Thank you. I now use the Macro Palette instead of Typed String to trigger these.