• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Check out code please
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Check out code please


  • Subject: Check out code please
  • From: louie <email@hidden>
  • Date: Thu, 21 Jul 2011 11:45:57 -0700

Howdy all,
In the script below that I save as a application there is three things that I am concerned about. The first is that the dialog does not speak text when typing in the edit field. The next is a small delay I needed to code or I would randomly when running the scrip I would get a index out of range. The last one is I have to turn off then voice over to have the script work the next timed it is run. Any help in these concerned's would be very much appreciated.
(*
I would like to thank hamsoftengineering for MouseTools.
http://www.hamsoftengineering.com
apple script name
crawlMenubar
search the menubar for a menu name that can not be reached by voice over.
author
Richard L. Most better known as Louie
email@hidden
*)

-- bring Finder to the front so there is a known menubar
tell application "Finder"
	activate
	-- initialize variables
	-- get the screen resolution
	set {d1, d2, maxX, maxY} to bounds of desktop's window
	-- the below will give a step of 16 pixels in a resolution of 1024
	set step to maxX / 64
	-- apple script starts count from zero
	set x to maxX - 1
	-- set y to the hight center of the menu bar
	set y to 10
	set stepCount to 0
	set mouseToolsPath to (path to home folder as text) & "UnixBins:MouseTools"
	-- get the name of the menu item to activate
	set menuName to the text returned of (display dialog "Menu name" default answer "dropbox")
	set volume with output muted
end tell
-- tell the user that the search has started
talk("working")
-- start the search of the menu bar
repeat
	set x to x - step
	-- is it time to tell user searching
	set stepCount to stepCount + 1
	if stepCount ≥ 10 then
		set stepCount to 0
		talk("working")
	end if
	-- move the mouse one step to the left
	do shell script quoted form of POSIX path of mouseToolsPath & " -x " & (x as text) & " -y " & (y as text)
	set volume with output muted
	-- get the text under the mouse cursor
	tell application "VoiceOver"
		tell commander
			perform command "describe item in mouse cursor"
			perform command "copy last phrase to clipboard"
			perform command "pause or resume speaking"
		end tell
		--output a bunch non speaking characters this will ensure that talking is stopped
		output "                                 "
	end tell
	-- need a small delay because some times we get a out of index error.
	delay 0.1
	-- get the text from the clipboard
	set clip to (the clipboard as text)
	-- check the text under the mouse cursor
	-- if text under mouse cursor is the word help the cursor is in a area of the menu bar that can be reach by normal voice over navigation, no need to search any more.
	if clip contains "help" then
		talk(menuName & " not found")
		tell application "VoiceOver"
			tell commander
				-- bring up the desktop
				perform command "go to desktop"
				--get off the menu bar
				perform command "escape"
			end tell
		end tell
		exit repeat
	end if
	if clip contains menuName then
		(*
The below code is to turn voice over off then on. This action is needed because the voice over cursor is moved when the mouse is clicked. The voice over cursor is forced out of the bounds that it is normally in, this causes the script not to work the second time or voice over to quit working. The action of turning voice over off and on fixed this bug.
*)
		tell application "VoiceOver"
			quit
			delay 0.5
			activate
			-- Now that voice over is reset continue
			-- click the found menu name
			tell mouse cursor
				click once with left button
			end tell
		end tell
		talk(menuName & " menu")
		exit repeat
	end if
end repeat

on talk(msg)
	set isMuted to output muted of (get volume settings)
	if isMuted is true then
		set volume without output muted
	end if
	say msg
end talk

louie
email@hidden



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Re: Lion crashed by AppleScript
  • Next by Date: Re: Lion crashed by AppleScript
  • Previous by thread: Re: Lion notes
  • Next by thread: Idle Bug in Lion ASE
  • Index(es):
    • Date
    • Thread