Moving a window to a certain place on my screen?

So I've just open an app (in this case, it's the stream deck settings, app, which for whatever reason appears randomly on random places on my screen every time I open it up, which is a bit of a pain). Is there any sort of macro that will allow me to place a given app onto a specific place on my screen?

In theory, it would be the same as a three finger drag on the top menu bar with my mouse if that makes sense.

I can't replicate your problem. The Stream Deck app always appears in the same location that it was when I last closed it. It never uses a "random" location.

Nonetheless, I will still help, and the first step in solving your problem is to get KM to launch a macro when the Stream Deck app is activated. I was able to achieve that as follows: (you will have to take extra steps to select "Elgato Stream Deck" by clicking on the "Other" button and locating it in your App folder.)

Screenshot 2024-04-30 at 00.11.46

The next step is to move the window to the location you want.

The problem here is that KM doesn't recognize Stream Deck as a "window." From what I can see, Elgato has used special macOS options to make the window invisible to the GUI. Normally you would use something like this, but it won't work because Elgato has made a non-standard window:

image

However it should be possible using a different technique. The Stream Deck window is visible to the FindImage action, and you could use a different KM action to drag that window to your preferred location. Here's the code I created to solve your problem.

image

Of course, you will have to create these actions yourself manually, because my image capture will most likely not work for you. You have to create your own image capture of the multicoloured icon on the Stream Deck app.

And further, I couldn't replicate your problem, so this isn't even necessary.

Moreover, this is not the best way to solve this problem for any other app. If you are having this problem with any other app, then a different solution will work better.

You might want to contact Elgato and complain to them about the bad behaviour of their app.

Of course, my answers are right only 80% of the time, so maybe someone else will have a better solution or a better analysis for you.

My Stream Deck window also opens at the size and location where I last left it, so it sounds like an issue on your Mac. Does it successfully save changes to its Preferences? If not, maybe it's a permissions issue with its preferences file?

In any event, for windows that Keyboard Maestro can't control, AppleScript is usually a pretty good hammer. This seems to work fine on my Mac:

tell application "System Events"
	tell process "Stream Deck"
		set position of window 1 to {100, 100}
		set size of window 1 to {1200, 800}
	end tell
end tell

You could put that in a Keyboard Maestro macro as simple as this one:

Note, though, that this could be annoying: If you move or resize the window, then switch away and switch back, it'll go back to the old size and location :). You can get fancier so it only happens on launch, and much more (pass the size and location variables from KM, etc.), but that's the general idea.

Positions are in pixels from the top left corner; sizes are in pixels in width, height form.

-rob.

1 Like

Another vote for "my Stream Deck app always opens in its last position".

It's a "background only" app, so it's never the "front window of the front application" to KM. You can see that with the following:

tell application "System Events"
	delay 5
	return name of item 1 of (get every process whose frontmost is true)
end tell

...if you open the Stream Deck app during the 5 second delay (also, the application menu name doesn't change when the app is launched).

But you can explicitly target Stream Deck and move its window with a KM action:

image

That explicit targeting is a good trick to have up your sleeve, as it allows you to move another app's window in the background, without you losing your current focus.

1 Like

Your answers are always so accurate and so useful, that for the last two days I've been wondering if you are a pseudonym for the guy who created and maintains Keyboard maestro.

Ah, if only I were that smart, that handsome...

(And if that doesn't get me a free update to KM 12 when it's released, nothing will :wink: )

While I've only just had my 2nd KM anniversary*, joining this board to see if it was worth even downloading the KM trial**, I've learnt a lot from the "giants" of the forum in that time. So it's the friendly, helpful, knowledgable community here that deserves any praise that's being handed out -- not me.

* And that time includes a 9-month "forum-dark" period because of a nose to the grindstone work project
** I've known about KM for years, obvs, but only then got round to properly trying it out. And that is my loss -- all that time wasted by not automating simple things!

1 Like