Retrieving all UI Elements from window with Applescript

Hi All..
I want to retrieve all the ui elements from one of the window in runtime with Applescript.
The problem is in order to get the elements of the particular window i need to pass thru the hierarchy like UI element 1 of scroll area 1 of window 1 etc..
How do i get the hierarchy at the runtime??
For eg: if the hierarchy level is 3, i can get the UI elemets like.. ui elements of ui elements of ui elements of window 1.. this works fine
but i want to repeat the same statement in loop, till i get some elements, how do i achieve the same??
I tried the below code its not working for me... Pls suggest
set allButtons to {}
set i to 0
tell application "System Events"
    tell process "Install Adobe Reader"
        set num to count of UI elements of window 2
        set element to every UI element of window 2
              repeat with i from 0 to num
            if class of element is button then
                return true
            else
                set element to (a reference to UI elements of element)
                set num to count of UI elements of element
                end if
        end repeat
    end tell
end tell

madhusudhanjr wrote:
actually am implementing Applescripts in Java, the output what we get in Java is not exactly similar to Applescript.. Is their any way to make a list or Array of the above codes output??
Because they are objects.
Here's how to convert these objects in  text format :
set allButtons to ""
tell application "System Events"
      tell process "Install Adobe Reader"
            with timeout of 0 seconds
                  set tElements to entire contents of window 1
            end timeout
            repeat with i in tElements
                  if class of i is button then try
                        i as text
                  on error err
                        tell my cleanUpErr(err) to if it is not "" then set allButtons to allButtons & it & linefeed
                  end try
            end repeat
      end tell
end tell
allButtons
on cleanUpErr(t)
      set oTID to text item delimiters
      try
            set text item delimiters to "«" -- remove description of the error at beginning of the text
            set t to "«" & (text items 2 thru -1 of t) as text
            set text item delimiters to " of «class pcap»" -- remove 'of process "xxxx" of application "System Events"'
            set r to text item 1 of t
            set text item delimiters to oTID
            return r -- return object in text format
      end try
      set text item delimiters to oTID
      return ""
end cleanUpErr
You will get a button to each line (the last line will be empty).
Here is an example of the result :
«class butT» 1 of window "xyz"
«class butT» "bla" of window "xyz"
«class butT» 3 of window "xyz"
«class butT» "OK" of «class scrb» 1 of «class scra» 1 of window "xyz"
Each line is compilable in (osascript or in the Editor) without changing the text even if some of the classes are Raw Code --> «class butT»

Similar Messages

  • How to retrieve all users in the portal with UME API

    Hi everybody,
    I would like to know how to retrieve all the users from a portal, which uses LDAP as a source (there are users created in the portal as well)
    My code snippet is :
    IUserFactory userFactory = UMFactory.getUserFactory();
    UserSearchFilter searchFilter = userFactory.getUserSearchFilter();
    searchFilter.setDisplayName("*", ISearchAttribute.LIKE_OPERATOR, false);
    ISearchResult searchResult = userFactory.searchUsers(searchFilter);
    My problem is that with the code above, only the users created in the portal are displayed, and no LDAP users.
    Does someone know how to retrieve all the users whatever is the source?
    Regards
    Renaud

    prakash's code should work.
    however, mine code below doesn't user a search filter. it retrieves everyuser including users like indexadmin etc. Note:
    result.next().toString();
    returns a weird uniqueID used in the portal world.
    getUniqueName()
    gives your the usernames (sAMAccountName in Microsoft AD) people use to logon to the portal.
    try {
      IUserFactory uf = UMFactory.getUserFactory();
      ISearchResult result = uf.getUniqueIDs();
      while (result.hasNext()) {
        String uniqueid = result.next().toString();
        IUser user = uf.getUser(uniqueid);
        String userid = user.getUniqueName();
    } catch(Exception e) {
      //systemout

  • I sync a specific photos folder from my computer to my iPhone.  However, that folder was lost due to a crash on my computer.  But all of the Synced Photos are still on my iPhone.  How do I retrieve all those photos from my iPhone?

    I sync a specific photos folder from my computer to my iPhone.  However, that folder was lost due to a crash on my computer.  But all of the Synced Photos are still on my iPhone.  How do I retrieve all those photos from my iPhone?

    ManSinha wrote:
    Do you have a Windows computer or Mac?
    If Windows - and it has iTunes installed - you should see an Autoplay explorer when you connect your iPhone - this should let you see the pictures and transfer them back to your computer
    Wrong. That only works for pictures in the Camera Roll, not those in the Photo Album app.

  • The logic board on my MacBook Pro has failed. How do I retrieve all my data from the hard drive?

    The logic board on my MacBook Pro has failed. How do I retrieve all my data from the hard drive?

    Remove the drive and put it in an external enclosure. Backup the drive completely. Repartition and format the drive. Replace the drive into the computer. Take the computer in for the logicboard replacement.

  • How do I change platform for downloading and installing Photoshop Elements from Windows to Mac?

    How do I change platform for downloading and installing Photoshop Elements from Windows to Mac?

    As long as your license supports both platforms you should only have to download the Mac version and install/activate using your serial number.  If you need help finding a link to download the file, please indicate the PSE version you need.

  • I'm got replacement 5c, how do I retrieve all my info from the cloud?

    i had to get a replacement due to dropping my orginal 5c, I was able to retrieve all my info from the clould from an older model 4c , however I haven't been able retrieve all my info from the original 5c how can I can retrieve it to my current replacement from the cloud?

    Hello vejames,
    Thanks for using Apple Support Communities.
    If you need to restore your replaced iPhone from either an iTunes or iCloud backup then you can follow the directions in the article below to help walk you through the process.
    Back up and restore your iPhone, iPad, or iPod touch using iCloud or iTunes - Apple Support
    Cheers,
    Alex H.

  • I switched to android, but all my texts from pepole with iphones still go to my old iphone

    i switched to android, but all my texts from pepole with iphones still go to my old iphone

    yep, and i unregistered my device, and i turned off everything in iCloud.........  This is incredibly frustrating i've been missing texts for a month!

  • HT201263 I would like retrieve all my data from my IPhone 4S after I lost all my data! Please help! ? Thank You.

    I would like retrieve all my data from my IPhone 4S after I lost all my data due constant Apple logo on! After I restored this phone I lost all my contacts, text messages, pictures, videos..!!! The question I have is if I never backed up to iCloud and iTunes is there any way I can retrieve all my data that was before restoring this iPhone 4S. Please help! ? I greatly appreciated !!!

    If you never synced your phone to your computer and your contacts were not synced to iCloud or another cloud-based service, everything is gone. You will have to start fro scratch.
    ~Lyssa

  • How to retrieve all the data from a BLOB using view-generated accessor

    I am using JDeveveloper 10g v. 10.1.3 and am storing an image in a database as a blob object and need to retrieve all of the data to get the entire image and store it in an ImageIcon. The code I have works partially in that it retrieves the correct data, but only gets a piece of it, leaving me with a partial image.
    AppModuleImpl am;
    ImageVwViewImpl vo;
    am = (AppModuleImpl)panelBinding.getDataControl().getDataProvider();
    vo = (ImageVwViewImpl)am.findViewObject("ImageVwView");
    ImageVwViewRowImpl ivo = (ImageVwViewRowImpl)vo.getCurrentRow();
    ImageIcon icon = new ImageIcon(ivo.getImage().getBytes(1, (int)ivo.getImage().getBufferSize()));
    jULabel1.setIcon(icon);I either need to know how to use a stream to get the data out (from BlobDomain method getBinaryStream()), or how to get the other chunks of data separately.
    edit: I know the problem is that getBufferSize() returns an int which is too small to hold all the data, but need to know what to use instead. Thanks!

    This is the code I'm using now. Same problem :(
    AppModuleImpl am;
            ImageVwViewImpl vo;
            am = (AppModuleImpl)panelBinding.getDataControl().getDataProvider();
            vo = (ImageVwViewImpl)am.findViewObject("ImageVwView");
            ImageVwViewRowImpl ivo = (ImageVwViewRowImpl)vo.getCurrentRow();  
            ImageIcon icon = new ImageIcon(ivo.getImage().toByteArray());
            jULabel1.setIcon(icon);

  • Closing active terminal window with applescript

    I made a very basic script to lock my screen, and I like how it works. Some of my co-workers would also like it but it has one problem.
    When the script runs, a terminal box pops up at the end saying [process complete]. I can click through this and I don't care, they do.
    I can't just killall terminal because we use terminal and that could kill our work.
    We sometimes need to see output from a script and like the process complete, so don't want to reconfigure our systems to never display it.
    I'm trying to find a way to use applescript or something to kill the active terminal window, or the window with the title of LockScreen or something.
    Anyone have an idea?
    I was hoping something like this would exist but it doesn't seem to: tell application "Terminal" to close window

    Here is an easy approach.  Start Applications -> Automator
    Select Application
    In Automator search for "Start Screen Saver".  This should be under Library->Utilities
    Drag "Start Screen Saver" to the right side panel.
    Save the Automator app.
    If the user has System Preferencs -> Security -> Require Password ... set, then one the screen saver has started running, it will require the user to enter their password before getting control back.
    This Automator app can be double clicked, it will not require the terminal.
    With respect to your script.  If this is a shell script, AND if you wish to continue using it, then you could create an Automator app that uses "Run Shell Script" under Automator Library->Utilities.  This will also NOT require the use of Terminal, however, be aware that when Automator runs a shell script it DOES NOT have the same environment as when you are running a shell script at your Terminal prompt.  There are very few environment variables set, and for example the USER, HOME, current working directory, PATH, etc... may not be the same.  If you have dependencies on specific environment information, you may want to write a simple automator script the using "Run Shell Script" to output various environment information into a file so you can see what you have to work with
    (id -a
    pwd
    echo "$#"
    echo "$@"
    printenv
    ) >/tmp/automator.environment.txt

  • How can I retrieve all row information from a database table.

    I have a jsp file which calls info from columns in a table. My question, is how can I edit it so that it retrieves all the rows?
    I tried using resultset SalesInfo.next() which only retrieves the last row value and resultset SalesInfo.first() which only retrieves the first row value.
    Here is my code
    public ResultSet SalesInfo;
    public void getSalesInfo()
              try
                   Statement stmt = db.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
                   SalesInfo = stmt.executeQuery("SELECT sales_id,cust_id,product_id, quantity from sales;");
                   SalesInfo.first();
                   setCartsales_id (SalesInfo.getString("sales_id"));
                   setCartcust_id (SalesInfo.getString("cust_id"));
                   setCartProduct_id(SalesInfo.getString("product_id"));
                   setCartquantity (SalesInfo.getString("quantity"));
              catch(SQLException e )
                   setCartsales_id(e.toString());
                   e.printStackTrace();
    Also I apologise for not having the proper code format as I had a problem with my keyboard.

         public class SalesDB{
        public static synchronized Vector getSalesDetail(Connection connection) throws SQLException{
            String query = "SELECT * from Sales;"
           Statement statement = connection.createStatement();
            ResultSet results = statement.executeQuery(query);
            Vector sale_details = new Vector();
            while(results.next() == true){
         SaleInfo saleInfo = new    SaleInfo(results.getString("sales_id"),results.getDouble("cust_id"),results.getString("product_id"));
                sale_details.add(saleInfo);
            results.close();
            statement.close();
            return sale_details;
    }

  • Accessing ext3 partitions from Windows with FS Driver

    Hi everyone,
    I have a slight probem. I'm dual-booting ArchLinux and Windows. Here is my partition scheme:
    /dev/sda1 (NTFS) Lenovo Recovery partition
    /dev/sda2 (NTFS) Windows
    /dev/sda3 (ext2) /boot
    /dev/sda5 (JFS) /
    /dev/sda6 (JFS) /home
    /dev/sda7 (ext3) [documents] partition mounted on /media/data
    /dev/sda8 (swap) swap
    Everything works fine on the Linux side (of course).
    The problem is that I use http://www.fs-driver.org/ to access my documents (/dev/sda7) from Windows.
    This worked fine (I was using Kubuntu) but now I had to format the disk in order to install ArchLinux and FS Driver would not recognize the "documents" partition.
    I think it might be because the partition is not PRIMARY but LOGICAL. Is there a way to fix this without reformatting everything (just formatting /dev/sda7 is fine with me) ?
    Thank you in advance
    Last edited by yms (2009-09-11 14:08:17)

    Hi, I just stumbled across this one and thought I'd throw in my two cents....
    Something I've found about windows is that it's -very- picky about partition sizes.
    For  instance, on a new system of mine, I did dual booting windows/Linux from partitions on the same hard drive.
    The windows partition was first.  After creating my Linux partitions, windows would no longer boot, said the partition table was corrupt.
    (All partitions were primary)
    The solution?  I created my Linux partitions using windows tools (which wasted around 10Gigs of hard drive space) and finished them off with linux tools.
    Everything worked fine then.
    Bottom line, Linux can use partition sizes that (some?) windows will refuse to use.
    You should be able to simply remove the last 2 partitions (sda7 and sda8).  Any partitioner should work (gparted, cfdisk, windows logical disk manager).  Don't forget to move your documents.  If you do this from your installed Linux system, don't forget to disable your swap space or you won't be able to remove that partition.
    ...might also need to unmount /dev/sda7 to use cfdisk... I think gparted does this automatically but don't quote me on that one...
    Then you can recreate the last two partitions using windows.  Then use Linux to set their types, format them, and restore your documents.
    Just to simplify things with the swap space, it's probably easier to use a live distro than your installed Linux.
    If your fstab uses UUID's, don't forget to update as formatting will assign new UUID's to the partitions.
    ... should solve at least half the problem.
    laters,
    b

  • Trying to retrieve all the records from the file on desktop

    HI All
    I have one particular problem. I was given a text file which as 7000 records with length 512 each in a continues string. I Changed begining of each record with comma  in that text and saved it in .csv , when I try to upload the file into my program's internal table.
    It is still giving one record. I used
    itab_EXTRACT1 declared as
    DATA: begin of itab_extract OCCURS 0,
            extract1(512) type c,
          end of itab_extract.
    call method cl_gui_frontend_services => gui_upload
        exporting
          filename                = Xfile
        filetype                    = 'ASC'
         has_field_separator     = 'X'
        changing
          data_tab                = itab_EXTRACT1
      exceptions
        others                  = 17.
      Is there a way how to retrieve all the records into the internal table.
    Thanks
    Ravi

    Hi Ravi,
    I don't know if this is the correct solution, but I think it will work.
    Declare your internal table (itab_extract) with the maximum length which your file will occupy.
    Create another internal table (itab) with field (text) length 512.
    Populate the internal table itab_extract using GUI_UPLOAD.
    Then write this code
    l_index = 1.
    itab-text = itab_extract-extract1+0(512).
    append itab.
    do.
    n = ( l_index * 512 ) + 1.
    itab-text = itab_extract-extract1+n(512).
    append itab.
    if ( itab-text is initial ).
    exit.
    endif.
    enddo.
    Let me know if I miss anything.

  • HT5824 How can I delete all my contacts from icloud with a single command?

    I would like to delete all my contacts from iCloud so when I synchronize with my other devices, the one I already have don't be duplicated or deleted

    If you delete all your iCloud contacts, then enable contact syncing with your other devices, the empty iCloud contacts are likely to overwrite the contacts on your other devices and you will lose them.
    Do you have a master list of contacts on one of your devices that you are trying to replace the iCloud contacts with?

  • Installation from Windows with a'n closed Display

    Hi, i have a big problem.
    On my Macbook pro ist the display broken and i must install windows with an extern TFT. Under Mac OSX is that not a Problem, it switch to the extern display.
    The installation-procedure from Windows activate the internal display (that was at me broken).
    Is there any hints or tips, so that i can install Windows with bootcamp on an externeal display?

    I doubt this is possible, and even if it was, it would not be advisable to use an OS that was installed on one computer, then move the installation to a computer with a different processor architecture. Doing that is asking for trouble.
    If you have any further questions about Bootcamp, I suggest you post them in Apple's Bookcamp discussion forum.

Maybe you are looking for

  • Clamshell mode?

    Can a TiBook (1GHz SuperDrive) run in clamshell mode? (i.e. with the lid closed, using an external monitor)

  • ASP data collection

    This is a post from ASP data collection in which I was referred to this forum.  Sorry I did not start here.  I have since found a substandard, overly complex, and resource consuming solution, but have not had time to drill down to make it work yet. 

  • Can I get Href attributes in HTML page ?

    Can I get Href attributes in HTML page ? I want to get HTML's table include href. I want to get columns "item", "item href", "value" from below table in a HTML web page. <table> <thead> <th>item</th> <th>value</th> </thead> <tbody> <tr> <td><a href="

  • When ipod connect via usb to my computer what is best method to disconnect.

    i have connected my ipod to my computer, via usb   but I am not sure what is the best way to disconnect;  i have been simply pulling it out of the computer.  But I think I lost my music downloads when last I did this

  • Call a method from another methond - MVC

    Hey I have string method and want to call it trough another method, but I'm not quit sure how to do that. All help appreciated from Here is the code: class model control cont; String name = cont.lesInn();   // i know this is wrong, because it require