[COLOR="Gray"]-- détermine la zone d'affichage[/COLOR]
[COLOR="Gray"][COLOR="Black"][B]set[/B] [/COLOR][COLOR="Green"]hauteurMenu[/COLOR] [COLOR="Black"][B]to[/B] 22 [/COLOR]-- hauteur supposée de la barre de menu[/COLOR]
[COLOR="Black"][B]tell[/B] [COLOR="Blue"][I]application[/I][/COLOR] "Finder"[/COLOR]
[COLOR="Black"][B]set[/B] [COLOR="Green"]tailleEcran[/COLOR] [B]to[/B] [COLOR="Purple"]bounds[/COLOR] [B]of[/B] [COLOR="Blue"][I]window[/I][/COLOR] [B]of[/B] [COLOR="Purple"]desktop[/COLOR][/COLOR]
[COLOR="Green"][COLOR="Black"][B]set[/B] [/COLOR]largeur [COLOR="Black"][B]to[/B] [/COLOR][COLOR="Blue"][I]item[/I][/COLOR] [COLOR="Black"]3 [B]of[/B] [/COLOR]tailleEcran[/COLOR]
[COLOR="Green"][COLOR="Black"][B]set[/B] [/COLOR]hauteur [COLOR="Black"][B]to[/B] ([/COLOR][COLOR="Blue"][I]item[/I][/COLOR] [COLOR="Black"]4 [B]of[/B] [/COLOR]tailleEcran[COLOR="Black"]) - [/COLOR]hauteurMenu[/COLOR]
[COLOR="Black"][B]end[/B] [B]tell[/B][/COLOR]
[COLOR="Black"][B]set[/B] [COLOR="Green"]gauche[/COLOR] [B]to[/B] 0[/COLOR]
[COLOR="Black"][B]tell[/B] [COLOR="Blue"][I]application[/I][/COLOR] "System Events"[/COLOR]
[COLOR="Gray"]-- retire le Dock de la zone d'affichage[/COLOR]
[COLOR="Purple"][COLOR="Black"][B]tell[/B] [/COLOR]dock preferences[/COLOR]
[COLOR="Black"][B]set[/B] [COLOR="Green"]masqueAuto[/COLOR] [B]to[/B] [COLOR="Purple"]autohide[/COLOR] [B]as[/B] [COLOR="Blue"][I]boolean[/I][/COLOR][/COLOR]
[COLOR="Black"][B]set[/B] [COLOR="Green"]positionDock[/COLOR] [B]to[/B] [COLOR="Purple"]screen edge[/COLOR] [B]as[/B] [COLOR="Blue"][I]string[/I][/COLOR][/COLOR]
[COLOR="Black"][B]end[/B] [B]tell[/B][/COLOR]
[COLOR="Black"][B]if[/B] [B]not[/B] ([COLOR="Green"]masqueAuto[/COLOR]) [B]then[/B][/COLOR]
[COLOR="Black"][B]tell[/B] [COLOR="Blue"][I]process[/I][/COLOR] "Dock"[/COLOR]
[COLOR="Black"][B]set[/B] [COLOR="Green"]tailleDock[/COLOR] [B]to[/B] [COLOR="Purple"]size[/COLOR] [B]in[/B] [COLOR="Blue"][I]list[/I][/COLOR] 1[/COLOR]
[COLOR="Green"][COLOR="Black"][B]set[/B] [/COLOR]largeurDock [COLOR="Black"][B]to[/B] [/COLOR][COLOR="Blue"][I]item[/I][/COLOR] [COLOR="Black"]1 [B]of[/B] [/COLOR]tailleDock[/COLOR]
[COLOR="Green"][COLOR="Black"][B]set[/B] [/COLOR]hauteurDock [COLOR="Black"][B]to[/B] [/COLOR][COLOR="Blue"][I]item[/I][/COLOR] [COLOR="Black"]2 [B]of[/B] [/COLOR]tailleDock[/COLOR]
[COLOR="Black"][B]end[/B] [B]tell[/B][/COLOR]
[COLOR="Black"][B]if[/B] [COLOR="Green"]positionDock[/COLOR] = "bottom" [B]then[/B][/COLOR]
[COLOR="Green"][COLOR="Black"][B]set[/B] [/COLOR]hauteur [COLOR="Black"][B]to[/B] [/COLOR]hauteur [COLOR="Black"]- [/COLOR]hauteurDock[/COLOR]
[COLOR="Black"][B]else[/B][/COLOR]
[COLOR="Green"][COLOR="Black"][B]set[/B] [/COLOR]largeur [COLOR="Black"][B]to[/B] [/COLOR]largeur [COLOR="Black"]- [/COLOR]largeurDock[/COLOR]
[COLOR="Black"][B]if[/B] [COLOR="Green"]positionDock[/COLOR] = "left" [B]then[/B] [B]set[/B] [COLOR="Green"]gauche[/COLOR] [B]to[/B] [COLOR="Green"]largeurDock[/COLOR][/COLOR]
[COLOR="Black"][B]end[/B] [B]if[/B][/COLOR]
[COLOR="Black"][B]end[/B] [B]if[/B][/COLOR]
[COLOR="Gray"]-- dresse la liste des applications[/COLOR]
[COLOR="Black"][B]set[/B] [COLOR="Green"]listeApplis[/COLOR] [B]to[/B] [COLOR="Purple"]name[/COLOR] [B]of[/B] [COLOR="Blue"][I]processes[/I][/COLOR] [B]where[/B] [COLOR="Purple"]visible[/COLOR] [B]is[/B] [COLOR="Indigo"]true[/COLOR][/COLOR]
[COLOR="Black"][B]end[/B] [B]tell[/B][/COLOR]
[COLOR="Gray"]-- dresse la liste des fenêtres[/COLOR]
[COLOR="Green"][COLOR="Black"][B]set[/B] [/COLOR]listeFenetres [COLOR="Black"][B]to[/B] {}[/COLOR][/COLOR]
[COLOR="Black"][B]repeat[/B] [B]with[/B] [COLOR="Green"]appli[/COLOR] [B]in[/B] [COLOR="Green"]listeApplis[/COLOR][/COLOR]
[COLOR="Black"][B]try[/B][/COLOR]
[COLOR="Blue"][COLOR="Black"][B]tell[/B] [/COLOR][I]application[/I] [COLOR="Black"][/COLOR][COLOR="Green"]appli[/COLOR][/COLOR]
[COLOR="Black"][B]set[/B] [COLOR="Green"]numFenetre[/COLOR] [B]to[/B] 1[/COLOR]
[COLOR="Black"][B]repeat[/B] [B]with[/B] [COLOR="Green"]fenetreAppli[/COLOR] [B]in[/B] ([B]every[/B] [COLOR="Blue"][I]window[/I][/COLOR] [B]where[/B] [COLOR="Purple"]visible[/COLOR] [B]is[/B] [COLOR="Indigo"]true[/COLOR])[/COLOR]
[COLOR="Green"][COLOR="Black"][B]set[/B] [/COLOR]rectFenetre [COLOR="Black"][B]to[/B] [/COLOR][COLOR="Purple"]bounds[/COLOR] [COLOR="Black"][B]of[/B] [/COLOR]fenetreAppli[/COLOR]
[COLOR="Black"][B]set[/B] [COLOR="Green"]x[/COLOR] [B]to[/B] ([COLOR="Blue"][I]item[/I][/COLOR] 1 [B]of[/B] [COLOR="Green"]rectFenetre[/COLOR]) + ([COLOR="Blue"][I]item[/I][/COLOR] 3 [B]of[/B] [COLOR="Green"]rectFenetre[/COLOR]) / 2[/COLOR]
[COLOR="Black"][B]set[/B] [COLOR="Green"]y[/COLOR] [B]to[/B] ([COLOR="Blue"][I]item[/I][/COLOR] 2 [B]of[/B] [COLOR="Green"]rectFenetre[/COLOR]) + ([COLOR="Blue"][I]item[/I][/COLOR] 4 [B]of[/B] [COLOR="Green"]rectFenetre[/COLOR]) / 2[/COLOR]
[COLOR="Black"][B]set[/B] [COLOR="Green"]critereTri[/COLOR] [B]to[/B] [COLOR="Green"]x[/COLOR] + 17 * [COLOR="Green"]y[/COLOR][/COLOR]
[COLOR="Green"][COLOR="Black"][B]set[/B] [/COLOR]listeFenetres [COLOR="Black"][B]to[/B] [/COLOR]listeFenetres [COLOR="Black"]& {{[/COLOR]critereTri[COLOR="Black"], [/COLOR][COLOR="Purple"]name[/COLOR][COLOR="Black"], [/COLOR]numFenetre[COLOR="Black"]}}[/COLOR][/COLOR]
[COLOR="Green"][COLOR="Black"][B]set[/B] [/COLOR]numFenetre [COLOR="Black"][B]to[/B] [/COLOR]numFenetre [COLOR="Black"]+ 1[/COLOR][/COLOR]
[COLOR="Black"][B]end[/B] [B]repeat[/B][/COLOR]
[COLOR="Black"][B]end[/B] [B]tell[/B][/COLOR]
[COLOR="Black"][B]end[/B] [B]try[/B][/COLOR]
[COLOR="Black"][B]end[/B] [B]repeat[/B][/COLOR]
[COLOR="Green"][COLOR="Black"][B]set[/B] [/COLOR]nbFenetres [COLOR="Black"][B]to[/B] [/COLOR][COLOR="Blue"][B]count[/B][/COLOR] [COLOR="Black"][B]of[/B] [/COLOR]listeFenetres[/COLOR]
[COLOR="Black"][B]if[/B] [COLOR="Green"]nbFenetres[/COLOR] = 0 [B]then[/B] [COLOR="Blue"][B]quit[/B][/COLOR][/COLOR]
[COLOR="Gray"]-- trie les fenêtres d'après leur position actuelle[/COLOR]
[COLOR="Black"][B]repeat[/B] [B]with[/B] [COLOR="Green"]i[/COLOR] [B]from[/B] 1 [B]to[/B] [COLOR="Green"]nbFenetres[/COLOR] - 1[/COLOR]
[COLOR="Black"][B]repeat[/B] [B]with[/B] [COLOR="Green"]j[/COLOR] [B]from[/B] [COLOR="Green"]i[/COLOR] + 1 [B]to[/B] [COLOR="Green"]nbFenetres[/COLOR][/COLOR]
[COLOR="Black"][B]if[/B] [COLOR="Blue"][I]item[/I][/COLOR] 1 [B]of[/B] ([COLOR="Blue"][I]item[/I][/COLOR] [COLOR="Green"]i[/COLOR] [B]of[/B] [COLOR="Green"]listeFenetres[/COLOR]) > [COLOR="Blue"][I]item[/I][/COLOR] 1 [B]of[/B] ([COLOR="Blue"][I]item[/I][/COLOR] [COLOR="Green"]j[/COLOR] [B]of[/B] [COLOR="Green"]listeFenetres[/COLOR]) [B]then[/B][/COLOR]
[COLOR="Green"][COLOR="Black"][B]set[/B] [/COLOR]temp [COLOR="Black"][B]to[/B] [/COLOR][COLOR="Blue"][I]item[/I][/COLOR] [COLOR="Black"][/COLOR]i [COLOR="Black"][B]of[/B] [/COLOR]listeFenetres[/COLOR]
[COLOR="Green"][COLOR="Black"][B]set[/B] [/COLOR][COLOR="Blue"][I]item[/I][/COLOR] [COLOR="Black"][/COLOR]i [COLOR="Black"][B]of[/B] [/COLOR]listeFenetres [COLOR="Black"][B]to[/B] [/COLOR][COLOR="Blue"][I]item[/I][/COLOR] [COLOR="Black"][/COLOR]j [COLOR="Black"][B]of[/B] [/COLOR]listeFenetres[/COLOR]
[COLOR="Green"][COLOR="Black"][B]set[/B] [/COLOR][COLOR="Blue"][I]item[/I][/COLOR] [COLOR="Black"][/COLOR]j [COLOR="Black"][B]of[/B] [/COLOR]listeFenetres [COLOR="Black"][B]to[/B] [/COLOR]temp[/COLOR]
[COLOR="Black"][B]end[/B] [B]if[/B][/COLOR]
[COLOR="Black"][B]end[/B] [B]repeat[/B][/COLOR]
[COLOR="Black"][B]end[/B] [B]repeat[/B][/COLOR]
[COLOR="Gray"]-- calcule la mise en page[/COLOR]
[COLOR="Green"][COLOR="Black"][B]set[/B] [/COLOR]nbColonnesNormales [COLOR="Black"][B]to[/B] [/COLOR][COLOR="Navy"][B]round[/B][/COLOR] [COLOR="Black"](([/COLOR]nbFenetres [COLOR="Black"]* [/COLOR]largeur [COLOR="Black"]/ [/COLOR]hauteur[COLOR="Black"] / 1.4) ^ 0.5) [/COLOR][COLOR="Navy"]rounding[/COLOR] [COLOR="Black"][/COLOR][COLOR="DarkSlateBlue"]up[/COLOR][/COLOR]
[COLOR="Green"][COLOR="Black"][B]set[/B] [/COLOR]nbLignesNormales [COLOR="Black"][B]to[/B] [/COLOR][COLOR="Navy"][B]round[/B][/COLOR] [COLOR="Black"]([/COLOR]nbFenetres [COLOR="Black"]/ [/COLOR]nbColonnesNormales[COLOR="Black"]) [/COLOR][COLOR="Navy"]rounding[/COLOR] [COLOR="Black"][/COLOR][COLOR="DarkSlateBlue"]down[/COLOR][/COLOR]
[COLOR="Green"][COLOR="Black"][B]set[/B] [/COLOR]nbFenetresNormales [COLOR="Black"][B]to[/B] [/COLOR]nbColonnesNormales [COLOR="Black"]* [/COLOR]nbLignesNormales[/COLOR]
[COLOR="Green"][COLOR="Black"][B]set[/B] [/COLOR]largeurFenetresNormales [COLOR="Black"][B]to[/B] [/COLOR][COLOR="Navy"][B]round[/B][/COLOR] [COLOR="Black"]([/COLOR]largeur [COLOR="Black"]/ [/COLOR]nbColonnesNormales[COLOR="Black"]) [/COLOR][COLOR="Navy"]rounding[/COLOR] [COLOR="Black"][/COLOR][COLOR="DarkSlateBlue"]down[/COLOR][/COLOR]
[COLOR="Green"][COLOR="Black"][B]set[/B] [/COLOR]nbColonnesDerniereLigne [COLOR="Black"][B]to[/B] [/COLOR]nbFenetres [COLOR="Black"]- [/COLOR]nbFenetresNormales[/COLOR]
[COLOR="Green"][COLOR="Black"][B]if[/B] [/COLOR]nbColonnesDerniereLigne [COLOR="Black"]> 0 [B]then[/B][/COLOR][/COLOR]
[COLOR="Green"][COLOR="Black"][B]set[/B] [/COLOR]largeurDernieresFenetres [COLOR="Black"][B]to[/B] [/COLOR][COLOR="Navy"][B]round[/B][/COLOR] [COLOR="Black"]([/COLOR]largeur [COLOR="Black"]/ [/COLOR]nbColonnesDerniereLigne[COLOR="Black"]) [/COLOR][COLOR="Navy"]rounding[/COLOR] [COLOR="Black"][/COLOR][COLOR="DarkSlateBlue"]down[/COLOR][/COLOR]
[COLOR="Green"][COLOR="Black"][B]set[/B] [/COLOR]hauteurFenetres [COLOR="Black"][B]to[/B] [/COLOR][COLOR="Navy"][B]round[/B][/COLOR] [COLOR="Black"]([/COLOR]hauteur [COLOR="Black"]/ ([/COLOR]nbLignesNormales [COLOR="Black"]+ 1)) [/COLOR][COLOR="Navy"]rounding[/COLOR] [COLOR="Black"][/COLOR][COLOR="DarkSlateBlue"]down[/COLOR][/COLOR]
[COLOR="Black"][B]else[/B][/COLOR]
[COLOR="Green"][COLOR="Black"][B]set[/B] [/COLOR]hauteurFenetres [COLOR="Black"][B]to[/B] [/COLOR][COLOR="Navy"][B]round[/B][/COLOR] [COLOR="Black"]([/COLOR]hauteur [COLOR="Black"]/ [/COLOR]nbLignesNormales[COLOR="Black"]) [/COLOR][COLOR="Navy"]rounding[/COLOR] [COLOR="Black"][/COLOR][COLOR="DarkSlateBlue"]down[/COLOR][/COLOR]
[COLOR="Black"][B]end[/B] [B]if[/B][/COLOR]
[COLOR="Gray"]-- redimensionne et déplace les fenêtres[/COLOR]
[COLOR="Green"][COLOR="Black"][B]set[/B] [/COLOR]indexFenetre [COLOR="Black"][B]to[/B] 0[/COLOR][/COLOR]
[COLOR="Green"][COLOR="Black"][B]repeat[/B] [B]with[/B] [/COLOR]fenetre [COLOR="Black"][B]in[/B] [/COLOR]listeFenetres[/COLOR]
[COLOR="Green"][COLOR="Black"][B]if[/B] [/COLOR]indexFenetre [COLOR="Black"]< [/COLOR]nbFenetresNormales [COLOR="Black"][B]then[/B][/COLOR][/COLOR]
[COLOR="Green"][COLOR="Black"][B]set[/B] [/COLOR]x1 [COLOR="Black"][B]to[/B] [/COLOR]gauche [COLOR="Black"]+ ([/COLOR]indexFenetre [COLOR="Black"][B]mod[/B] [/COLOR]nbColonnesNormales[COLOR="Black"]) * [/COLOR]largeurFenetresNormales[/COLOR]
[COLOR="Green"][COLOR="Black"][B]set[/B] [/COLOR]x2 [COLOR="Black"][B]to[/B] [/COLOR]x1 [COLOR="Black"]+ [/COLOR]largeurFenetresNormales[/COLOR]
[COLOR="Black"][B]else[/B][/COLOR]
[COLOR="Green"][COLOR="Black"][B]set[/B] [/COLOR]x1 [COLOR="Black"][B]to[/B] [/COLOR]gauche [COLOR="Black"]+ ([/COLOR]indexFenetre [COLOR="Black"][B]mod[/B] [/COLOR]nbColonnesNormales[COLOR="Black"]) * [/COLOR]largeurDernieresFenetres[/COLOR]
[COLOR="Green"][COLOR="Black"][B]set[/B] [/COLOR]x2 [COLOR="Black"][B]to[/B] [/COLOR]x1 [COLOR="Black"]+ [/COLOR]largeurDernieresFenetres[/COLOR]
[COLOR="Black"][B]end[/B] [B]if[/B][/COLOR]
[COLOR="Green"][COLOR="Black"][B]set[/B] [/COLOR]y1 [COLOR="Black"][B]to[/B] [/COLOR]hauteurMenu [COLOR="Black"]+ ([/COLOR][COLOR="Navy"][B]round[/B][/COLOR] [COLOR="Black"]([/COLOR]indexFenetre [COLOR="Black"]/ [/COLOR]nbColonnesNormales[COLOR="Black"]) [/COLOR][COLOR="Navy"]rounding[/COLOR] [COLOR="Black"][/COLOR][COLOR="DarkSlateBlue"]down[/COLOR][COLOR="Black"]) * [/COLOR]hauteurFenetres[/COLOR]
[COLOR="Green"][COLOR="Black"][B]set[/B] [/COLOR]y2 [COLOR="Black"][B]to[/B] [/COLOR]y1 [COLOR="Black"]+ [/COLOR]hauteurFenetres[/COLOR]
[COLOR="Black"][B]try[/B][/COLOR]
[COLOR="Black"][B]tell[/B] [COLOR="Blue"][I]application[/I][/COLOR] ([COLOR="Blue"][I]item[/I][/COLOR] 2 [B]of[/B] [COLOR="Green"]fenetre[/COLOR]) [B]to[/B] [B]set[/B] [COLOR="Purple"]bounds[/COLOR] [B]of[/B] [COLOR="Blue"][I]window[/I][/COLOR] ([COLOR="Blue"][I]item[/I][/COLOR] 3 [B]of[/B] [COLOR="Green"]fenetre[/COLOR]) [B]to[/B] {[COLOR="Green"]x1[/COLOR], [COLOR="Green"]y1[/COLOR], [COLOR="Green"]x2[/COLOR], [COLOR="Green"]y2[/COLOR]}[/COLOR]
[COLOR="Black"][B]end[/B] [B]try[/B][/COLOR]
[COLOR="Green"][COLOR="Black"][B]set[/B] [/COLOR]indexFenetre [COLOR="Black"][B]to[/B] [/COLOR]indexFenetre [COLOR="Black"]+ 1[/COLOR][/COLOR]
[COLOR="Black"][B]end[/B] [B]repeat[/B][/COLOR]