KeyboardCowboy icon indicating copy to clipboard operation
KeyboardCowboy copied to clipboard

AppleScript not executing

Open greg1075 opened this issue 8 months ago • 2 comments

Hi there and thanks for all the work on Keyboard Cowboy - fantastic app!

I've figured out how to center a window using KC's built-in window management, but not how to resize to custom dimensions. Is that currently possibly natively?

If not, I have this AppleScript which works fine when triggered in Script Editor, but not in Keyboard Cowboy. I have it running concurrently with the Center Window command, but it's not resizing. What am I missing?

Here is the script:

-- Desired size
set desiredWidth to 1350
set desiredHeight to 840

-- Get screen dimensions
tell application "Finder"
	set screenBounds to bounds of window of desktop
	set screenWidth to item 3 of screenBounds
	set screenHeight to item 4 of screenBounds
end tell

-- Calculate center position
set posX to (screenWidth - desiredWidth) / 2
set posY to (screenHeight - desiredHeight) / 2

-- Resize and move the frontmost window
tell application "System Events"
	set frontApp to name of first application process whose frontmost is true
	tell application process frontApp
		try
			set size of front window to {desiredWidth, desiredHeight}
			set position of front window to {posX, posY}
		on error errMsg
			display dialog "Error: " & errMsg
		end try
	end tell
end tell

Thank you

greg1075 avatar Apr 13 '25 14:04 greg1075

Please disregard the AppleScript execution problem. It was a permission issue.

Please let me know if resizing to custom dimensions is possible natively though, please.

Thanks!

greg1075 avatar Apr 13 '25 21:04 greg1075

Hey @greg1075, so right now, custom dimensions aren't supported. It just makes the apps stick to the corners of the screen. I've been thinking about rewriting some of these commands, but I haven't because I don't use them myself.

My workflow is pretty much based on macOS Sequoia's built-in window tiling and Loop.

https://github.com/MrKai77/Loop

Keyboard Cowboy and Loop can make a really cool setup.

zenangst avatar May 29 '25 11:05 zenangst