In preparation for hooking up Lync muting and unmuting to separate hotkeys, I wanted to make sure that my scripts no longer toggled the mute button, but only muted or unmuted.
For that to work, I needed to retrieve the current state of the checkbox.
set theCheckbox to checkbox 5 of splitter group 1 of aWindow
tell theCheckbox
set checkboxStatus to value of theCheckbox as boolean
if checkboxStatus is true then click theCheckbox
end tell
In this case, I store off the checkbox into a variable theCheckbox
and then later the checkbox status into a variable, allowing me to unset the checkbox if it is true.
This results in the following script for unmuting:
tell application "Microsoft Lync"
activate
end tell
tell application "System Events"
tell process "Microsoft Lync"
repeat with aWindow in (get every window)
set aName to get the name of aWindow
set initialName to ((characters 1 through 12 of aName) as string)
if (initialName = "Conversation") then
activate aWindow
set theCheckbox to checkbox 5 of splitter group 1 of aWindow
tell theCheckbox
set checkboxStatus to value of theCheckbox as boolean
if checkboxStatus is true then click theCheckbox
end tell
end if
end repeat
end tell
end tell
And for muting:
tell application "Microsoft Lync"
activate
end tell
tell application "System Events"
tell process "Microsoft Lync"
repeat with aWindow in (get every window)
set aName to get the name of aWindow
set initialName to ((characters 1 through 12 of aName) as string)
if (initialName = "Conversation") then
activate aWindow
set theCheckbox to checkbox 5 of splitter group 1 of aWindow
tell theCheckbox
set checkboxStatus to value of theCheckbox as boolean
if checkboxStatus is false then click theCheckbox
end tell
end if
end repeat
end tell
end tell
These scripts (and hopefully, others soon) are available on GitHub