Okay the goal for this script is to make it where it changes the time back 1 second every 1 second. So in a way it is stop time on the mac. I got this far into the script. Note in () is what the script there is suppose to do. aka where you help me.
set pasword to ("my password")
tell application "System Preferences"
activate
end tell
delay 3
tell application "System Events"
tell process "System Preferences"
click menu item "Date & Time" of menu "View" of menu bar 1
delay 2
tell window "Date & Time"
(click the authentication lock.)
tell application "System Events"
keystroke pasword
delay 1
tell application "System Events"
keystroke return
delay 1
(uncheck the set time data and time automatically checkbox)
delay 1
repeat
(select the seconds above the clock)
(click the top arrow right next to it)
(click save)
delay 1
end repeat
end tell
end tell
end tell
end tell
end tell
So that the whole script, I just got stuck in those areas and I'm looking for some help. Thanks.
答案 0 :(得分:1)
您可以使用名为UIElementInspector的应用程序来确定您尝试与之交互的UI元素的名称和层次结构。例如,“自动设置时间和日期复选框”将具有类似“复选框3”的名称。
然而,我的感觉是你将无法完成你试图用这个脚本做的事情,因为GUI脚本(当你告诉系统事件与GUI的一部分交互时)的时机确实很差。虽然在典型的AppleScript中可能有可能运行一个命令,然后等待一秒钟并运行另一个命令并等待一秒钟并运行另一个命令(尽管即使在那里,你将会失去同步)与GUI Scripting,第一个你运行这个脚本的时间可能需要2秒钟,然后是1.5秒,然后是3秒,然后第二次运行脚本时可能会完全不同。
使用“do shell脚本”AppleScript命令使用命令行shell脚本设置时间可能会得到更好的结果。
Changing system date from the command line
当然,如果您正在以您描述的方式搞乱系统时钟,那么您可能会发现整个计算机出现意外行为。您当然可以看到数据丢失(尤其是网络同步),或者您可能会崩溃Mac或甚至无法启动。