Jump to content
Sign in to follow this  
fassbinder

Telling applescript in automator to press a button...

Recommended Posts

fassbinder    0

thanks!

 

i should have written that i have tried watch me do, thing is i want to send this to a client. I know that he wont be able to execute this command. So a script would be the best way for this situation. But yes watch me do is really a good tip! Thank you!

Share this post


Link to post
Share on other sites
johnfoster    48

here's an in-depth article about scripting UI elements. the UI Elements tool listed in the article that has moved. use this link instead. yes, the buttons says it's going to download the source code allowing you to compile your own. don't worry, there's a binary already made inside the zip.

 

http://www.mactech.com/articles/mactech/Vol.21/21.06/UserInterfaceScripting/index.html

Share this post


Link to post
Share on other sites
fassbinder    0

here's an in-depth article about scripting UI elements. the UI Elements tool listed in the article that has moved. use this link instead. yes, the buttons says it's going to download the source code allowing you to compile your own. don't worry, there's a binary already made inside the zip.

 

http://www.mactech.c...ting/index.html

 

Thanks!

 

I've read the article and have come up with the following script for telling it to press the export button:

 

on run {input, parameters}

 

tell application "System Events" to set isUIScriptingEnabled to UI elements enabled

if isUIScriptingEnabled = false then

tell application "System Preferences"

activate

set current pane to pane "com.apple.preference.universalaccess"

display dialog "Your system is not properly configured to run this script.

Please select the \"Enable access for assistive devices\"

checkbox and trigger the script again to proceed."

return

end tell

end if

 

tell application "System Events" to return name of every process

 

tell application "System Events" to set frontmost of process "DNGImporter" to true

 

tell application "System Events"

tell process "DNGImoprter"

click button "Export" of window 1

end tell

end tell

 

return input

end run

 

 

 

The thing is it doesnt press the export button.... all it does is bring DNGImporter to the front.

 

When I put the cursor over the export button Accessibility Inspector says:

 

<AXApplication: "DNGImoprter">

<AXWindow: "DGImporter">

<AXButton: "Export">

 

Attributes:

AXRole: "AXButton"

AXRoleDescription: "button"

AXHelp: "(null)"

AXEnabled: "0"

AXFocused: "0"

AXParent: "<AXWindow: "DNGImporter">"

AXWindow: "<AXWindow: "DNGImporter">"

AXTopLevelUIElement: "<AXWindow: "DNGImporter">"

AXPosition: "x=220 y=444"

AXSize: "w=463 h=64"

AXTitle: "Export"

 

Actions:

AXPress - press

 

 

Or I could do a keystroke to get it to export using cmd + e, but of course Im doing that wring to...

 

tell application "System Events"

tell process "DNGImoprter"

keystroke "E" using {command down}

end tell

end tell

 

return input

end run

Edited by fassbinder

Share this post


Link to post
Share on other sites
johnfoster    48

application automation always feels like it's hacks on top of hacks. it's doesn't really matter how you get it to work as long as it works.

Share this post


Link to post
Share on other sites
fassbinder    0

true. but I'm having problem with writing the script with keystroke that tells it to press cmd + e

 

tell application "System Events"

tell process "DNGImoprter"

keystroke "E" using {command down}

end tell

end tell

 

return input

end run

 

any ideas what im doing wrong?

 

whole script looks like this:

 

on run {input, parameters}

 

tell application "System Events" to set isUIScriptingEnabled to UI elements enabled

if isUIScriptingEnabled = false then

tell application "System Preferences"

activate

set current pane to pane "com.apple.preference.universalaccess"

display dialog "Your system is not properly configured to run this script.

Please select the \"Enable access for assistive devices\"

checkbox and trigger the script again to proceed."

return

end tell

end if

 

tell application "System Events" to return name of every process

 

tell application "System Events" to set frontmost of process "DNGImporter" to true

 

tell application "System Events"

activate

tell process "DNGImporter"

keystroke "E" using {command down}

end tell

end tell

 

return input

end run

Edited by fassbinder

Share this post


Link to post
Share on other sites
johnfoster    48

use a lower case "e".

Share this post


Link to post
Share on other sites
johnfoster    48

do you have link to this app? I looked but didn't find one.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing

    No registered users viewing this page.

  • Who's Online (See full list)

    There are no registered users currently online

×