I'm using the LG OnScreen Control app to switch between different monitor layouts which have no names in the menu item as it uses pictures. I want to write an applescript that clicks either the first one or the 9th one, my favourite selections. =)
How can I click them? I only managed to select them with the below code
ignoring application responses
tell application "System Events" to tell process "OnScreen Control"
click menu bar item 1 of menu bar 2
end tell
end ignoring
delay 0.1
do shell script "killall System\\ Events"
tell application "System Events" to tell process "OnScreen Control"
tell menu bar item 1 of menu bar 2
click menu item "Screen Split" of menu 1
end tell
end tell
UPDATE: Ah silly me, I figured I can use "key code 125" several times to click the down arrow and "key code 76" to hit enter.
ignoring application responses
tell application "System Events" to tell process "OnScreen Control"
click menu bar item 1 of menu bar 2
end tell
end ignoring
delay 0.1
do shell script "killall System\\ Events"
tell application "System Events" to tell process "OnScreen Control"
tell menu bar item 1 of menu bar 2
click menu item "Screen Split" of menu 1
key code 125
key code 125
key code 125
key code 125
key code 125
key code 125
key code 125
key code 125
key code 76
end tell
end tell
Wondering though if there is a better and quicker way to execute this? Addressing the sub-items directly despite not having a name?
CodePudding user response:
After:
click menu item "Screen Split" of menu 1
Use:
click menu item 9 of menu 1 of menu item "Screen Split" of menu 1
Getting rid of all the key code
commands