0

EDIT: I'm trying to save a session file from the Web Proxy Debugging App Charles (http://www.charlesproxy.com/) using AppleScript. Basically, I select "Export", put in a temp name, and then save it. However, after I click on combo box 2, which is the "Format" area, and then try to click on pop up button "XML Session File (.xml)", the Applescript Editor throws an error saying it can't find it.

At the moment I hacked it with the following code, but for some reason it only works on the Applescript Editor and sometimes in Terminal/my code, especially when I am doing other actions at the same time.

tell application "Charles"
    activate
end tell

tell application "System Events"
    tell process "Charles"
        tell menu bar 1
            click menu bar item "File"
            tell menu "File"
                click menu item "Export..."
            end tell
        end tell
        tell window "Save"
            keystroke "tempCharles"
            delay 0.5
            click combo box 2
            delay 0.5
            key code 125 -- down arrow
            delay 0.2
            key code 125
            delay 0.2
            key code 125
            delay 0.2
            key code 125
            delay 0.2
            keystroke return
            delay 0.4
            keystroke return
            delay 0.4
            keystroke return
        end tell
    end tell
end tell

I want my code to look something like this

    tell window "Save"
        keystroke "tempCharles.xml"
        delay 3
        click combo box 2
        tell combo box 2
            click pop up button "XML Session File (.xml)"
        end tell
        click button "Save"
    end tell

Any hack is fine too. Before posting, trying running "osascript" on Terminal to check if it works not through AppleScript Editor.

2 Answers2

0

set value of text field 1 of window 1 didn't seem to work either, but you could try just using keystroke:

delay 0.5 -- time to release modifier keys if the script is run with a shortcut like cmd-R
tell application "System Events" to tell process "Charles"
    set frontmost to true
    click menu item "Save..." of menu 1 of menu bar item "File" of menu bar 1
    keystroke "templog" & return
end tell
Lri
  • 26,768
  • 8
  • 84
  • 82
0

Yep that worked! I just added

-- Got rid of the "set text" line
keystroke return
delay 1
click button "Save"

That was very subtle and I've seen that before but now I realize better what it is. Thanks a lot!