Windows – set position {0,0} of element accessibillityTitle via Applescript

applescriptdialoguiwindows

I have a UI element called accessibillityTitle with value Layers and I want to position this element in the top right corner, but I don't know how to acces it via Applescript. I have found the element using Accessibility Inspector and here is what the rest looks like.

AXApplication
    AXWindow:AXDialog
Attributes
    isAccessibilityFocused  NO
    accessibilityTitle  Layers
    accessibilityGrowArea   <nil>
    accessibilityMinimizeButton <nil>
    accessibilityDocument   <nil>
    accessibilityCloseButton    <nil>
    isAccessibilityMain NO
    accessibilityFullScreenButton   <nil>
    accessibilityProxy  <nil>
    accessibilityDefaultButton  <nil>
    isAccessibilityMinimized    NO
    accessibilityChildren   10 items
    accessibilityRole   AXWindow
    accessibilityParent <AXApplication>
    accessibilityTitleUIElement <nil>
    accessibilityCancelButton   <nil>
    isAccessibilityModal    NO
    accessibilitySubrole    AXDialog
    accessibilityZoomButton <nil>
    accessibilityRoleDescription    dialog
    accessibilityToolbarButton  <nil>
    accessibilityFrame  x=1038.00 y=23.00 w=240.00 h=773.00
    accessibilityIdentifier com.pixelmatorteam.pixelmator.layers.palette
Actions
    accessibilityPerformRaise

How can I use set position to {1280, 0} to this element?

Best Answer

Actually I dealt with a similar case, when I wanted to move a previously generated dialog to the top-right corner of my screen.
I only succeeded in doing so thru a 2nd script that was launched simultaneously, but had a "repeat nothing until" loop built in to await the dialog's pop-up. In my experience, no matter what I tried, the dialog would hinder an "in-script moving" while its window stayed open ...
(I attached both to a folder: I just had to add #2 to its list.)

In script #1 the final command reads:

tell application "Finder" to display dialog DL_display as string with ¬
  title "Recent downloads" buttons {"Close"} default button 1

The 2nd one:

tell application "Finder"
    set screenRgt to bounds of the window of desktop  --> independent of
    set rightEdge to (item 3 of screenRgt) - 425      --> screen resolution
end tell
tell application "System Events" to tell process "Finder"
    repeat while not (exists window "Recent downloads")
    end repeat
    delay 0.1
    set position of window "Recent downloads" to {rightEdge, 61}
end tell

You can see there's a (minute) delay after "repeat-nothing". Even waiting 0.1s sometimes my MacMini's so busy that the delay's too short, and the dialog remains centered ...
(To make sure set a higher value, say: 0.5.)
My "Recent downloads" Workaround #2 for Safari can be found HERE.