Le 25/10/2014 à 23:16, Robert Poland < email@hidden> a écrit :
Hi,
Now that Yosemite screwed with the green button, how do I "click" in Applescript using Option down?
TIA,
Robert Poland
Hello Robert
(1) the green button is not screwed. It does exactly what it is designed to achieve: - activate full screen if it's clicked with no modifier - maximize the window if it's clicked with option depressed.
System Events doesn't offer the ability to define a modifier when we click an item. Happily, we may use ASObjC Runner
activate application "Finder" tell application "System Events" to tell process "Finder" tell window 1 set buttonPos to position of button 2 end tell tell application "ASObjC Runner" to click button once at buttonPos holding down {option} end tell end
We may achieve the same goal without ASObjC Runner. We just need to trigger the menu item dedicated to this task in the Windows menu. In French it's named Réduire/agrandir It's the second item displayed in the menu but its index is 3.
activate application "Finder" delay 0.2 # delay required tell application "System Events" to tell process "Finder" tell menu bar 1 to tell menu bar item 7 to tell menu 1 # name of menu items --> {"Placer dans le Dock", "Placer toutes les fenêtres dans le Dock", "Réduire/agrandir", "Réduire/agrandir toutes les fenêtres", "Faire défiler les fenêtres", missing value, "Afficher l’onglet précédent", "Afficher l’onglet suivant", "Afficher l’onglet précédent", "Afficher l’onglet suivant", "Afficher l’onglet précédent", "Afficher l’onglet suivant", "Placer l’onglet dans une nouvelle fenêtre", "Fusionner toutes les fenêtres", missing value, "Tout ramener au premier plan", missing value, "Mobile Applications"} click menu item 3 --> menu item "Réduire/agrandir" of menu "Fenêtre" of menu bar item "Fenêtre" of menu bar 1 of application process "Finder" of application "System Events" end tell end tell
Of course, I guess that Shane will be able to give us a neater scheme triggering directly ASObjC in Yosemite.
Yvan KOENIG (VALLAURIS, France) dimanche 26 octobre 2014 10:51:13 |