Re: Swap keyboard from "belgium" layout to US
Re: Swap keyboard from "belgium" layout to US
- Subject: Re: Swap keyboard from "belgium" layout to US
- From: Jan Bultereys <email@hidden>
- Date: Tue, 25 Apr 2006 09:45:36 +0200
- Thread-topic: Swap keyboard from "belgium" layout to US
Hi, right the shortcut is cmd ` and now it works perfectly thanks for the
tip.... BUT now I want to put it into production on PANTHER machines and I
have an "NSReceiverEvaluationScriptError" on : count menu bar item
How can I fix this?
on switch_keyboard to keyboard_layout
tell application "System Events" to tell menu bar 1 ¬
of application process "SystemUIServer"
(* workaround for bug in conditional filter: *)
repeat with this_menu from 1 to count menu bar items
try
tell menu bar item this_menu to if ¬
(get value of attribute "AXDescription") ¬
is "text input menu extra" then
click (* open menu *)
tell menu item keyboard_layout of ¬
menu 1 to if exists then return click
cancel (* operation failed: close menu *)
exit repeat
end if
end try
end repeat
end tell
beep (* indicate that a failure occurred *)
error number -128 (* cancel script execution *)
end switch_keyboard
switch_keyboard to "U.S."
delay 1
tell application "System Events"
tell process "QuarkXPress"
set frontmost to true
key code 42 using {command down}
end tell
end tell
switch_keyboard to "Belgian"
> From: Felix Grasser <email@hidden>
> Date: Mon, 24 Apr 2006 18:31:06 +0200
> To: Jan Bultereys <email@hidden>, AppleScript Users
> <email@hidden>
> Subject: Re: Swap keyboard from "belgium" layout to US
>
> Hi Jan,
>
>> Hi, I want to create a flying indend but quark doesn't understand the
>> command, changing to US keyboard hit "command `" works.... I don't
>> know what
>> I do wrong:
>
> If I understand correctly, you are trying to execute a menu command
> in QuarkXPress that has a keyboard shortcut (cmd-`) assigned. The
> keyboard shortcut works fine when invoked manually (even in the
> Belgium keyboard) but does not work when invoked from AppleScript.
>
> I had a similar problem summoning the spell checking panel (cmd-: on
> the Swiss French keyboard). The panel appears correctly when manually
> typing "cmd-:" but does not appear when invoked through applescript
> 'keystroke ":" using command down'.
>
> I have no clue why that is so. If any AppleScript experts on this
> list could enlighten me, I would be very thankful.
>
> My workaround consists in using a call to "key code" instead of
> "keystroke". The script would then look like:
>
> =======8><=======
> tell application "System Events"
> tell process "QuarkXPress"
> set frontmost to true
> -- Adjust key code for your requirements.
> key code 47 using {command down, shift down}
> end tell
> end tell
> =======8><=======
>
> You can find the key code for your shortcut "`" by downloading Peter
> Maurer's "Key Codes" application:
> <http://www.petermaurer.de/nasi.php?section=keycodes&layout=default>.
> Simply launch the application, type your shortcut and write down the
> key code.
>
> HTH
> Felix
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Applescript-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> edepot.com
>
> This email sent to 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:
This email sent to email@hidden