Le 12/12/2013 à 15:06, Robert Poland <
email@hidden> a écrit :
Thanks Yvan,
I trued your suggestion and got error, 'Smile got an error: Missing argument to command "c": Expected two coordinates (separated by a comma) or “.”.Examples: "c:123,456" or "c.”'
BUT you’re referring to a very old version. current version is 2.3.1. 10/17/2013.
As I don't use cliClick regularly I ran the script with the version which was installed after tests made for you times ago.
You're right, it's an old version.
With the new one the script behaved flawlessly on my iMac under 10.9.
In fact I ran :
-- NOTE: THIS SCRIPT MAY DEPEND ON THE SATIMAGE.OSAX
-- NOTE: THIS SCRIPT MAY DEPEND ON CLICLICK
on run
main()
beep
end run
on main()
--set applicationName to (info for (path to frontmost application))'s short name
set applicationName to "Finder"
tell application applicationName
activate
try
set {leftEdge, topSide, null, null} to bounds of window 1
on error
beep 2
tell application "SystemUIServer"
display dialog "This function is broken when used with " & applicationName
end tell
end try
if applicationName contains "Finder" then
set y to (topSide - 12) as integer -- locate green button
else
set y to (topSide + 12) as integer
end if
set x to (leftEdge + 52) as integer
delay 0.5 -- needs this value or greater
# Macintosh HD:usr:bin:cliclick
tell me to do shell script "cliclick c:" & x & "," & y -- click it
end tell
end main
which forced the script to apply to the Finder because I made tests from the Apple's script editor.
I replaced System Events by SystemUIServer in the error code.
I inserted « tell me to » before do shell script because this function is an OSAX component so, triggering it in a tell application block issue an error.
This one is not fatal and the script make a second attempt mimicking tell me so it's cleaner and more efficient to code with tell me directly.
Why are you using a third party command when what you want to achieve may be done with in the box code ?
-- NOTE: THIS SCRIPT MAY DEPEND ON THE SATIMAGE.OSAX
on run
main()
beep
end run
on main()
--set applicationName to (info for (path to frontmost application))'s short name
set applicationName to "Finder"
tell application applicationName
activate
if applicationName contains "Finder" then
tell application "System Events" to tell process "Finder"
tell (first window whose subrole is "AXStandardWindow")
# properties of button 2
click button 2
end tell
end tell
end if
end tell
end main
This new version don't rely on cliClick and does what you want.
Yvan KOENIG (VALLAURIS, France) jeudi 12 décembre 2013 16:12:10