# Maximizing window and back to the last size

**URL:** <https://community.folivora.ai/t/maximizing-window-and-back-to-the-last-size/24059>\
**Category:** Configuration Help & General Discussion\
**Tags:** trackpad\
**Created:** [September 20, 2021, 11:39pm UTC](https://community.folivora.ai/t/maximizing-window-and-back-to-the-last-size/24059 "2021-09-20T23:39:47Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Black\_Simorgh](https://community.folivora.ai/user_avatar/community.folivora.ai/black_simorgh/32/260_2.png) [@Black\_Simorgh](https://community.folivora.ai/u/Black_Simorgh)\
**Post date:** [September 20, 2021, 11:39pm UTC](https://community.folivora.ai/t/maximizing-window-and-back-to-the-last-size/24059/1 "2021-09-20T23:39:47Z")

</div>

Hi,  
I'm looking for an option to toggle between the maximum window size and the last size back and forth, with the same touch pattern on the trackpad.  
I already created a command to maximize my window, but if I choose the same touch pattern for the last size, I get a menu to choose from. I want it without the menu appearing.

Is this possible?  
Thanks

---

<div class="post-metadata">

**Author:** ![Black\_Simorgh](https://community.folivora.ai/user_avatar/community.folivora.ai/black_simorgh/32/260_2.png) [@Black\_Simorgh](https://community.folivora.ai/u/Black_Simorgh)\
**Post date:** [November 10, 2021, 11:37am UTC](https://community.folivora.ai/t/maximizing-window-and-back-to-the-last-size/24059/2 "2021-11-10T11:37:19Z")

</div>

Is there no one who can help me out?

---

<div class="post-metadata">

**Author:** ![TheBloke](https://community.folivora.ai/user_avatar/community.folivora.ai/thebloke/32/535_2.png) [@TheBloke](https://community.folivora.ai/u/TheBloke)\
**Post date:** [November 10, 2021, 6:03pm UTC](https://community.folivora.ai/t/maximizing-window-and-back-to-the-last-size/24059/3 "2021-11-10T18:03:37Z")

</div>

I had a look but couldn't immediately find any way to do this within the BTT UI.

I think you would have to write a script to do this. You would create two named triggers, one for the Maximise action, one for the Restore action.

Then your gesture trigger would run a script (AppleScript or Javascript). This script would check a BTT variable, eg "windowmax"; if it's 0 or not set, it executes the Maximise named trigger, and then sets windowmax = 1. If it's already 1, it runs the Restore named trigger, and sets windowmax = 0.

It would be nice if BTT supported conditional execution within the UI. A simple way would be for a new Trigger option that checks a BTT variable for a specific value, and only triggers the action(s) if the variable is set to that value.

Then it would be possible to do this via the UI, with no script needed. One would add the "Assign Value To Variable" actions to set the variable, and have the triggers check the value when deciding what to execute.

---

<div class="post-metadata">

**Author:** ![TheBloke](https://community.folivora.ai/user_avatar/community.folivora.ai/thebloke/32/535_2.png) [@TheBloke](https://community.folivora.ai/u/TheBloke)\
**Post date:** [November 12, 2021, 6:56pm UTC](https://community.folivora.ai/t/maximizing-window-and-back-to-the-last-size/24059/4 "2021-11-12T18:56:44Z")

</div>

@Black_Simorgh I noticed that another user asked this a while ago, and there's a forum post with an example script you can use, already written: [Cycling through custom areas - #7 by coolwhiff](https://community.folivora.ai/t/cycling-through-custom-areas/13745/7)

---

<div class="post-metadata">

**Author:** ![Black\_Simorgh](https://community.folivora.ai/user_avatar/community.folivora.ai/black_simorgh/32/260_2.png) [@Black\_Simorgh](https://community.folivora.ai/u/Black_Simorgh)\
**Post date:** [November 12, 2021, 8:56pm UTC](https://community.folivora.ai/t/maximizing-window-and-back-to-the-last-size/24059/5 "2021-11-12T20:56:43Z")

</div>

Hey,  
First of all, thanks for your help.  
I created two triggers for maximizing and restoring window sizes, but I have no clue about this script.  
I had to look it up to know that it is Javascript. 😅  
Do I have to modify the script to make it work?

---

<div class="post-metadata">

**Author:** ![TheBloke](https://community.folivora.ai/user_avatar/community.folivora.ai/thebloke/32/535_2.png) [@TheBloke](https://community.folivora.ai/u/TheBloke)\
**Post date:** [November 12, 2021, 9:01pm UTC](https://community.folivora.ai/t/maximizing-window-and-back-to-the-last-size/24059/6 "2021-11-12T21:01:06Z")

</div>

You should only need to change this bit:

```auto
cycleThrough([
  "leftHalf",
  "leftTwoThirds",
  "leftOneThird"
]);

```

Change it to:

```auto
cycleThrough([
  "name of maximize trigger",
  "name of restore trigger"
]);

```

Obviously put the correct names for your named triggers in those two middle lines.

Then you put the script in an "Run Real Javascript" action, Source Type: Real Javascript. If you scroll up in the thread I linked, you can see a screenshot from Andreas showing the action to use. (Your script will look different to his.)

---

<div class="post-metadata">

**Author:** ![Black\_Simorgh](https://community.folivora.ai/user_avatar/community.folivora.ai/black_simorgh/32/260_2.png) [@Black\_Simorgh](https://community.folivora.ai/u/Black_Simorgh)\
**Post date:** [November 12, 2021, 9:12pm UTC](https://community.folivora.ai/t/maximizing-window-and-back-to-the-last-size/24059/7 "2021-11-12T21:12:06Z")

</div>

Wow, thank you very much.  
It works like a charm. Now I have one less problem to worry about. 😅  
Thanks

---

<div class="post-metadata">

**Author:** ![TheBloke](https://community.folivora.ai/user_avatar/community.folivora.ai/thebloke/32/535_2.png) [@TheBloke](https://community.folivora.ai/u/TheBloke)\
**Post date:** [November 12, 2021, 9:40pm UTC](https://community.folivora.ai/t/maximizing-window-and-back-to-the-last-size/24059/8 "2021-11-12T21:40:49Z")

</div>

Glad it works. Thanks to @coolwhiff for writing the script!

---

<div class="post-metadata">

**Author:** ![npeippo](https://community.folivora.ai/user_avatar/community.folivora.ai/npeippo/32/22812_2.png) [@npeippo](https://community.folivora.ai/u/npeippo)\
**Post date:** [September 4, 2022, 12:16pm UTC](https://community.folivora.ai/t/maximizing-window-and-back-to-the-last-size/24059/9 "2022-09-04T12:16:41Z")

</div>

Damn, I'm really new to BTT and haven't really got any knowledge on JS, but with the examples from @TheBloke and @coolwhiff I managed to make the window title bar's green button to either maximize or return the original size of the window! Works perfectly. Thanks 🙂
