检测 window 是否打开
Detecting if a window is open
如何检测我的对话框 window 是否已关闭?
- 我打开一个对话框window
- 然后我想读取window头值并显示结果
- 然后我关闭 window
然后我想检测window对话框是否关闭
在 DatabaseRefresher() 上
menu_click({"OsiriX", "Plugins", "Database", "SetRemoteDatabaseRefresh"})
延迟 1
将 Test1 设置为 0
将 Test1 设置为应用程序 window 的静态文本 "RemoteDatabasePrefs" 的值 "RemoteDatabasePrefs" 应用程序 "OsiriX" 的应用程序 "System Events"
日志测试1
PressButton("Cancel", "OsiriX", "RemoteDatabasePrefs") --(TheButtonToPress、TheProgramName、TheWindow)
在此处添加测试以检测 window 是否已关闭)
结束 DatabaseRefresher
这是我的 window 个元素:
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",
作为菜鸟,如果我问的是非常基本的问题,我深表歉意。我确实有一些现有的脚本可以使用,而且我似乎知道它们是如何工作的,但是当我尝试重构它们时,我似乎花了太多时间来寻找解决方案
这一行有点奇怪:
set Test1 to value of static text "RemoteDatabasePrefs" of window "RemoteDatabasePrefs" of ...
static text
object 通常以它们包含的文本的值命名。因此,我 期望 static text
的 value
为 "RemoteDatabasePrefs"
。
但是,如果这样做是为了获取 window 的 header 文本,则不需要读取某些 static text
[=53] 的值=];您可以访问 name
属性 或 title
属性 代替 window
object:
set Test1 to the title of window "RemoteDatabasePrefs" of ...
name
属性明明设置为"RemoteDatabasePrefs"
; title
属性通常与 name
相同,并且两者通常与 window 的 header 栏中的文本相匹配。但是,您可能遇到过一个异常,其中 name
和 title
属性的值不同;在这种情况下,您需要 title
属性 的值,它应该与 header 文本相匹配。
测试window是否已经关闭,使用exists
命令测试window
object是否仍然存在。当 window 关闭时,它从那一刻起不再存在。
tell application "System Events to tell process "OsiriX"
set isOpen to (exists window "RemoteDatabasePrefs")
end tell
变量 isOpen
将包含一个布尔值 true
或 false
告诉您 window 是打开的 (true
) 还是已经打开关闭 (false
).
如何检测我的对话框 window 是否已关闭?
- 我打开一个对话框window
- 然后我想读取window头值并显示结果
- 然后我关闭 window
然后我想检测window对话框是否关闭
在 DatabaseRefresher() 上 menu_click({"OsiriX", "Plugins", "Database", "SetRemoteDatabaseRefresh"}) 延迟 1 将 Test1 设置为 0
将 Test1 设置为应用程序 window 的静态文本 "RemoteDatabasePrefs" 的值 "RemoteDatabasePrefs" 应用程序 "OsiriX" 的应用程序 "System Events" 日志测试1 PressButton("Cancel", "OsiriX", "RemoteDatabasePrefs") --(TheButtonToPress、TheProgramName、TheWindow) 在此处添加测试以检测 window 是否已关闭) 结束 DatabaseRefresher
这是我的 window 个元素:
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",
作为菜鸟,如果我问的是非常基本的问题,我深表歉意。我确实有一些现有的脚本可以使用,而且我似乎知道它们是如何工作的,但是当我尝试重构它们时,我似乎花了太多时间来寻找解决方案
这一行有点奇怪:
set Test1 to value of static text "RemoteDatabasePrefs" of window "RemoteDatabasePrefs" of ...
static text
object 通常以它们包含的文本的值命名。因此,我 期望 static text
的 value
为 "RemoteDatabasePrefs"
。
但是,如果这样做是为了获取 window 的 header 文本,则不需要读取某些 static text
[=53] 的值=];您可以访问 name
属性 或 title
属性 代替 window
object:
set Test1 to the title of window "RemoteDatabasePrefs" of ...
name
属性明明设置为"RemoteDatabasePrefs"
; title
属性通常与 name
相同,并且两者通常与 window 的 header 栏中的文本相匹配。但是,您可能遇到过一个异常,其中 name
和 title
属性的值不同;在这种情况下,您需要 title
属性 的值,它应该与 header 文本相匹配。
测试window是否已经关闭,使用exists
命令测试window
object是否仍然存在。当 window 关闭时,它从那一刻起不再存在。
tell application "System Events to tell process "OsiriX"
set isOpen to (exists window "RemoteDatabasePrefs")
end tell
变量 isOpen
将包含一个布尔值 true
或 false
告诉您 window 是打开的 (true
) 还是已经打开关闭 (false
).