on setAssistWindowPosition(sender)
try
set p to 1
set newX to (current application's (NSScreen()'s mainScreen()'s visibleframe()'s origin()'s x)) + (current application's (NSScreen()'s mainScreen()'s visibleframe()'s |size|()'s width)) - (sender's frame()'s |size|()'s width) - 5
set p to 2
set newY to (current application's (NSScreen()'s mainScreen()'s visibleframe()'s origin()'s y)) + (current application's (NSScreen()'s mainScreen()'s visibleframe()'s |size|()'s height)) - (sender's frame()'s |size|()'s height) - 5
windowAssistiveAccess's setFrameOrigin:{newX as integer, newY as integer}
on error errmsg
display dialog "setAssistWindowPosition " & errmsg & "p=" & p
end try
end setAssistWindowPosition
but it returns an error ‘Can’t continue NSScreen’.
I’ve exhausted my knowledge, and tried everything I know of, so hopefully someone can set me straight, please.
Regards
Santa
Now I just need to figure out how to set the position of my advice window right next to the Assistive devices preferences window. Fun.
Hi Brian, again apologies for the lack of translation, but here's a cocoa method I use for doing just that.
This places the window upper top right, right underneath the spotlight/notificaitions menu bar icons. Adust it leftwards and downwards by increasing those two numbers -5 and -5 (by increase I really mean decrease, in a mathematical sense: eg. -100 and -100 will make it further left and further down!).
You then call the method on your window with something like
[myWindow setWindowPosition];
immediately after the line that tells the window to open.
- (void)setWindowPosition {
NSPoint pos;
pos.x = [[NSScreen mainScreen] visibleFrame].origin.x + [[NSScreen mainScreen] visibleFrame].size.width - [[self window] frame].size.width -5;
pos.y = [[NSScreen mainScreen] visibleFrame].origin.y + [[NSScreen mainScreen] visibleFrame].size.height - [[self window] frame].size.height -5 ;
[[self window] setFrameOrigin : pos];
}