【发布时间】:2020-11-27 02:46:12
【问题描述】:
我在 xcode 中有一个非常简单的 applescript 应用程序,它只打开一个窗口并有一个重定向到网站的按钮。如果用户在 60 秒内没有点击按钮,有没有办法自动退出窗口。 这是我的代码
script AppDelegate
-- property parent : class "NSObject"
-- IBOutlets
property theWindow : missing value
on applicationWillFinishLaunching_(aNotification)
-- Insert code here to initialize your application before any files are opened
end applicationWillFinishLaunching_
on buttonClicked_(sender)
open location "https://example.com"
quit
end buttonClicked_
on applicationShouldTerminate_(sender)
-- Insert code here to do any housekeeping before your application quits
return current application's NSTerminateNow
end applicationShouldTerminate_
end script
【问题讨论】:
-
你可以通过使用带有超时的
display dialog来避免整个Xcode的事情。 -
@red_menace 我不能,我还在窗口中插入图像,所以我必须使用 xcode。
-
您也可以使用辅助视图,但是您是如何显示窗口的,或者界面编辑器中的所有内容?
-
@red_menace 我在 .xib 文件中创建了一个窗口,它有一个完整的 gui,您可以在其中拖动按钮和图像(我显然是个菜鸟)。我到处查找,但似乎无法找到如何做到这一点
-
@red_menace 我通过
open compiled.app展示了这一点
标签: xcode macos popup applescript