代码之家  ›  专栏  ›  技术社区  ›  Krishna Maru

从Safari和Mail中查找选定文本的范围

  •  0
  • Krishna Maru  · 技术社区  · 6 年前

    我已经试着找到它,我能够找到文本范围以外的所有其他应用程序这2。

    AXValueRef selectedRangeValue = NULL;
        AXError getSelectedRangeError = AXUIElementCopyAttributeValue(focussedElement,   kAXSelectedTextRangeAttribute, (CFTypeRef *)&selectedRangeValue);
    

    我也试过AppleScript,但它只适用于MSWord。

    tell application "Microsoft Word"
                    activate
                    return selection start of selection
                end tell
    

    0 回复  |  直到 6 年前