Multi-monitor and Keyboard Maestro

I’m loving Keyboard Maestro except for one thing: when I trigger a macro to open a file, etc. it always opens on my first monitor even when I’m on my second monitor. I’ve tried moving Keyboard Maestro itself over to the second monitor but that doesn’t help.

Is there a way to make Keyboard Maestro do its thing on whatever monitor is currently active when a macro key is pressed to save having to move a lot of Windows around?

Thanks

Hey John,

You need to provide a more complete picture of what you’re doing.

Keyboard Maestro doesn’t do its thang except when executing actions that relate specifically to Keyboard Maestro, otherwise it uses various APIs to instruct the OS and other applications what to do.

Applications have their own idea of what monitor they want to work with. That’s not up to KM, although it can move windows around to various screens.

What kind of file are you opening? Into what application?


Best Regards,
Chris

Thanks for replying. I’m trying some real simple things, like opening a Finder window into a specific folder. If I manually open Finder while on Monitor 2, the Finder window appears on Monitor 2 but if I’m on Monitor 2 and use a macro key it always opens on Monitor 1. First world problems, I know.

Hey John,

Okay. Look here to see how this might be done with KM.

For simple Finder stuff I personally would probably use AppleScript.

AppleScript considers a multiple-monitor-setup to have one big desktop window, so you have to figure out how you want to place and size your windows. Here’s an AppleScript to do just that:

--------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2014/02/12 16:38
# dMod: 2015/01/15 17:11
# Appl: System Events
# Task: Get Bounds of Selected Process's Front Window and put them on the Clipboard.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @System_Events, @Bounds, @Front, @Window
--------------------------------------------------------------------
try
  
  tell application "System Events"
    set procList to name of processes whose background only is false
  end tell
  
  set _process to choose from list procList ¬
    with prompt "Pick a Process:" default items {item 1 of procList}
  
  if _process = false then return
  
  set _process to item 1 of _process
  tell application _process
    set _bounds to fmtBnds(bounds of front window) of me
  end tell
  
  set _script to "tell application \"" & _process & "\" to set bounds of front window to " & _bounds
  set the clipboard to _script
  
on error e number n
  stdErr(e, n, true, true) of me
end try

--------------------------------------------------------------------
--» HANDLERS
--------------------------------------------------------------------
on fmtBnds(_bounds)
  try
    _bounds / 0
  on error e
    set AppleScript's text item delimiters to {"{", "}"}
    set _bounds to "{" & (text item 2 of e) & "}"
    return _bounds
  end try
end fmtBnds
--------------------------------------------------------------------
on stdErr(e, n, beepFlag, ddFlag)
  set e to e & return & return & "Num: " & n
  if beepFlag = true then
    beep
  end if
  if ddFlag = true then
    tell me
      set dDlg to display dialog e with title "ERROR!" buttons {"Cancel", "Copy", "OK"} default button "OK"
    end tell
    if button returned of dDlg = "Copy" then set the clipboard to e
  else
    return e
  end if
end stdErr
--------------------------------------------------------------------

Run the script to put a pre-made script on the Clipboard to set the bounds of the front window in the selected application to its current position and size.

Place and size your window. Run the script. Paste your AppleScript.

An AppleScript to open and resize a window in the Finder might look something like this:

set docsFolder to path to documents folder
tell application "Finder"
  activate
  open docsFolder
  set bounds of front window to {0, 44, 844, 1196}
end tell

I have 20 or 30 open and/or resize scripts for the Finder and use them often.


Best Regards,
Chris