Hey guys and gals! New here. I'm having a devil of a time with moving and resizing windows. I want a window to move and resize exactly as is shown in the attached screenshot, but I don't know how to determine exactly where it is x and y on the screen and how to tell KM that I want to end up there sized exactly as it is. Please help. Also, talk to me like I'm 5. I'm just getting into automation.
Your picture didn't come across. But here's what I'd do.
First, I'd set up a macro that has a hotkey trigger, with one action:
FrontWindowPosition = %FrontWindowPosition% FrontWindowSize = %FrontWindowSize%
Bring the application window you want to manipulate to the front, and trigger the macro.
Let's say it gave you this result:
Then all you have to do is add a "Move Window" action:
and click on "Move To", and select the following option:
and your action will look like this:
Then just paste in the numbers, like this:
Hope that helps.
That did it. Thank you SO much!
If you don't mind, a follow up. How did you know what syntax to use in the display query? I never would have know how to do that. Is there a wiki somewhere with that info?
Yes, here's the Wiki: https://wiki.keyboardmaestro.com/Home_Page
We (those of us who answer lots of questions, or in my case, used to answer lots of questions) love it when people ask questions like yours. Sometimes it feels like people just want easy answers, and that's OK, but when someone wants to learn, well, that just makes our day. So, kudos to you, and keep asking questions!
So let me go into detail how I found this. Even though I know KM very well, even I have to dig a little sometimes. So here's what I did.
First I searched for an action that retrieved the window's position, and didn't find any.
Then I realized that there was probably a "token" for this. Tokens are awesome, but for some reason, I don't immediately look there. Anyway, I went to the Wiki, and searched for "tokens", and this is what I got:
If I had been observant, I would have picked "A", or better yet, "B", but I picked "C" which was fine, but I just wanted to point out "A" and "B" so perhaps I'd remember to look there next time.
Anyway, when I got to the list of tokens, I looked for "Window", and found what I (or you) needed.
Then I wondered how to display the information, and at first I was just going to use a regular "Prompt for Input" action, but I decided it would be better to be able to copy the values, and I knew there was some sort of "Display" action that displayed text in a window.
So I searched for "Display" and got this:
Even though it said "Display text briefly", I noticed the menu button (arrow), so I figured this had what I wanted. And sure enough, when I added the action and popped up the menu, there it was:
Then I messed around displaying various Window tokens until I thought I had what would work best.
Then I searched for a Window action, and got this:
Even though this didn't show changing the position, I saw this one did:
And I figured the popup menu would have the action I wanted, and it did, after a little poking around:
And that's the thing about KM. There's SO MANY things it can do, you can't possibly know everything. I'll bet even Peter (the guy who wrote KM) doesn't even remember everything it does.
So when I'm stuck, I search the Wiki, and this forum, and I usually find the answer pretty quickly. I also periodically just skim this forum, looking for interesting topics. I learn new things all the time that way.
Anyway, enough of this novel, and have fun! Keep learning, and asking good questions like this.
You're very helpful, Dan! I really appreciate it!
Hi @twijit, welcome to Keyboard Maestro (KM) and its Forum.
KM is one of the best Mac automation tools available, its Forum is one of the best and friendliest forums on the Internet. Whenever you reach a tough stumbling block trying to use KM, please feel free to post your question/problem here for help.
You will also find this helpful:
Tip: How Do I Get The Best Answer in the Shortest Time?
Getting Started with Keyboard Maestro
- Read the Quick Start.
- This is essential to become familiar with KM terminology
- Do the tutorial (Help ➤ Tutorial) in the KM Editor.
- Gives you a live walkthrough of creating a macro in the KM Editor
- Review/Browse the Available Macro Actions
- For Help with an Action in your Macro, click on the gear icon at the top right of the Action, and select "Help"
- Search the Keyboard Maestro Wiki for detailed help.
- Start small, and grow your macros organically.
- Be prepared for some trial and error in the beginning.
- Make good use of this Keyboard Maestro Forum
- Checkout these Great Resources
- Search for existing macros
- Post your questions/issues if you get stuck
- Be sure to first read: Tip: How Do I Get The Best Answer in the Shortest Time?
For more help, see Getting Started with Keyboard Maestro and the Forum .
Definitely - more than once I've gone to say "there is no way to do that" and found someone else had found a way I'd forgotten about.
Thank you for this, Dan! I had the same question as twijit and just used this approach successfully. Much much much appreciated!
I recently made the jump to Catalina and found that on my three screen set up there are new menu items in the window menu.
Move (to screen x)
Move (to screen y)
I renamed my screens so the left and right screens are named "Left" and "Right" and then I just use KM to call the menu item in the window menu to move the currently frontmost window to that respective screen.
I know this is not what you where trying to do per se, but hoping it helps others.
Thank you for this post and the one where you lay out how you search the wiki. Very helpful. Discovering this post save me from extending beyond an hour a bout of frustration during which I tried to figure out how to do moving and re-sizing of windows on my own.