Skip to content

Instantly share code, notes, and snippets.

@azur256
Created July 19, 2012 09:47
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Auto insert photos to MarsEdit editor
on run
tell application "MarsEdit" to activate
tell application "System Events"
openUploadWindow() of me
try
set uploadWindow to getUploadWindow() of me
click button 6 of uploadWindow
on error
openUploadWindow() of me
delay 2
set uploadWindow to getUploadWindow() of me
click button 6 of uploadWindow
end try
set itemCount to getItemCount() of me
if itemCount is not 0 then
repeat with index from 1 to itemCount - 1
selectItem(index) of me
click button 5 of uploadWindow
try
openUploadWindow() of me
delay 2
set uploadWindow to getUploadWindow() of me
click button 6 of uploadWindow
on error
openUploadWindow() of me
delay 2
set uploadWindow to getUploadWindow() of me
click button 6 of uploadWindow
end try
end repeat
selectItem(itemCount) of me
click button 5 of uploadWindow
end if
end tell
end run
on openUploadWindow()
tell application "MarsEdit" to activate
tell application "System Events"
key down {command}
keystroke "3"
key up {command}
end tell
end openUploadWindow
on getUploadWindow()
tell application "System Events"
tell process "MarsEdit"
set targetWindow to ""
set currentWindows to windows
repeat with currentWindow in currentWindows
if (name of currentWindow as string is "Upload Utility") then
set targetWindow to currentWindow
exit repeat
end if
end repeat
end tell
end tell
if targetWindow is "" then
error "Can't find Upload Utility"
else
return targetWindow
end if
end getUploadWindow
on getItemCount()
tell application "System Events"
tell process "MarsEdit"
tell list 1 of scroll area 2 of scroll area 1 of browser 1 of splitter group 1 of group 1 of sheet 1 of window 1
set lCount to count of UI elements
end tell
end tell
end tell
return lCount
end getItemCount
on selectItem(index)
tell application "System Events"
tell process "MarsEdit"
select text field index of list 1 of scroll area 2 of scroll area 1 of browser 1 of splitter group 1 of group 1 of sheet 1 of window 1
click button 1 of sheet 1 of window 1
end tell
end tell
end selectItem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment