Yes I did get the same behaviour without editing the post and I ran with 5 pictures. I have just tried again as asked and the tweets stop on the last in the list. What I did try was deleting the last tweet from the twitter feed and running again. This then posted the last tweet again! Hop that helps?
I tried the syntax above, and it posted the tweets, but not the images.
Not sure if this will help, as you may already be aware of it, but the code below works if the images are hard coded, as in the example below:
set imagePath to "HARD Disk X:Users:USERNAME:Pictures:TweetImages:test.jpg"
tweet "Tweet testing" using account "MyTwitterAccount" with image imagePath
It works on the first set of tweets, and cycles around once the list is complete, starting over as expected. However, it only posts the same tweet (tweet 21) of the second list of tweets! Both sets post with images, whether in the Pictures folder or a subfolder of the pictures folder, which it wasnât doing earlier in the day when I tested, but is since coming back to post this message.
I know you are at the end of you tether with this but, I would be grateful if you could look at why the second list of tweets are not incrementing beyond the first message (tweet 21) in the list, as I canât spot anything myself.
Also, would there be an easy way at the start of the code to enable / disable the accounts? For example use account 1 and 2 or use only account one or account two depending on what is set?
I have tried the code using option 1 and 2 when presented, and get the error message below. I have not been able to confirm if the second set of messages increment, as nothing posts currently.
Please forgive me, I was not clear in my request for the ability to enable / disable account use. I was after a hard coded option for enabling, or disabling an account, and not anything requiring human interaction or button selections.
Perhaps something at the start of the code, like the (rough) example below, which you provided in a different form for another script?
property howMany : 1
# 0 = disable all tweeting - Nothing will be posted. Use for safety when code is not intended to run
# 1 = use tweeterAccount, tweeterAccount2 - Default setting. This will use both defined accounts
# 2 = use tweeterAccount - Use only first account defined in the list of available accounts
# 3 = use tweeterAccount2 - Use only the Second account defined in the list of available accounts
-- If more than three accounts are defined in the system this code will ensure only those required, and defined, are accessed and used via the script.
On reflection I think I am trying to make the code far more complex than needed, as I believe I could simply remark out the second account tweet line, if it is not needed, or used.
As the code was working, minus the issue of not posting the second line of tweets beyond the first entry, could we revert to a simpler version that I can test each tweet account with to ensure the lists post, with an image?
I have tried several attempts to make the code run, and the following message box appears when running the latest code:
I know you donât have access to twitter or use twitter, so I ran some local tests, which I hope help. Please forgive me if I am teaching you what you already know.
The following code tells me I have three accounts setup:
tell application "Twitter Scripter"
-- returns a list of usernames for the OS defined Twitter accounts
set availableAccounts to available accounts
end tell
-- Result Screen: {"Hal","Batman", "Asterix"}
The above response for the returned list shows there are three accounts, all are active. Account names have been renamed for privacy.
Running the following command and replacing the âitemâ number in each run, shows me which account a tweet will be posted from, based on the âItemâ number âsetâ :
tell application "Twitter Scripter"
-----------------------------------------
-- 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 1 of availableAccounts -- uses account named Hal (default for live Tweets)
#set twitterAccount2 to item 2 of availableAccounts -- uses account named Batman (secondary account for live tweets)
set twitterAccount2 to item 3 of availableAccounts -- uses account named Asterix (default for testing and not used for live tweets)
#Replacing the item number with either 1, 2 or 3, as shown above, confirms in the result screen which account the number relates to. Below is the output per number
# 1 = Hal returned from code when 'item' was set to 1
# 2 = Batman returned from code when 'item' was set to 2
# 3 = Asterix (item 3 is our test account) returned from code when 'item' was set to 3
end tell
return twitterAccount
-- Result Screen: "Asterix"
# depending on the item number above the output screen shows the account selected. In this instance 3 is set, which is our test account
Now using this command we set the account to use for tweeting:
set twitterAccount to item 3 of availableAccounts -- NOTE: set 'item' 3 which is the account [Asterix] for testing.
#Account three will be used for twitterAccount during tests, and also for testing twitterAccount2 when the primary twitterAccount is disabled.
This then wraps into the following commands for a simple text based tweet test, which works well with the âsetâ twitterAccount. Typically we are testing one account setup at a time to avoid posting to live accounts!
tweet "I'm tweeting from my desktop!" using account twitterAccount
#OR
tweet 'This is the second account for tweets!" using account twitterAccount2
-- remember to change the 'item' number for each account. In our case we always use 3 for tests!
# I have removed image tweeting from the code for now to make life easier.
What I canât see in your new code is where to âsetâ the twitter account to use via twitter scripter. Please forgive me if itâs in the code, I just cant spot where to set this, and or what code to use.
I have inserted comments commencing with â to your questions below. I am sorry for any confusion I am causing, and I am grateful for your amazing patience with me.
The requirement below, in my mind is the same as above. However, it seems that the âitemâ is what defines the account to use, so being able to quickly set this is essential.
I have made a small adjustment to the list below, which might clarify matters.
The real life configuration would be 2 for Index1 and 3 for Index2
However, the ability to change the item number associated with the index would be essential. Could this be achieved by simply editing the code, and changing the item number(s) as required?
When I change the settings in the code below to any value the result is constantly the same! Is that meant to happen? I was expecting the accounts shown in the result window to change.
The code below when run gave the output under result. The result changed if I changed the values up to the value 9, upon which it presented a coded message, as intended, requesting an account be set.
The corrected code in message #29 appears to work! Based on the data entered, I get the following values back.
Selecting howMany = 3
set howMany to 3 # Play with values 1, 2 or 3. In the full script, the case 0 is filtered before calling the handler.
set {tweeterAccount, tweeterAccount2} to my setTweeterAccount(howMany) # Corrected a typo
on setTweeterAccount(howMany)
# Here, howMany may be 1, 2 or 3
# 1 means use account index indexForAccount and account index indexForAccount2
# 2 means use account index indexForAccount
# 3 means use account index indexForAccount2
# play with the 2 values below
set indexForAccount to 1
set indexForAccount2 to 6
-- Result displayed as: {"account6", false}
Selecting howMany = 2
set howMany to 2 # Play with values 1, 2 or 3. In the full script, the case 0 is filtered before calling the handler.
set {tweeterAccount, tweeterAccount2} to my setTweeterAccount(howMany) # Corrected a typo
on setTweeterAccount(howMany)
# Here, howMany may be 1, 2 or 3
# 1 means use account index indexForAccount and account index indexForAccount2
# 2 means use account index indexForAccount
# 3 means use account index indexForAccount2
# play with the 2 values below
set indexForAccount to 1
set indexForAccount2 to 6
-- Result displayed as: {"account1", false}
Selecting howMany = 1
set howMany to 1 # Play with values 1, 2 or 3. In the full script, the case 0 is filtered before calling the handler.
set {tweeterAccount, tweeterAccount2} to my setTweeterAccount(howMany) # Corrected a typo
on setTweeterAccount(howMany)
# Here, howMany may be 1, 2 or 3
# 1 means use account index indexForAccount and account index indexForAccount2
# 2 means use account index indexForAccount
# 3 means use account index indexForAccount2
# play with the 2 values below
set indexForAccount to 1
set indexForAccount2 to 6
-- Result displayed as: {"account1", "account6"}