AppleScript:如何制作具有四个零字节值的 "type class"?
AppleScript: How to make a "type class" with four zero-byte values?
"Type class" AppleScript 中的值如下所示:
«class TEXT»
接收应用程序然后获取类型 OSType
(或 ResType
)的 32 位值。
我需要将 属性 设置为等于 0 的 32 位值。换句话说,我需要定义一个包含四个 NUL 字符的 «class »
。
接收属性在.sdef文件中声明如下:
<property name="scrap type" code="Scrp" type="type">
<cocoa key="scrapType"/>
</property>
这可能吗?
也许这会奏效:
use framework "Foundation"
(current application's NSAppleEventDescriptor's ¬
descriptorWithTypeCode:0) as anything
--> «class »
编辑: 2019-04-28
如评论中所述,AppleScript 中的 anything
(或 any
)class,可以 用于强制 cocoa 值到他们的 AppleScript 等价物,不是这样做的理想方法。相反,将 cocoa 对象添加到 NSArray
然后将其强制转换为 list
会将数组中的所有值强制转换为其 AppleScript 类型。所以:
item 1 of ((current application's NSArray's ¬
arrayWithObject:(current application's ¬
NSAppleEventDescriptor's ¬
descriptorWithTypeCode:0)) as list)
"Type class" AppleScript 中的值如下所示:
«class TEXT»
接收应用程序然后获取类型 OSType
(或 ResType
)的 32 位值。
我需要将 属性 设置为等于 0 的 32 位值。换句话说,我需要定义一个包含四个 NUL 字符的 «class »
。
接收属性在.sdef文件中声明如下:
<property name="scrap type" code="Scrp" type="type">
<cocoa key="scrapType"/>
</property>
这可能吗?
也许这会奏效:
use framework "Foundation"
(current application's NSAppleEventDescriptor's ¬
descriptorWithTypeCode:0) as anything
--> «class »
编辑: 2019-04-28
如评论中所述,AppleScript 中的 anything
(或 any
)class,可以 用于强制 cocoa 值到他们的 AppleScript 等价物,不是这样做的理想方法。相反,将 cocoa 对象添加到 NSArray
然后将其强制转换为 list
会将数组中的所有值强制转换为其 AppleScript 类型。所以:
item 1 of ((current application's NSArray's ¬
arrayWithObject:(current application's ¬
NSAppleEventDescriptor's ¬
descriptorWithTypeCode:0)) as list)