我将使用什么 applescript 数据类型?

发布于 2024-12-17 04:47:26 字数 386 浏览 0 评论 0原文

我有这个 applescript 代码:

tell application "TextEdit"
    set test to the bounds of window 1
end tell

display dialog test

但我收到以下错误:

error "Can’t make {10, 22, 400, 1003} into type string." number -1700
from {10, 22, 400, 1003} to string

我需要为此使用哪种数据类型?

顺便说一句,我不希望它像将其设置为某些数据类型时那样显示 10224001003

I have got this applescript code:

tell application "TextEdit"
    set test to the bounds of window 1
end tell

display dialog test

but I am getting the following error:

error "Can’t make {10, 22, 400, 1003} into type string." number -1700
from {10, 22, 400, 1003} to string

Which data type would I need to use for this?

BTW, I don't want it to display 10224001003 as it does when you set it to some data types.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

披肩女神 2024-12-24 04:47:26

显示对话框语句只能显示字符串。窗口边界将以数字列表的形式返回给您。因此,您必须根据该信息创建一个字符串,以便可以显示它。有多种方法可以做到这一点,但这里有一种简单的方法,我们只需创建一个新字符串并将边界数字插入到该字符串中即可。您可以看到我使新字符串看起来像数字列表......但它确实是一个字符串。

tell application "TextEdit"
    set boundsList to the bounds of window 1
end tell

set boundsString to "{" & ((item 1 of boundsList) as text) & ", " & ((item 2 of boundsList) as text) & ", " & ((item 3 of boundsList) as text) & ", " & ((item 4 of boundsList) as text) & "}"
display dialog boundsString

A display dialog statement can only display a string. The window bounds is returned to you as a list of numbers. As such you have to create a string out of that information so you can display it. There's several ways to do that but here's a simple way where we just create a new string and insert the bounds numbers into that string however we want. You can see that I made the new string look like the list of numbers... but it really is a string.

tell application "TextEdit"
    set boundsList to the bounds of window 1
end tell

set boundsString to "{" & ((item 1 of boundsList) as text) & ", " & ((item 2 of boundsList) as text) & ", " & ((item 3 of boundsList) as text) & ", " & ((item 4 of boundsList) as text) & "}"
display dialog boundsString
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文