Saturday, November 18, 2017

#26 2017-07-10 11:50:40 am

Prescience
Member
From:: United Kingdom
Registered: 2017-02-03
Posts: 43

Re: Help Completing / Coding Droplet for Tweeting via Twitter Scripter

Hello Yvan,

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. smile

If I understand well what is written in message #24

if howMany = 1 you want to send tweets from list theTweets to item 3 of availableAccounts and tweets from list theTweets2 to item 2 of of availableAccounts -- Correct. This sets the twitter account for item 3 to tweeterAccount and item 2 to tweeterAccount2 in the code.  This ensures the correct accounts to post tweets from are defined.

if howMany = 2 you want to send tweets from list theTweets to item 3 of availableAccounts -- Correct
if howMany = 3 you want to send tweets from list theTweets2 to item 2 of availableAccounts -- Correct

(I continue to have a doubt upon the list to use)

I think the issue is we could have 4 twitter accounts setup, and using the 'item' to define the correct account to tweet from is essential.  The droplet will run with the predefined account such as item 3 and 2 as you have used above. However, this could be item 3 and 4 if item 4 is a new twitter account, and the correct account to work with.

The list in the code will never change, it will only ever be the item number from available twitter accounts to use, as per, 0 = None , 1 = both accounts,  2 = tweeterAccount (1) only, and 3 = tweeterAccount2 (2) only.


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.

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 accounts from the available accounts set using the relevant 'item' [number(s)]
# 2 = use tweeterAccount - Use only First account from the available accounts as set using 'item' [number] i.e. 3
# 3 = use tweeterAccount2 - Use only the Second account defined in the list of available accounts as set using 'item' [number] i.e.2


Wisdom is knowing the power of experience, understanding the knowledge learnt on your personal journey through time, and having the empathy to share with others.

Offline

 

#27 2017-07-10 12:09:22 pm

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 3201

Re: Help Completing / Coding Droplet for Tweeting via Twitter Scripter

Did a bit of cleaning

Yvan KOENIG running Sierra 10.12.5 in French (VALLAURIS, France) lundi 10 juillet 2017 19:09:16

Last edited by Yvan Koenig (2017-07-12 09:07:18 am)

Offline

 

#28 2017-07-10 12:23:51 pm

Prescience
Member
From:: United Kingdom
Registered: 2017-02-03
Posts: 43

Re: Help Completing / Coding Droplet for Tweeting via Twitter Scripter

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?

OK. It seems that I know what to with the configuration used for tests.
What for the "real life configuration"?
which would be the index corresponding to 3 ?
which would be the index corresponding to 2 ?


Wisdom is knowing the power of experience, understanding the knowledge learnt on your personal journey through time, and having the empathy to share with others.

Offline

 

#29 2017-07-10 01:52:12 pm

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 3201

Re: Help Completing / Coding Droplet for Tweeting via Twitter Scripter

Did a bit of cleaning

Yvan KOENIG running Sierra 10.12.5 in French (VALLAURIS, France) lundi 10 juillet 2017 20:51:47

Last edited by Yvan Koenig (2017-07-12 09:06:18 am)

Offline

 

#30 2017-07-10 02:32:08 pm

Prescience
Member
From:: United Kingdom
Registered: 2017-02-03
Posts: 43

Re: Help Completing / Coding Droplet for Tweeting via Twitter Scripter

Hi Yvan,

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.

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(1)

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 2
   set indexForAccount2 to 3


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.

set indexForAccount to 2
  set indexForAccount2 to 3


-- Result: {"account2", "account3"}


Wisdom is knowing the power of experience, understanding the knowledge learnt on your personal journey through time, and having the empathy to share with others.

Offline

 

#31 2017-07-11 04:43:29 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 3201

Re: Help Completing / Coding Droplet for Tweeting via Twitter Scripter

Did a bit of cleaning

Yvan KOENIG running Sierra 10.12.5 in French (VALLAURIS, France) mardi 11 juillet 2017 11:42:03

Last edited by Yvan Koenig (2017-07-12 09:06:41 am)

Offline

 

#32 2017-07-11 05:16:11 am

Prescience
Member
From:: United Kingdom
Registered: 2017-02-03
Posts: 43

Re: Help Completing / Coding Droplet for Tweeting via Twitter Scripter

Hello Yvan,

The corrected code in message #29 appears to work! Based on the data entered, I get the following values back.

Selecting howMany = 3

Applescript:



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

Applescript:


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

Applescript:


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"}


Wisdom is knowing the power of experience, understanding the knowledge learnt on your personal journey through time, and having the empathy to share with others.

Offline

 

#33 2017-07-11 06:56:38 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 3201

Re: Help Completing / Coding Droplet for Tweeting via Twitter Scripter

Here is the true script :

Applescript:

(*
[url]http://macscripter.net/edit.php?id=190729[/url]
*)

property theTweets : {"Testing Tweets from my desktop again", "#HappyDays more testing of desktop tweets", "Follow the tweeting challenge"}

property theTweets2 : {"tweet21", "tweet 22", "tweet 23", "tweet 24"}

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.

#=====

# Entry point used by double click or by calling from the editor
on run
   set droppedFiles to choose file "Select some picture files" of type {"png", "jpeg", "jpg", "tiff", "tif"} default location (path to pictures folder) with multiple selections allowed
   my main(droppedFiles) # droppedFiles is a list of aliases
end run

#=====

# Entry point used by drag & drop
on open droppedFiles # droppedFiles is a list of aliases
   my main(droppedFiles)
end open

#=====

on main(droppedFiles) # droppedFiles is a list of aliases
   # Defining the local variables is useful for Script Debugger
   local maxLen, theDelay, path2log, indexPath, currentIndexes, currentIndex1, currentIndex2
   local twoAccounts, tweeterAccount, tweeterAccount2, cnt1, cnt2, num1, num2, i, aFile, aPictPath, maxi
   
   if howMany = 0 then error number -128
   
   set maxLen to 140 - 1 # free space for a space character
   set theDelay to 0.1 # I assume that a delay may be needed between two tweets. Maybe this value is too short.
   
   set indexPath to (path to library folder from user domain as text) & "Application Support:tweetIndex_xednIteewt.txt"
   # In both cases read two indexes so, if we really use only one we will be able to restore the second one before exit.
   try
       set currentIndexes to paragraphs of (read file indexPath)
       set currentIndex1 to (item 1 of currentIndexes) as integer
       try
           set currentIndex2 to (item 2 of currentIndexes) as integer # EDITED on 2017/07/09
       on error
           set currentIndex2 to 1
       end try
   on error
       set {currentIndex1, currentIndex2} to {1, 1}
   end try
   
   set twoAccounts to my setTweeterAccount(howMany)
   my logThat("twoAccounts = " & my recolle(twoAccounts, ", ") & linefeed & linefeed, false)
   
   set {tweeterAccount, tweeterAccount2} to twoAccounts
   my logThat("tweeterAccount : " & tweeterAccount & linefeed & "tweeterAccount2 : " & tweeterAccount2 & linefeed & linefeed, true)
   
   tell application "Twitter Scripter"
       # Loop issuing the tweets
       set {cnt1, cnt2} to {count theTweets, count theTweets2}
       set {num1, num2} to {0, 0}
       set i to 0
       my logThat("howmany : " & howMany & linefeed & linefeed, true)
       
       repeat with aFile in droppedFiles
           set aPicPath to aFile as text
           my logThat("i = " & i & ", treat file : " & aPicPath & linefeed, true)
           
           if howMany is in {1, 2} then
               delay theDelay
               if i mod cnt1 = 0 then set num1 to num1 + 1
               set max1 to maxLen - (count (num1 as text))
               set theTweet to (item currentIndex1 of theTweets) as text
               if (count theTweet) > max1 then set theTweet to items 1 thru max1 of theTweet as text
               set theTweet to theTweet & space & num1
               my logThat("theTweet : " & theTweet & linefeed & "tweeterAccount : " & tweeterAccount & linefeed, true)
               tweet theTweet using account tweeterAccount with image aPicPath
               
               set currentIndex1 to currentIndex1 + 1
               if currentIndex1 > (count theTweets) then set currentIndex1 to 1
           end if # {1, 2}
           
           if howMany is in {1, 3} then
               delay theDelay
               if i mod cnt2 = 0 then set num2 to num2 + 1
               set max2 to maxLen - (count (num2 as text))
               set theTweet to (item currentIndex2 of theTweets2) as text
               if (count theTweet) > max2 then set theTweet to items 1 thru max2 of theTweet as text
               set theTweet to theTweet & space & num2
               my logThat("theTweet : " & theTweet & linefeed & "tweeterAccount2 : " & tweeterAccount2 & linefeed & linefeed, true)
               tweet theTweet using account tweeterAccount2 with image aPicPath
               
               set currentIndex2 to currentIndex2 + 1
               if currentIndex2 > (count theTweets2) then set currentIndex2 to 1
           end if # {1, 3}
           
           set i to i + 1 # next file
       end repeat
   end tell # "Twitter Scripter"
   
   # Prepare for the next run
   my writeto(indexPath, (currentIndex1 as text) & linefeed & currentIndex2, text, false)
   
end main

#=====

on setTweeterAccount(howMany)
   local availableAccounts, countAccounts, indexForAccount, indexForAccount2 # ADDED
   
   # Here, howMany may be 1, 2 or 3
   tell application "Twitter Scripter"
       
       -- returns a list of usernames for the OS defined Twitter accounts
       
       set availableAccounts to available accounts
   end tell
   set countAccounts to count availableAccounts
   
   set indexForAccount to 2 # ADDED, edit to fit your needs
   set indexForAccount2 to 3 # ADDED, edit to fit your needs
   
   if indexForAccount > indexForAccount2 then
       if howMany is in {1, 2} then
           if (countAccounts < indexForAccount) then
               tell application (path to frontmost application as string)
                   display dialog "Please set up at least " & indexForAccount & " 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 " & indexForAccount & " Twitter Accounts available !"
               end tell
               error number -128
           end if
           if howMany = 1 then
               return {item indexForAccount of availableAccounts, item indexForAccount2 of availableAccounts}
           else
               return {item indexForAccount of availableAccounts, false}
           end if
       else # here howMany = 3 then
           if countAccounts < indexForAccount2 then --> want item smallerIndex of availableAccounts
               tell application (path to frontmost application as string)
                   display dialog "Please set it up at least " & indexForAccount2 & " Twitter accounts in your System Preferences, and allow them to be accessed by \"Twitter Scripter\"" buttons {"OK"} default button "OK" with icon 2 with title "No " & indexForAccount2 & " Twitter Accounts available !"
               end tell
               error number -128
           end if
           return {item indexForAccount2 of availableAccounts, false}
       end if
       
   else
       # Here indexForAccount ≤ indexForAccount2. In fact it's smaller than !
       if howMany is in {1, 3} then
           if (countAccounts < indexForAccount2) then
               tell application (path to frontmost application as string)
                   display dialog "Please set up at least " & indexForAccount2 & " 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 " & indexForAccount2 & " Twitter Accounts available !"
               end tell
               error number -128
           end if
           if howMany = 1 then
               return {item indexForAccount of availableAccounts, item indexForAccount2 of availableAccounts}
           else
               return {item indexForAccount2 of availableAccounts, false}
           end if
       else # here howMany = 2 then
           if countAccounts < indexForAccount then
               tell application (path to frontmost application as string)
                   display dialog "Please set it up at least " & indexForAccount & " Twitter accounts in your System Preferences, and allow them to be accessed by \"Twitter Scripter\"" buttons {"OK"} default button "OK" with icon 2 with title "No " & indexForAccount & " Twitter Accounts available !"
               end tell
               error number -128
           end if
           return {item indexForAccount of availableAccounts, false}
       end if
   end if
end setTweeterAccount

#=====
(*
Handler borrowed to Regulus6633 - [url]http://macscripter.net/viewtopic.php?id=36861[/url]
*)

on writeto(targetFile, theData, dataType, apendData)
   -- targetFile is the path to the file you want to write
   -- theData is the data you want in the file.
   -- dataType is the data type of theData and it can be text, list, record etc.
   -- apendData is true to append theData to the end of the current contents of the file or false to overwrite it
   try
       set targetFile to targetFile as class furl
       set openFile to open for access targetFile with write permission
       if not apendData then set eof of openFile to 0
       write theData to openFile starting at eof as dataType
       close access openFile
       return true
   on error
       try
           close access targetFile
       end try
       return false
   end try
end writeto

#=====

on recolle(l, d)
   local oTIDs, t
   set {oTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, d}
   set t to l as text
   set AppleScript's text item delimiters to oTIDs
   return t
end recolle

#=====

on logThat(msg, trueOrFalse)
   set path2log to (path to desktop as text) & "log report_troper gol.txt"
   my writeto(path2log, msg, text, trueOrFalse)
end logThat

#=====

Yvan KOENIG running Sierra 10.12.5 in French (VALLAURIS, France) mardi 11 juillet 2017 13:55:31

Last edited by Yvan Koenig (2017-07-12 10:02:41 am)

Offline

 

#34 2017-07-11 07:13:10 am

Prescience
Member
From:: United Kingdom
Registered: 2017-02-03
Posts: 43

Re: Help Completing / Coding Droplet for Tweeting via Twitter Scripter

Hello Yvan,

The alternate way in your response, is what we are after.  So when howMany is set to 1 it posts tweets from both theTweets and theTweets2 to two separate twitter accounts!

When set to howMany 2 the script should only issue tweets from the account set and theTweets.  No other tweets or accounts are used.

When set to howMany 3 the script should only issue tweets from the other account set, and theTweets2.  No other tweets or accounts used.

Let me test what you have kindly provided, and drop an update when tested.

Thanks you


As I have a doubt about the list of messages to use when howMany is 3, I build the code so that you may change easily its behavior.
As is, when howMany is 2 or when it is 3, the script issue tweets from the list theTweets.

The alternate way would be :
when howMany is 2, the script issue tweets from the list theTweets.
when howMany is 3, the script issue tweets from the list theTweets2.
You may activate this mode by enabling the block of instructions which is currently disabled.


Wisdom is knowing the power of experience, understanding the knowledge learnt on your personal journey through time, and having the empathy to share with others.

Offline

 

#35 2017-07-11 07:40:13 am

Prescience
Member
From:: United Kingdom
Registered: 2017-02-03
Posts: 43

Re: Help Completing / Coding Droplet for Tweeting via Twitter Scripter

Testing on the active (test) twitter account gives the following error message - The variable indexForAccount is not defined. (-2753)


Wisdom is knowing the power of experience, understanding the knowledge learnt on your personal journey through time, and having the empathy to share with others.

Offline

 

#36 2017-07-11 07:55:51 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 3201

Re: Help Completing / Coding Droplet for Tweeting via Twitter Scripter

Oops. It's corrected.
I read and reread before posting but nothing is more efficient that true execution to find oddities in a code.

Yvan KOENIG running Sierra 10.12.5 in French (VALLAURIS, France) mardi 11 juillet 2017 14:55:46

Offline

 

#37 2017-07-11 08:15:02 am

Prescience
Member
From:: United Kingdom
Registered: 2017-02-03
Posts: 43

Re: Help Completing / Coding Droplet for Tweeting via Twitter Scripter

More than happy to test and feedback. smile

With howMany 2 - The following error appears. The variable otherAccount is not defined. (-2753)

With howMany 1 - The following error appears. The variable otherAccount2 is not defined. (-2753)

No tweets are posted in either case.


Wisdom is knowing the power of experience, understanding the knowledge learnt on your personal journey through time, and having the empathy to share with others.

Offline

 

#38 2017-07-11 08:53:29 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 3201

Re: Help Completing / Coding Droplet for Tweeting via Twitter Scripter

Oops, wording remaining from the time the tweets were issued in a handler.
What is odd is that I corrected the names in the code used for tests and forgot to do the same in the true code.
Maybe the retired potter must also retire as an helper.

The script is corrected in message #33

Yvan KOENIG running Sierra 10.12.5 in French (VALLAURIS, France) mardi 11 juillet 2017 15:53:24

Offline

 

#39 2017-07-11 09:50:08 am

Prescience
Member
From:: United Kingdom
Registered: 2017-02-03
Posts: 43

Re: Help Completing / Coding Droplet for Tweeting via Twitter Scripter

Good news - No errors!

Bad news - No tweets!  I am looking over why this is likely to be the case now.  Any suggestions?

Thanks

[Updated]

Adding the below to the end of the code produces an error when run! Not sure if this helps.

Applescript:


Return tweeterAccount

-- error "The variable tweeterAccount is not defined." number -2753 from "tweeterAccount"

Last edited by Prescience (2017-07-11 10:06:45 am)


Wisdom is knowing the power of experience, understanding the knowledge learnt on your personal journey through time, and having the empathy to share with others.

Offline

 

#40 2017-07-11 10:42:00 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 3201

Re: Help Completing / Coding Droplet for Tweeting via Twitter Scripter

I don't know what you call "the end of the script".
I edited the script in message #33.
Now it contain several instructions allowing it to create a log file on the desktop.
The file would be named : "log report_troper gol.txt"

Its contents is supposed to resemble to:

twoAccounts = account1, account2

tweeterAccount : account1
tweeterAccount2 : account2

treat file : path2pict1
howmany : 1
theTweet : blahblah
tweeterAccount : account1
theTweet : baratin
tweeterAccount2 : account2

treat file : path2pict2
howmany : 1
theTweet : blahblah2
tweeterAccount : account1
theTweet : baratin2
tweeterAccount2 : account2

and so on…

If you look in the code you will see that I split the instruction setting the accounts into two instructions to be sure of what is returned.

I guess that other users aren't interested by our exchanges, so if you wish, you may send the result to my mailbox :
k o e n i g . y v a n @ s f r . f r (without the spaces)

Yvan KOENIG running Sierra 10.12.5 in French (VALLAURIS, France) mardi 11 juillet 2017 17:38:42

Offline

 

#41 2017-07-11 11:56:37 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 3201

Re: Help Completing / Coding Droplet for Tweeting via Twitter Scripter

I duplicated the real script and disabled the calls to Twitter Scripter.
Everything behaved well.

The log text file contain:

twoAccounts = account2, account3

tweeterAccount : account2
tweeterAccount2 : account3

treat file : file1
howmany : 1
theTweet : Testing Tweets from my desktop again
tweeterAccount : account2
theTweet : tweet 22
tweeterAccount2 : account3

treat file : file2
howmany : 1
theTweet : #HappyDays more testing of desktop tweets
tweeterAccount : account2
theTweet : tweet 23
tweeterAccount2 : account3

So it seems that the entire structure is OK.

Yvan KOENIG running Sierra 10.12.5 in French (VALLAURIS, France) mardi 11 juillet 2017 18:56:29

Last edited by Yvan Koenig (2017-07-11 11:57:39 am)

Offline

 

#42 2017-07-11 12:11:11 pm

Prescience
Member
From:: United Kingdom
Registered: 2017-02-03
Posts: 43

Re: Help Completing / Coding Droplet for Tweeting via Twitter Scripter

[update at 18:34] I have the code working! I will post my changes later, as I have spotted another quirk.

When I tried to post a real tweet to the active account, which has been disabled it posted tweets from what seems to be a cache, as these were from code that had been replaced!


Hello Yvan,

I have spotted some anomalies with Twitter Scripter, as I tested it independently to your script.

1 - The image size must not be too large - this is known to be a problem with twitter, so not surprised
2 - You can't post the same tweet twice! I.e. Tweet24 will only post once.  If you change to Tweet24a it will post the tweet.

I ran your code and the log output for howMany 1 is:

twoAccounts = MainAccount, TestAccount

tweeterAccount : MainAccount
tweeterAccount2 : TestAccount

howmany : 1
theTweet : Testing Tweets from my desktop again
tweeterAccount : MainAccount
theTweet : tweet 22
tweeterAccount2 : TestAccount


The log output for howMany 3 is:

twoAccounts = TestAccount, false

tweeterAccount : TestAccount
tweeterAccount2 : false

howmany : 3
theTweet : tweet21
tweeterAccount : TestAccount


Using the code below, to test if the system was even working, I do get Tweets and Tweets with images.  I have to change the text or image for it to post every time I run it though.  Something you fixed in a previous script, as we did get the tweets cycling through the available list, and then restarting at the beginning.

Applescript:


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 3 of availableAccounts -- choose the right account!
   # 1 Should = Prescience
   # 2 Shoud = MainAccount
   # 3 Should = TestingAccount
   
   
   # tweet "I'm trying out #TwitterScripter from @mousedownsoft again." using account twitterAccount
   -- Works but does not post the same tweet twice! If you adjust by a character it does. Could twitter handler be caching tweets?
   
   set imagePath to "Macintosh HD:Users:??????:Pictures:test2.jpg" -- replace with your own path
   
   tweet "#TwitterScripter #image size matters! By @mousedownsoft with an image defined in the above settings." using account twitterAccount with image imagePath
end tell
return twitterAccount
-- Displays in the result window the account set under 'item' from available accounts

-- Result window displays: TestingAccount

It would seem from the log that the outputs is exactly as desired, it would appear to be something with Twitter Scripter when it comes to posting the tweets.  T

I will continue to test and investigate.

Last edited by Prescience (2017-07-11 12:34:17 pm)


Wisdom is knowing the power of experience, understanding the knowledge learnt on your personal journey through time, and having the empathy to share with others.

Offline

 

#43 2017-07-12 05:17:23 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 3201

Re: Help Completing / Coding Droplet for Tweeting via Twitter Scripter

What are you dropping onto the script ?
You are supposed to drop a group of files. If you drop a folder the script will be unable to work because droppedFiles will be { theDroppedFolder as alias}.
The loop supposed to issue the tweets will try to create a tweet with the folder where it's supposed to pass a file.

I edited the script in message #33 so that it creates the log file when you use it.
May you run it ?

As is, the new version has two entry points so, when it's saved as an application, we may call it by a double click or by drag & drop.
We may also run it from the script editor so we may see the events log during the execution process.

Yvan KOENIG running Sierra 10.12.5 in French (VALLAURIS, France) mercredi 12 juillet 2017 12:17:18

Last edited by Yvan Koenig (2017-07-12 08:57:17 am)

Offline

 

#44 2017-07-14 03:20:33 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 3201

Re: Help Completing / Coding Droplet for Tweeting via Twitter Scripter

May you look at : https://stackoverflow.com/questions/373 … ave-as-pdf ?
They posted :

Applescript:

on saveExcelAsPDF(documentPath, PDFPath) -- params = two HFS paths
set tFile to (POSIX path of documentPath) as POSIX file -- get a posix file object to avoid grant access issue with 'Microsoft Office 2016', not the same as (file documentPath) when using the 'open ...' command

tell application "Microsoft Excel"
set isRun to running
set wkbk1 to open workbook workbook file name tFile
alias PDFPath -- This is necessary to any script for 'Microsoft Office 2016', this avoid errors with any "save ... " command
save workbook as wkbk1 filename PDFPath file format PDF file format with overwrite
close wkbk1 saving no
if not isRun then quit
end tell
end saveExcelAsPDF

The code may be modified to fit your needs.

Yvan KOENIG running Sierra 10.12.5 in French (VALLAURIS, France) vendredi 14 juillet 2017 10:20:27

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)