Maximise Window from applescript?

605 views
Skip to first unread message

Rob Russell

unread,
Apr 13, 2021, 5:33:30 PM4/13/21
to BBEdit Talk
Hi,

Just trying to adapt a distraction free script I found on this list and am looking for a way to toggle the BBEdit Window to Full Screen - you know, when you click on the little green dot in the top left of the window, or hit escape to pop-out of that mode.

The zoomed property in A/S seems to refer to the natural size of the window as defined by Window->Save Default Text/Project Window, which is not what I'm looking for here.

Any hints, anyone?

Thanks

Rob

Nestor Aguilera

unread,
Apr 13, 2021, 6:15:29 PM4/13/21
to BBEdit Talk
Googling "applescript maximize current window" I found <https://gist.github.com/FranciscoG/4a94fca5fb452f2a7dda> which seems close to what you want. You may put it with other BBEdit scripts (chapter 13 of user manual) and assign a shortcut to it (p. 25 of manual).

Best,

Nestor

===============================================

>
> --
> This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
> ---
> You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/88311f8e-6eac-48ec-b560-bd254746dc06n%40googlegroups.com.

Rob Russell

unread,
Apr 13, 2021, 7:41:03 PM4/13/21
to BBEdit Talk
Thanks for that. I think the syntax is suitable for Mavericks. I certainly couldn't get that going, even after opening up security permissions. It seems that system events should be able to set the state of the zoomed property of the given window, though the syntax is opaque to me.

r

Nestor Aguilera

unread,
Apr 13, 2021, 8:03:56 PM4/13/21
to bbe...@googlegroups.com
Hi Rob,

> On 13 Apr 2021, at 20:16, Rob Russell <sum...@gmail.com> wrote:
>
> Thanks for that. I think the syntax is suitable for Mavericks. I certainly couldn't get that going, even after opening up security permissions. It seems that system events should be able to set the state of the zoomed property of the given window, though the syntax is opaque to me.
>
> r

Sorry for that, I should have tried it myself.

This one seems to work for me with BBEdit and Mojave:

#----------------------------------------------
tell application "System Events" to tell (process 1 where frontmost is true)
click button 2 of window 1
end tell
activate application (path to frontmost application as text)
#----------------------------------------------

Hope it works for you too.

Regards,

Nestor

===============================================

>
> On Wednesday, 14 April 2021 at 10:15:29 UTC+12 Nestor Aguilera wrote:
>
>
> > On 13 Apr 2021, at 18:32, Rob Russell <sum...@gmail.com> wrote:
> >
> > Hi,
> >
> > Just trying to adapt a distraction free script I found on this list and am looking for a way to toggle the BBEdit Window to Full Screen - you know, when you click on the little green dot in the top left of the window, or hit escape to pop-out of that mode.
> >
> > The zoomed property in A/S seems to refer to the natural size of the window as defined by Window->Save Default Text/Project Window, which is not what I'm looking for here.
> >
> > Any hints, anyone?
> >
> > Thanks
> >
> > Rob
>
> Googling "applescript maximize current window" I found <https://gist.github.com/FranciscoG/4a94fca5fb452f2a7dda> which seems close to what you want. You may put it with other BBEdit scripts (chapter 13 of user manual) and assign a shortcut to it (p. 25 of manual).
>
> Best,
>
> Nestor
>
> ===============================================
>
> >
> > --
> > This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
> > ---
> > You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.
> > To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/88311f8e-6eac-48ec-b560-bd254746dc06n%40googlegroups.com.
>
>
> --
> This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
> ---
> You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/7f6965eb-3f00-4384-8c5b-9dc545145e85n%40googlegroups.com.

jj

unread,
Apr 14, 2021, 4:31:24 AM4/14/21
to BBEdit Talk
Hi Rob,

This AppleScript seems to do the trick.

    ```applescript
    use AppleScript version "2.7"
    use scripting additions
    tell application "BBEdit"
        activate
        tell application "System Events"
            try
                tell process "BBEdit"
                    set frontmost to true
                    click menu item "Enter Full Screen" of menu "View" of menu bar item "View" of menu bar 1
                end tell
            on error aMessage
                display dialog aMessage
            end try
        end tell
    
    end tell
    ```

HTH,

Jean Jourdain

Rob Russell

unread,
Apr 14, 2021, 6:39:23 PM4/14/21
to BBEdit Talk
Thanks Jean,

I don't know how many times I looked at the Window and view menus, and never saw "Enter Full Screen" 😳 

so my toggle distraction mode script now looks like:

tell application "BBEdit"
activate
try
set win to text window 1
tell win
set show gutter to (not show gutter)
set show navigation bar to (not show navigation bar)
set sidebar visible to (not sidebar visible)
set show line numbers to (not show line numbers)
tell application "System Events"
tell process "BBEdit"
set frontmost to true  -- is this redundant?
try
click menu item "Enter Full Screen" of menu "View" of menu bar item "View" of menu bar 1
on error
click menu item "Exit Full Screen" of menu "View" of menu bar item "View" of menu bar 1
end try
end tell
end tell
end tell
on error str
display alert str
end try
end tell

save that script to my FastScripts folder, give it a shortcut ctrl-shift-option-D and it works a treat.

Thanks all.

Rob



Reply all
Reply to author
Forward
0 new messages