Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

AppleScript not executing #622

Copy link
Copy link
Open
Open
Copy link
@greg1075

Description

@greg1075
Issue body actions

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.