• 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
Re: Swap keyboard from "belgium" layout to US
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Swap keyboard from "belgium" layout to US


  • Subject: Re: Swap keyboard from "belgium" layout to US
  • From: kai <email@hidden>
  • Date: Wed, 19 Apr 2006 14:31:40 +0100


On 19 Apr 2006, at 11:50, Gary (Lists) wrote:

"kai" wrote:

[snip]

While
it works in Tiger, I can't say if it will in Panther. (Sometimes, adding a
delay here and there seems to help with a pre-Tiger UI).


I can confirm that the uncertainty had merit.

This does not run in Panther, OMM.

Specifically, I get the NSReceiverEvaluationScriptError 4.

Thanks for the feedback, Gary. :-)

NSReceiverEvaluationScriptError 4 is usually a good indication that an object doesn't exist. The question then is: *what's* missing? (Only guessing, of course, but I'm inclined to think one possible absentee could be attribute "AXDescription".)

Something like the following might help to pinpoint the problem. In Tiger, the script gets as far as clicking on a menu chosen from a list of descriptions. From the sound of things, it's unlikely to get that far in Panther - but it could give a better clue as to where the routine trips up:

----------------

tell application "System Events" to try
	tell application process "SystemUIServer"
		if not (exists) then error it
		tell menu bar 1
			if not (exists) then error it
			tell menu bar items
				if not (exists) then error it
				tell attribute "AXDescription"
					if not (exists) then error it
					set l to value
					tell me to set v to choose from list l
					if v is false then error number -128
					set v to v's item 1
					tell l to repeat with i from 1 to count
						if item i is v then exit repeat
					end repeat
				end tell
			end tell
			click menu bar item i
		end tell
	end tell
on error e
	beep (* indicate a problem *)
	e (* return the possible source of the problem *)
end try

----------------

<lameass>

LOL!

While I know this is not all that useful in a variable environment, I toggle
between two keyboard layouts -- current and last, only -- using 'cmd-space'.
Since I daily use two, I can switch quickly.

Yeah - as you might guess, that does something else here (opens a spotlight search).


I'm jumping the gun a bit here, based purely on speculation and assumption - but this might stand a better chance of succeeding in Panther (though the delay thing could still apply). It requires a predetermined position for the text input menu extra. (My current menu extras are: [1] AppleScript, [2] modem, [3] text input, [4] battery, [5] clock.)

----------------

on switch_keyboard to keyboard_layout at menu_position
tell application "System Events" to tell menu bar item menu_position of ¬
menu bar 1 of application process "SystemUIServer" to if exists then
click (* open menu *)
tell menu item keyboard_layout of menu 1 to if exists then return click
cancel (* operation failed: close menu *)
end if
beep (* indicate that a failure occurred *)
error number -128 (* cancel script execution *)
end switch_keyboard


set menu_position to 3 (* text input menu extra: modify as appropriate *)
switch_keyboard at menu_position to "U.S."
delay 2 (* demo only: do some stuff *)
switch_keyboard at menu_position to "Belgian"


----------------

But then again...
;-)

---
kai


_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Swap keyboard from "belgium" layout to US
      • From: Felix Grasser <email@hidden>
    • Re: Swap keyboard from "belgium" layout to US
      • From: Jan Bultereys <email@hidden>
References: 
 >Re: Swap keyboard from "belgium" layout to US (From: "Gary (Lists)" <email@hidden>)

  • Prev by Date: Re: MacBook Pro iSight Scripting
  • Next by Date: Struggling with a script
  • Previous by thread: Re: Swap keyboard from "belgium" layout to US
  • Next by thread: Re: Swap keyboard from "belgium" layout to US
  • Index(es):
    • Date
    • Thread