The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   Applications (http://hintsforums.macworld.com/forumdisplay.php?f=5)
-   -   Decimal point key (http://hintsforums.macworld.com/showthread.php?t=64684)

NovaScotian 12-18-2006 10:57 AM

If you have several languages in your Keyboard layout menu (the little flag next to Spotlight in the menu bar) then this AppleScript will toggle through each one every time it is run. If you give it a hot key using any of the available tools (I use FastScripts), a key combo will switch for you.

Code:

tell application "System Events" to tell process "SystemUIServer"
        set _ to get value of attribute "AXDescription" of every menu bar item of menu bar 1
        set {k, j} to {count of _, 0}
        repeat with i from 1 to k
                if _'s item i is "text input menu extra" then
                        set j to i
                        exit repeat
                end if
        end repeat
       
        if j > 0 then
                tell menu bar item j of menu bar 1
                        click
                        tell menu 1
                                set {lk, kl, i} to {get name of every menu item, {}, 0}
                                repeat
                                        set i to i + 1
                                        if lk's item i is missing value then exit repeat
                                        set end of kl to lk's item i
                                end repeat
                                (* now we have a list of installed layouts *)
                               
                                set knt to count of kl
                                if knt > 1 then
                                        repeat with i from 1 to knt
                                                if (value of attribute "AXMenuItemMarkChar" of menu item (kl's item i) is not "") then
                                                        if i = knt then
                                                                set i to 1 (* back to top of list *)
                                                        else
                                                                set i to i + 1 (* switch to next layout *)
                                                        end if
                                                        exit repeat
                                                end if
                                        end repeat
                                        click menu item (kl's item i)
                                end if --  knt > 1
                        end tell -- to menu 1
                end tell -- to menu bar item…
        end if --  j > 0
end tell -- to process and System Events


allanb 01-18-2007 01:46 PM

Thanks, but it's beyond my technical ability to follow this instruction.

NovaScotian 01-18-2007 02:04 PM

It need not be. If you copy the script in the code box and paste it into a fresh page in your Script Editor (Spotlight for it), and then click the run button, it will change your language setting to the next item on the list under the languages flag on your menu bar each time you run it.

To get a script menu in your menu bar, you'll have to find the applescript provided to enable it (I can't find mine). If you then save my script as you have it in the Script Editor in the Scripts folder found in your user Library/Scripts folder, it will show up in that menu and by selecting it, you run the script.

vike 06-24-2009 06:08 PM

input menu shortcuts - system
 
os-x has since some time had the ability to set chortcuts to toggle/cycle input "source" (layout)

in os 10.5 (leopard) this is accessed in "system preferences"'s
either ("keyboard&mouse"):{keyboard shortcuts}:[outline]:|>="input menu"=" (".. previous .." toggles last/2nd last)
or ("international")->["input menu shortcuts"] with takes you to ["keyboard&mouse"]


i got here from g**gle in a different matter, namely to have applescript parse a real/float out of a numeric string with the decimal dot (eg "1.2") when the sys's international/locale's decimal point is the comma (",")
you know how?


All times are GMT -5. The time now is 01:44 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.