right click

Hi,

I would like to use applescript to right click with a mouse. I am disabled, and use my head mouvements to point in the computer, i could use the voice to click quicker,

thanks,

Salvador

Hello.

I can’t help you with the speakable items part, but I can help you with an AppleScript that opens the “right click” menu for you, provided you install the following small utilities, and gets someone to make the folders they are supposed to be in. ~/opt/bin means that you have to create an opt older inside your home folder, and then create a bin folder inside that folder.

CliClick can be downloaded from here

MouseTools can be downloaded from here

Here is the AppleScript, It may not be perfect, but should work most of the time.

I have no idea about Speakable items, and such, and it doesn’t work for me, so I hope someone else here, will help you. :slight_smile: (You or somebody else, may tweak the script in anyway you want or need, in order to make it work for you.)


# Copyright © 2012 - 2015 McUsr
run showRightClickMenu
script showRightClickMenu
	on run
		set mouseLoc to (do shell script "~/opt/bin/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), 1200 - (mouseY as integer)}
		
		tell application id "sevs"
			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
				else
					set mouseX to RightBound
				end if
				
				if mouseY ≥ upperBound and mouseY ≤ lowerBound then
				else if mouseY < upperBound then
					set mouseY to upperBound
				else
					set mouseY to lowerBound
				end if
				
			end if
		end tell
		set mouseLoc to "c" & mouseX & " " & mouseY
		do shell script "~/opt/bin/cliclick " & mouseLoc
		set AppleScript's text item delimiters to astid
	end run
end script

Hi,

thanks for your answer.

I installed clickclick and mouse tools (the compiled command line tool) in a folder in opt and bin folders as you told me (Miname/opt/bin),

I copied the script (from run showRightClickMenu to the end). When I click play it told me that there is a shortcut who doesn’t work (the number changes, but message is: Unrecognized action shortcut “c166”)

I tried to create a voice command (system preferences / accessibility / voice commands / create command / execute “the name of the file of script”), it doesn’t works, but I don’t know the reason,

could you help me?, thanks in advance,

Salvador Cabanilles

Hello.

I hope you did open the script with AppleScript Editor and ran it from there, to certify that the script works as expected.

Where did you run the script from when you got that message?

I placed it into the folder, global speakable items, though I am not totally sure if it should work from there, because it seems by the documentation from Apple that I found here (I’m still on Mavericks). My problem is really that I can’t calibrate the speakable items, so that I know for sure that the script triggers, when the right command words are spoken. (I saved by the name “Right Click”).

As I wrote above, I hope somebody will help you to make this work for you. Good Luck.