Skip navigation

Beginner question about Applescript

972 Views 8 Replies Latest reply: Apr 24, 2013 7:23 AM by IsaiahvanHunen RSS
Epsylon Calculating status...
Currently Being Moderated
Apr 15, 2011 10:12 AM
Hello,

I'de like to know two things :
- can I use Applescript on an application which does not have any dictionary ?
- do you think it would be possible to make a script which would detect the opening of a window on this application, and automatically display this new window on the front screen ?
iMac, Mac OS X (10.6.7)
  • Niel Level 10 Level 10 (235,215 points)
    Currently Being Moderated
    Apr 15, 2011 10:15 AM (in response to Epsylon)
    can I use Applescript on an application which does not have any dictionary ?


    Not except for a few basic commands: open, run, print, and quit.

    do you think it would be possible to make a script which would detect the opening of a window on this application, and automatically display this new window on the front screen ?


    AppleScripts can't be invoked in response to an event unless that application provides a hook for this purpose.

    (57823)
    iMac Late 2007 Core 2 Duo, Mac OS X (10.5.8)
  • Niel Level 10 Level 10 (235,215 points)
    Currently Being Moderated
    Apr 15, 2011 10:31 AM (in response to Epsylon)
    No, but if you enable access for assistive devices in the Universal Access pane of System Preferences, you can control it through AppleScript as you would with a keyboard and mouse.

    (57824)
    iMac Late 2007 Core 2 Duo, Mac OS X (10.5.8)
  • rccharles Level 5 Level 5 (5,155 points)
    Currently Being Moderated
    Apr 15, 2011 10:59 AM (in response to Epsylon)
    This script will resize a Microsoft Word open window. It does this by simulating the keyboard & mouse.

    Have a look at this script.
    http://discussions.apple.com/thread.jspa?messageID=11060273&#11060273

    While I haven't tried, I believe the latest Automator will let you record a sequence using the mouse for later playback.

    Robert
    iMac G3 600, Mac OS X (10.4.11)
  • rytonbay Calculating status...
    Currently Being Moderated
    Nov 1, 2012 6:47 PM (in response to rccharles)

    You can recorn in applescript, not just in Automater.

  • IsaiahvanHunen Level 1 Level 1 (0 points)
    Currently Being Moderated
    Apr 22, 2013 12:44 PM (in response to Epsylon)

    Hi there,

     

    No, you can't check the opening of an window, but you can check the count of the windows.

    This script would check whether there are windows added;

     

    set theApp to "yourapp"

    set windowcount to (count of windows of application theApp)

    repeat

    if ((count of windows of application theApp) > windowcount) then

      exit repeat

    end if

    end repeat

    --actions

    display dialog "Hey! A window was opened!"

     

    About displaying this new window in front of the screen:

    Usually when applications open windows, there will be in front op the screen, but you can do that manually:

     

    set theApp to "yourapp"

    tell application theApp

    activate

    set index of window (count of windows) to 1

    end tell

  • IsaiahvanHunen Level 1 Level 1 (0 points)
    Currently Being Moderated
    Apr 24, 2013 7:23 AM (in response to IsaiahvanHunen)

    Improved:

     

    set theApp to "yourapp"

    set windowcount to (count of windows of application theApp)

    repeat

    if ((count of windows of application theApp) > windowcount) then

      exit repeat

    else if ((count of windows of application theApp) < windowcount) then

    set windowcount to (count of windows of application theApp)

    end if

    end repeat

     

    --actions

    display dialog "Hey! A window was opened!"

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.