MAC检测当前输入法名称代码
delphi吧
全部回复
仅看楼主
level 9
sun280 楼主
//获取系统当前输入法名称
function CurrentKeyboardName: string;
var
Source: TISInputSourceRef;
p: Pointer;
begin
Result := '';
Source := TISCopyCurrentKeyboardInputSource();
p := TISGetInputSourceProperty(Source, kTISPropertyLocalizedName);
if p <> nil then
Result := ToStr(p);
end;
2015年01月14日 14点01分 1
level 9
sun280 楼主
function ToStr(p: CFStringRef): string;
begin
Result := UTF8String(TNSString.Wrap(p).UTF8String);
end;
//获取系统当前输入法语言名称
function CurrentKeyboardLanguage: string;
var
Source: TISInputSourceRef;
p: Pointer;
begin
Result := '';
Source := TISCopyCurrentKeyboardInputSource();
p := TISGetInputSourceProperty(Source, kTISPropertyInputSourceLanguages);
if p <> nil then begin
if CFArrayGetCount(CFArrayRef(p)) > 0 then
Result := ToStr(CFArrayGetValueAtIndex(CFArrayRef(p), 0));
end;
end;
2015年01月14日 14点01分 2
1