Re: Keyboard Control Panel 8.5 (Gestalts 'n' Stuff)
Re: Keyboard Control Panel 8.5 (Gestalts 'n' Stuff)
- Subject: Re: Keyboard Control Panel 8.5 (Gestalts 'n' Stuff)
- From: Richard 23 <email@hidden>
- Date: Thu, 30 Nov 2000 03:03:29 -0800
>
Spent most of the day trying to figure this one out, been all over
>
developer.apple.com. It's a mac -- it shouldn't be this hard <ARGH!>
>
>
I'm trying to write a short, sweet and simple Apple Script to turn
>
off the Global Function Keys in Keyboard Control Panel Version 8.5.
>
Logic tells me it should look like this:
>
>
on run
>
tell application "Keyboard"
>
set Hot Function Key Settings to False
>
end tell
>
end run
>
Ha! Try telling to do your laundry! Just as effective.
>
A similarly written AppleScript works for turning off font smoothing,
>
and it's pretty rudimentary. The error generated indicates the name
>
I'm using for my object 'Hot Function Key Settings' is not what the
>
developer of Keyboard 8.5 decided to call it. I tried to pull the
>
dictionary for Keyboard 8.5, but was informed by script editor that
>
it was not scriptable (Apple, however, lists it as a scriptable
>
resource in the AppleScript Guide).
I just searched my pdf copy for AppleScript 1.3.7 for the word keyboard
and found 3 occurrences none of which mentioned the control panel or
scriptability.
Using the Apple Help turned up scriptable applications. Before I
followed the link, I noted with a due sense of dread that the link
preceeding it read "Using the Script Ediotr" (sic).
Sorry I doubted you, there it is. But methinks somebody's playing
fast with the truth. Although it clearly lists "Keyboard Control
Panel" in the list, it contains nothing in its resources which would
normally be present in a scriptable application.
No aete or aedt. They are probably saying that you can manipulate
the control panel's settings by using a scripting addition, but that
doesn't qualify it as a scriptable application. I can get SimpleText
to open text files but it's not "scriptable" beyond the standard four
events (run, open, print and quit).
Well I figured out where it stores the setting, "Hot Keys Preferences"
but manipulating this has no effect because it doesn't read the setting
if it already knows what it is (because it read it in from the file
the first time you opened it). Its a possibility you could modify the
setting at startup and it would use whatever setting it found but that's
not very practical.
There is a gestalt selector which appears to correspond to the current
state of the checkbox, the selector code is "kycp" and the bit which
contains the current state is bit 1 (decimal value = 2).
The bit is in the opposite state as the checkbox:
Use As Function Keys Decimal Binary
-------------------- ------- --------
unchecked 3 00000011
checked 1 00000001
The value is actually a long which is 4 bytes but we only care about
the low-order byte.
to get the current value, you can use the Finder:
tell application "Finder" to get computer "kycp"
But the Finder doesn't provide the means to set the value you're either
going to have to find an existing tool or make one yourself (ugh).
the function you want to be able to call, hopefully indirectly is:
SetGestaltValue ( selector, newValue )
selector: OSType (a 4 character string), "TNAM"
newValue: long integer (4 byte), "DLNG" or "HLNG"
I used GestLab to toggle the bit on and off and found that the control
panel's checkbox changed properly as well as the value returned by the
Finder.
GestLab is available on the author's website at:
<
http://www.geocities.com/jp_curcio/>
There is also a useful Gestalt Selectors List at:
<
http://www.rgaros.nl/gestalt/index.html#appl>
GestLab, although not scriptable, retrieves a lot of interesting
information about your system and allows you to modify selector values
(at your own peril) like I did with the "kycp" selector.
I have already done a preliminary search for gestalt functions available
to AppleScript for another project but don't really have the info as to
whether there's a scriptable tool or scripting addition to do this.
It doesn't look very promising. I may have to do it myself. boo!
I need to look through my pile of downloads. If someone else knows
they'll perhaps beat me to it. Fine. I'd like to know myself!
>
I also looked at the Scripting
>
Extensions for Keyboard Addition, and its dictionary didn't contain
>
anything obvious.
Nothing that's not obvious either.
>
So I delved into developer.apple.com, and while I was able to dig up
>
several references to the Keyboard Control Panel, none of them
>
covered 8.5.
Yeah, it's really hard to find specific info sometimes. It almost seems
like the good stuff is buried on purpose, not organized into digestable
and usable form.
>
Any help/work-arounds would be extremely appreciated... it's become personal.
I did the best I could. I found the selector. Now all you need is a tool
to set it via AppleScript. I'll post a followup if I find one.
R23
All that blab and no answer. Aren't I helpful? 8)