如何检测我的对话框窗口是否已关闭?
然后我要检测窗口对话框是否关闭
在DatabaseRefresher()上
menu_click({“ OsiriX”,“插件”,“数据库”,“ SetRemoteDatabaseRefresh”})
延迟1
将Test1设置为0
将Test1设置为应用程序“系统事件”的应用程序进程“ OsiriX”的窗口“ RemoteDatabasePrefs”的静态文本“ RemoteDatabasePrefs”的值
记录Test1
PressButton(“取消”,“ OsiriX”,“ RemoteDatabasePrefs”)-(TheButtonToPress,TheProgramName,TheWindow)
在此处添加测试以检测窗口是否关闭)
结束DatabaseRefresher
这是我的窗口元素:
button "OK" of window "RemoteDatabasePrefs" of application process "OsiriX" of application "System Events",
button "Cancel" of window "RemoteDatabasePrefs" of application process "OsiriX" of application "System Events",
text field 1 of window "RemoteDatabasePrefs" of application process "OsiriX" of application "System Events",
static text "RemoteDatabasePrefs" of window "RemoteDatabasePrefs" of application process "OsiriX" of application "System Events"
static text "Enter Remote Database Refresh Interval in minutes:" of window "RemoteDatabasePrefs" of application process "OsiriX" of application "System Events",
button 3 of window "RemoteDatabasePrefs" of application process "OsiriX" of application "System Events",
button 4 of window "RemoteDatabasePrefs" of application process "OsiriX" of application "System Events",
button 5 of window "RemoteDatabasePrefs" of application process "OsiriX" of application "System Events",
作为菜鸟,如果我问的是非常基本的问题,我深表歉意。我确实有一些可以使用的脚本,而且我似乎知道它们的工作方式,但是当我尝试对其进行重构时,我似乎花了太多时间寻找解决方案
答案 0 :(得分:0)
这行有点奇怪:
set Test1 to value of static text "RemoteDatabasePrefs" of window "RemoteDatabasePrefs" of ...
static text
对象通常以它们包含的文本值命名。因此,我会期望该value
的{{1}}为static text
。
但是,如果这样做是为了获取窗口的标题文本,则无需读取某些"RemoteDatabasePrefs"
对象的值;您可以改为访问static text
对象的name
属性或title
属性:
window
set Test1 to the title of window "RemoteDatabasePrefs" of ...
属性明确设置为name
; "RemoteDatabasePrefs"
属性通常与title
相同,并且通常都与窗口标题栏中的文本匹配。但是,您可能遇到了一个例外,其中name
和name
属性的值不同;在这种情况下,您需要使用title
属性的值,该值应与标题文本匹配。
要测试窗口是否已关闭,请使用title
命令测试exists
对象是否仍然存在。关闭窗口后,该窗口便不再存在。
window
变量tell application "System Events to tell process "OsiriX"
set isOpen to (exists window "RemoteDatabasePrefs")
end tell
将包含一个布尔值isOpen
或true
,告诉您窗口是打开(false
)还是已关闭({{1} }。