English 中文(简体)
在没有姓名/头衔的窗户内,我如何用 Apple子在方言中点子? [闭门]
原标题:Using AppleScript how do I click a button in a dialog within a window that has no name/title? [closed]
Closed. This question needs details or clarity. It is not currently accepting answers.

Want to improve this question? Add details and clarify the problem by editing this post.

Closed 6 years ago.

我试图写一个果字,把Twitter的切身空出,然后重新启用。 问题一是,确认方言(标题是空洞的),因此,我失去了一个名字,即我如何把 no子作为目标。 这里我迄今为止所做的事情:

tell application "Twitter"
   activate
end tell
tell application "System Events"
   tell process "Twitter"
      tell menu bar 1
         tell menu bar item "Twitter"
            tell menu "Twitter"
               click menu item "Empty Cache"
            end tell
         end tell
      end tell
   end tell
end tell
tell application "System Events"
   click button "Empty Cache" of window "Empty Cache?"
end tell
tell application "Twitter"
   quit
end tell
tell application "Twitter"
   activate
end tell
最佳回答

There are numerous ways to refer to objects within the object hierarchy: name is only one way (see AppleScript Language Guide: Reference Forms. Your script already uses one of the other ways: Index.

tell menu bar 1

这份索引提到菜单:(与许多方案语言一样,阿普兰文清单中的项目从1个而不是0个指数化)。 下面的文字应当满足你们的愿望:

tell application "Twitter" to activate

tell application "System Events"
    tell application process "Twitter"
        click menu item "Empty Cache" of menu "Twitter" of menu bar item "Twitter" of menu bar 1
        delay 1
        --click button "Empty Cache" of front window
        click button "Empty Cache" of window 1
    end tell
end tell

tell application "Twitter"
    quit
    delay 1
    activate
end tell

您也许可以评论<代码>delay 1的行文;我补充说,这些行文使程序放慢,使你能够更容易地看到所发生的情况。

When trying to figure out how to "get at" an object in an application via AppleScript, I often find it helpful to use AppleScript Editor to create little query scripts to try to discover more info about the app. For example, in Twitter, I chose Twitter > Empty Cache to bring up the Empty Cache window. I then ran the following script:

tell application "Twitter"
    set theWindows to every window -- get a list of windows
    (* turns out there s only one window listed,
      so get the first item in the list *)
    set theWindow to first item of theWindows
    -- get the properties of the window
    properties of theWindow
end tell

该书还得出以下结果:

{closeable:true, zoomed:false, class:window, index:1,
  visible:true, name:missing value, miniaturizable:true,
 id:28551, miniaturized:false, resizable:true,
 bounds:{-618, 76, -128, 756}, zoomable:true}
问题回答

暂无回答




相关问题
2 mysql instances in MAC

i recently switched to mac. first and foremost i installed xampp. then for django-python-mysql connectivity, i "somehow" ended up installing a seperate MySQL. now the seperate mysql installation is ...

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Controlling OSX windows

I m trying to control windows of a foreign OSX applications from my application. I d like to 1. move the windows on the screen 2. resize the windows on the screen 3. change the currently active window ...

Switching J2SE versions on Mac OS (SnowLeopard)

My current JDK on Mac OS (10.6) is set to 1.6 and I d like to switch to 1.5. A listing of /System/Library/Frameworks/JavaVM.framework/Versions/ shows: lrwxr-xr-x 1 root wheel 10 Nov 3 18:34 ...

Scrolling inside Vim in Mac s Terminal

I ve been googling around trying to figure out if it s possible to use my mouse wheel to scroll while inside Vim in Mac s Terminal, with no luck. It seems as if only X11 or iTerm support this. Before ...

export to MP3 from quicktime API

A question for Apple,QT programmers. Would like to know if it s possible to export a Movie object to MP3 using the QuickTime API. Preferably the ConvertMovieToFile function. I ve looked at ...

热门标签