CrossOver Support - Community Forums

Important Information These are community forums and not official technical support. If you need official support: Contact Us

CrossOver Mac
Discussion about CrossOver Mac

The following comments are owned by whoever posted them. We are not responsible for them in any way.

Back to Threads Reply to Thread

Resize window of application

I am trying to resize the window of an application using applescript but not being very profecient I am not having any luck;

Here is what I have tried but get errors:

The application RootsMagic starts and runs fine
I do the delay to wait for RM to be fully loaded
I get the following error message when the script gets to the set bounds of window statement

error "Can’t get window 1 of {\"Macintosh HD:Applications:RootsMagic.app:\"}." number -1728 from window 1 of {"Macintosh HD:Applications:RootsMagic.app:"}

tell application "RootsMagic" to activate
delay 10.1

set the_application to {path to frontmost application as Unicode text}
tell the_application
set bounds of window 1 to {1, 1, 1281, 721}
end tell

Any suggestions or help would be appreciated
Thanks
Roger

I've never used AppleScript myself, so I can only offer guesswork. A possible cause of the problem is that "RootsMagic.app" is only a dummy application placeholder, and I think CrossOver.app is the application bundle that creates the Windows as far as OSX is concerned. I'll point Ken to this discussion, maybe he has some ideas.

Hi,

It looks like your script is incorrect. The expression:
path to frontmost application as Unicode text
will produce a string/text object. Surrounding that in curly braces creates a list object with a single element being that string.

You are then trying to "tell" that list object to get its "window 1" element, but list objects have no such elements. Neither would the string object. That's the source of the error you're seeing. Things haven't proceeded to try to set the bounds and you're not addressing the RootsMagic application (except for the activate command).

For the most part, our launcher mini-applications aren't very scriptable. You can work around that by using the System Events suite, which works using the Accessibility API. The system will prompt you for permission to use the Accessibility API. So, you can do something like this:

tell application "System Events"
    set theWindow to front window of application process "RootsMagic"
    set position of theWindow to {1, 1}
    set size of theWindow to {1281, 721}
end tell

(Although the system won't really let you move the window to {1, 1}, since that would put its title bar behind the menu bar. I would recommend setting the Y component to at least 22.)

Out of curiosity, what version of CrossOver are you using and why do you want to script the positioning of the window? Is it because the window comes up filling the screen on every launch? If so, the issue is probably that RootsMagic set its window to be "maximized" the first time it ran and has remembered that setting ever since. Maximizing windows is a Windows thing that doesn't really map properly to the way things work on OS X. Depending on the version of CrossOver, you may or may not be able to move and resize the window when it's maximized. Prior to CrossOver 14, you would be able to move and resize the window, but that didn't technically change whether it was maximized. As a result, RootsMagic would continue to think it needs to maximize the window on launch. Since CrossOver 14, we enforce maximization by preventing moving or resizing the window. You can "unmaximize" the window by selecting Zoom from the Window menu or Option-clicking the green plus button in the window's title bar. (Prior to Yosemite, it wasn't necessary to hold down the Option key, but Apple changed the behavior of that button.) Once you unmaximize it, you'll be able to move and resize it as normal. Furthermore, RootsMagic should remember that it's no longer maximized and its last position, so that it will come up in the same place on next launch.

Please Note: This Forum is for non-application specific questions relating to installation/configuration of CrossOver. All application-specific posts to this Forum will be moved to their appropriate Compatibility Center Forum.

CrossOver Forums: the place to discuss running Windows applications on Mac and Linux

CodeWeavers or its third-party tools process personal data (e.g. browsing data or IP addresses) and use cookies or other identifiers, which are necessary for its functioning and required to achieve the purposes illustrated in our Privacy Policy. You accept the use of cookies or other identifiers by clicking the Acknowledge button.
Please Wait...
eyJjb3VudHJ5IjoiVVMiLCJsYW5nIjoiZW4iLCJjYXJ0IjowLCJ0enMiOi01LCJjZG4iOiJodHRwczpcL1wvbWVkaWEuY29kZXdlYXZlcnMuY29tXC9wdWJcL2Nyb3Nzb3Zlclwvd2Vic2l0ZSIsImNkbnRzIjoxNzA4NjEzODE4LCJjc3JmX3Rva2VuIjoiYW5jcDZHaGJUSGZCZXg0NCIsImdkcHIiOjB9