Hello, Shahan,
The problem is I am using ScriptUI for a toolbar, not just ordinary expressions for things inside composition.
The window method “size.width” works fine and returns the current window width but it does not function with contained elements like group.
I found a temporary solution but it is a bad code. I just get the window width and substract some number calculated in advance so that I have the number close to width on the element I need. It does work fine with modern AE but not with older versions (f.e. CS4).
ExtendScript looks terribly poor and undeveloped. I am starting to believe that there is no good way to get the current width of UI elements.