I have a button that when clicked opens my “MAIN” window up by 250 pixels to the right (see code below). All works fine. However, when I have the program QuarkXpress open and I click on this same button in my program the window opens upward as well as to the right and it appears not by 250 pixels but by less than 250 pixels. Weirdness. Is there a more bullet proof way to have a window resize by 250 pixel to the right by clicking on a button.
Any suggestions would be greatly appreciated,
CarbonQuark
set MY_WINDOW_BOUNDS to bounds of window "MAIN"
tell window "MAIN" to set bounds to {(item 1 of MY_WINDOW_BOUNDS), (item 2 of MY_WINDOW_BOUNDS), (item 3 of MY_WINDOW_BOUNDS) + 250, (item 4 of MY_WINDOW_BOUNDS)}
there is a known problem with setting window bounds when Quark’s Scripting Addition is installed. Try to remove ‘QXPScriptingAdditions.osax’ from /Library/ScriptingAdditions/ or ~/Library/ScriptingAdditions/.
I removed Quark’s scripting addition and the problem went away. Unfortunately, the program that I am writing is for Quark and I plan on distributing it to the masses. I don’t want to ask my end users to remove this from their library.
If anyone has a way around this problem any information would be greatly appreciated.
ARGH! I usually love a good problem… but this one has me stumped. If anyone has any suggestions they would be greatly appreciated. There has to be another way to resize a window other than setting it with bounds.
I have everything named properly - window is named “window” and my button is tied to my script. However, when I click my button nothing happens not even an error.
Not sure what I am doing wrong. Do I need to inculde additional code? Any help would be greatly appreciated.
Thanks,
CarbonQuark
on clicked theObject
my resizewindow(500)
end clicked
on resizewindow(windowheight)
-- Get current window position
set thePosition to position of window "window"
-- Get current window size
set theSize to size of window "window"
-- Determine position of top left corner / bottom left corner + window height
set bottompos to item 2 of thePosition
set topPos to bottompos + (item 2 of theSize)
set leftPos to item 1 of thePosition
-- Calculate the difference between the old window height and new window height
set newheight to windowheight - (item 2 of theSize)
-- Calculate previous bottom left +/- difference in windows
set newbottompos to (bottompos - newheight)
-- Resize window to new size
-- Resize the window to fit the contents
set ThisWindow to window "window"
call method "resize:withFrame:" of class "ResizeWind" with parameters {ThisWindow, {leftPos, newbottompos, 504, windowheight}}
end resizewindow
you can simply call the NSWindow method directly from AppleScript - there is no need for extra files …
set x to 100 -- x position
set y to 200 -- y position
set w to 300 -- width
set h to 400 -- height
call method "setFrame:display:animate:" of (window "main") with parameters {{x, y, x + w, y + h}, true, true}
-- or - if you don't want the animation:
-- call method "setFrame:display:animate:" of (window "main") with parameters {{x, y, x + w, y + h}, true, false}