I'd like to assign a right-click context to a keyboard shortcut using something like an AppleScript.
For example:
If I right click a folder in Dropbox it gives me a "Share Dropbox Link" menu. Is it possible to access this without using the mouse?
I'd like to assign a right-click context to a keyboard shortcut using something like an AppleScript.
For example:
If I right click a folder in Dropbox it gives me a "Share Dropbox Link" menu. Is it possible to access this without using the mouse?
You can use my script below for accessing the context menu, you'll need both MouseLocation, and cliclick that you'll find via Google.
You may want to edit it a little (and adjust the hardcoded paths to both MouseLocation, and cliclick), but it should really be no problem, I think you can use System Events and key code commands to navigate the context menu.
set mouseLoc to (do shell script "/usr/local/opt/MouseLocation")
set {astid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ","}
tell mouseLoc to set {mouseX, mouseY} to {it's text item 1, it's text item 2}
set {mouseX, mouseY} to {(mouseX as integer), 1200 - (mouseY as integer)}
tell application "System Events"
set frontProcessName to name of every process whose frontmost is true
-- tell a to set aa to (get its name)
set wnCount to count of windows of process named frontProcessName
if wnCount > 0 then
tell window 1 of process named frontProcessName
set wnPos to its position
set wnsize to its size
end tell
set {wnX, wnY, wnWidth, wnHeight} to {item 1 of wnPos, item 2 of wnPos, item 1 of wnsize, item 2 of wnsize}
set {leftBound, RightBound, upperBound, lowerBound} to {wnX + 1, (wnX + wnWidth - 21), wnY + 50, (wnY + wnHeight - 51)}
if mouseX ≥ leftBound and mouseX ≤ RightBound then
else if mouseX < leftBound then
set mouseX to leftBound
log "a"
else
set mouseX to RightBound
log "b"
end if
if mouseY ≥ upperBound and mouseY ≤ lowerBound then
else if mouseY < upperBound then
set mouseY to upperBound
log "c"
else
set mouseY to lowerBound
log "d"
end if
end if
end tell
set mouseLoc to "c" & mouseX & " " & mouseY
do shell script "/usr/local/opt/cliclick " & mouseLoc
set AppleScript's text item delimiters to astid
Edit:
I didn't know that you couldn't find MouseLocation via Google anymore, I am sorry about that If you have problems compiling the code found in post # 3 in this thread (http://www.macscripter.net/viewtopic.php?id=33468), then I recommend you use the MouseTool found here :(http://www.hamsoftengineering.com/codeSharing/MouseTools/MouseTools.html) instead, you would then need to change the first four lines of the script to something like:
set mouseLoc to (do shell script "MouseTools -location")
set {astid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
tell mouseLoc to set {mouseX, mouseY} to {it's text item 1, it's text item 2}
set {mouseX, mouseY} to {(mouseX as integer),(mouseY as integer)}
(You'll have to adjust the path to MouseTools as well as to cliclick.)
According to this post, it seems to be possible to do this within the system, using Universal Access.