Hi Guys,
I have made some small progress with the following code. I would appreciate some assistance in building on the code to run sequentially tweets from the defined tweets in ‘theTweets’ list, and to include images dropped onto the app from within a subfolder of the picture folder, when tweeting. Image have to be in this location for security purposes, according to Twitter Scripter.
The code provided kindly by Kerflooey worked with hard coded image names, although the tweets failed. I hope I can add images to tweets from the safe folder location by dropping them on the droplet, and therefor not requiring the image name to be hard coded in a similar fashion to the code Yvan created for us to use for emails.
Hopefully, someone can assist with the missing code elements, as we seem to be on the right path.
Please note. I am the worst kind of coder, as I am not a coder at all!
Thank you all in advance.
tell application "Twitter Scripter"
# First account in available list = Name
# Second account in available list = Primary Name
# Note the first account may not be the default account! Naming appears to be alphabetical when results are returned
-----------------------------------------
-- Account commands
-----------------------------------------
-- returns a list of usernames for the OS defined Twitter accounts
set availableAccounts to available accounts
-- Test to check we've got at least one account
if ((count of availableAccounts) is 0) then
tell application "Finder"
activate
display dialog "Please set up at least one Twitter account in your System Preferences, and allow it to be accessed by \"Twitter Scripter\"" buttons {"OK"} default button "OK" with icon 2 with title "No Available Twitter Accounts"
end tell
return
end if
set twitterAccount to item 2 of availableAccounts -- choose the second (primary) available account
end tell
#set theText to {"Uno", "Dos", "Tweet 3", "Tweet 4"} # This approach posts ALL tweets at once if there is no associated image to match the tweets!
property theTweets : {"Testing Tweets from my desktop again", "#HappyDays more testing of desktop tweets", "Follow the tweeting challenge"} # This version posts a single tweet, however fails on second run
property currentIndex1 : 1 # Tweets for Account 2, which is our primary account!
#on open droppedFiles # droppedFiles is a list of aliases
# new_tweet(droppedFiles)
#end open
-- Used to try and run the code when an image is opened with the droplet within a subfolder of the pictures folder
set theTweets to item currentIndex1 of theTweets
set currentIndex1 to currentIndex1 + 1
if currentIndex1 > (count theTweets) then set currentIndex1 to 1
#set thePicNames to {} # Removed for initial text based tweeting only as did not run, per my previous update
#set thePicPath to (path to pictures folder) as text #Subfolder in the Pictures folder will be used
#set thePix to {}
#repeat with aPicName in thePicNames
#set thePix to thePix & (thePicPath & (aPicName as text))
#end repeat
#set picNum to 0
tell application "Twitter Scripter"
#repeat with aTweet in theText
#set picNum to (picNum + 1)
#tweet (aTweet as text) using account twitterAccount2 with image (item picNum of thePix)
#end repeat
#tweet (theTweets as text) using account twitterAccount2 with image (item picNum of thePix)
tweet (theTweets as text) using account twitterAccount2
-- Tweet works but does not increment from theTweets list! Posts a random character when the code is run a second time, and then returns a failed result if run again!
end tell