Set text of a Growl Notification using Automator? - macos

I have an Automator Application containing the action "Show Growl Notification", which is always empty when it appears. I've tried using the "Get Specified Text" and "Get Value Of Variable" actions directly before it, but nothing I've tried seems to work.

The code sample from gadgetmo is almost correct but won't work as is with Growl 1.4
An application must be registered and enabled and must provide a list of notifications it will present and also a list of which of those notifications are enabled.
You can skip all that config stuff if you just hijack the preconfigured automator settings as shown below.
Key points to note are "Automator notification" as the name of the notification and "Automator" as the source application.
tell application "System Events"
set isRunning to (count of (every process whose bundle identifier is "com.Growl.GrowlHelperApp")) > 0
end tell
if isRunning then
tell application id "com.Growl.GrowlHelperApp"
notify with name ¬
"Automator notification" title ¬
"Processing Files" description ¬
input as text application name "Automator"
end tell
end if

Use this in a Run Applescript:
tell application "System Events"
set isRunning to (count of (every process whose bundle identifier is "com.Growl.GrowlHelperApp")) > 0
end tell
if isRunning then
tell application id "com.Growl.GrowlHelperApp"
notify with name ¬
"Test Notification" title ¬
"Test Notification" description ¬
"This is a test AppleScript notification." application name "Growl AppleScript Sample"
end tell
end if
Or download it here.
You can also use this with input.

The action just passes the input through, and doesn't have any text fields that accept variables, so you will need to manually put in the message you want. The Show Growl Notification action (located inside the GrowlHelperApp bundle) does use an AppleScript, so you could modify a copy to do something like use the input if the message field is blank.

Related

I need to create an applescript to get the token from an account in the Authy desktop app and concatenate it with a password

I was able to identify the names of some elements to make the click command, but I could not find the name of the element that identifies the accounts.
The idea is to click on an account, copy the token and concatenate it with a password inside the script
Commands already used:
tell application "System Events"
tell process "Authy Desktop"
set visible to true
return every UI element of front window
end tell
end tell
tell application "System Events" to return value of every attribute of window of application process "Authy Desktop"

Create mail with attachment using applescript and outlook

I've wrote a litte Applescript to make a new message with an attached file via outlook. But it didn't work and I don't know why. There is no error or something else. The message is created in the Draft-section of outlook, but the attachment is missing. Can somebody help me out?
Here's the Script:
set mailBody to "<span>TEST</span>"
set mailAdress to text returned of (display dialog "Mail Adress" default answer "" buttons {"OK"} default button 1) as string
set whichFile to file
tell application "Finder" to set whichFile to selection
repeat with aFile in whichFile
tell application "Microsoft Outlook"
set filename to name of aFile
set theNewMessage to make new outgoing message with properties {subject:"TEST " & filename, content:mailBody}
make new recipient at theNewMessage with properties {email address:{address:mailAdress}}
set theAttachmentFile to aFile as POSIX file
make new attachment at the end of theNewMessage with properties {file:theAttachmentFile}
open theNewMessage
end tell
end repeat
Greetings and thanks in advance
Speedster
Here is what I have been using as an alternative. To use the below, you need the desired message to be queued up already in your outbox. Or you can just borrow a few lines of the below and work it into your existing code.
set theAttachmentFile to "Macintosh HD:Users:Speedster:Documents:Attachment.docx" as alias
---replace this with the hard address of your selected file
tell application "Microsoft Outlook"
repeat with theMessage in the messages of the outbox
make new attachment at the end of theMessage with properties {file:theAttachmentFile}
end repeat
end tell

Applescript for Outlook v15 - Recipients won't populate

I have copied some scripts on the site and the result is that Outlook creates a new forwarded message but the recipient is blank. Have tried multiple forms but always the blank recipient. It's a script I will only run for messages I manually select, so I can't use a simple forwarding rule in the app.
Any ideas?
tell application "Microsoft Outlook"
repeat with eachSelectedMessage in selectedMessages
set theForwardedMessage to forward eachSelectedMessage with opening window
make new recipient at theForwardedMessage with properties {email address:{address:"recipient#somewhere.com", name:"Lumpkin Skinbark"}}
send theForwardedMessage
end repeat
end tell
New information: It turns out the recipient is being populated correctly and put in my Outbox, but not being sent. In addition, a new window pops up with the same forwarded message and a blank recipient. That new window was the one I saw that led me to believe the recipient was not populating.
My workaround for now is to periodically hit the send/receive button in Outlook to send the messages sitting in the Outbox (I don't know why they don't just get sent automatically like everything else). Then I added:
close window 1
to close the open window -- don't know why it's created and don't want it, but might as well just close it and move on.
So I do have it working, but it's not elegant.
I finally figured out how to make this work: DON'T Open the forwarded email window until AFTER you've set the email properties, especially the Recipients.
Here's my test script:
set newSubjectStr to "TEST -- DON'T OPEN at first."
set recipientEmail to "somebody#InvalidDomainName.com"
tell application "Microsoft Outlook"
set selMsg to current messages
set oMsg to item 1 of selMsg
set subjectStr to subject of oMsg
set oFwdMsg to ¬
forward oMsg without opening window ## This is KEY. Don't Open Window
make new recipient at oFwdMsg ¬
with properties {email address:{address:recipientEmail}}
set subject of oFwdMsg to newSubjectStr
--- NOW OPEN FWD EMAIL WINDOW ---
open oFwdMsg
end tell
--- SEND NOW IF NO MORE CHANGES ---
-- Works fine if I manually send, or use keyboard shortcut --
-- Send and Close Window ---
delay 0.2
tell application "Microsoft Outlook" to activate
tell application "System Events"
key code 36 using {command down} -- CMD-RETURN
end tell
--- BELOW SEND BY SCRIPT LEAVES MSG IN OUTBOX ---
--send oFwdMsg
--close window 1
--sync folder "Outbox"
NOTE to Moderators: Is there a way to get syntax highlight for AppleScript?

How to run an applescript through xcode

Im trying to set up a MacOSX application through xcode to send an iMessage. I have an applescript that I have run through Automator to test to make sure it works. However, I want to be able to pass in parameters to the apple script so that it would look like this:
on run(thisContact, thisNumber, thisMessage)
tell application "Messages"
set targetService to 1st service whose service type = iMessage
set targetBuddy to buddy phoneNumber of targetService
repeat thisNumber times
send thisMessage to thisContact
end repeat
end tell
end run
How would I run a script like this from xcode?

Get network address of a file in AppleScript

We are a network of Mac computers. I would like to send email addresses to colleagues with links to files on network locations. I made the following AppleScript:
tell application "Finder"
set uuu to URL of the first item of (get the selection)
set the clipboard to uuu
end tell
which puts the URL of the currently selected file into the clipboard, which can then be pasted into the message (using the Add Link menu item), providing, for example:
file://localhost/Volumes/Commerciale/Clienti/
Unfortunately these links do not work. If I select Go To Folder from the menu item, I can get to the folder using an afp:// type URL.
Is there any way to get this via AppleScript like I do with URL above?
I have solved with this script:
on urlToPOSIXPath(theURL)
return do shell script "python -c \"import urllib, urlparse, sys; print urllib.unquote(urlparse.urlparse(sys.argv[1])[2])\" " & quoted form of theURL
end urlToPOSIXPath
tell application "Finder"
set uuu to URL of the first item of (get the selection)
set pp to my urlToPOSIXPath(uuu)
set the clipboard to "file://" & pp
end tell
Are the volumes already mounted on the email recipients' Mac? Netlink makes a URL that is clickable in Mail. I don't have an AFP share here to test this:
tell application "Finder" to set netlink to URL of (get selection as alias)
Not "automagically" as far as I know. The URL and POSIX path properties only returns the shared directory and not the volume itself. If you use the URL given to you by Applescript, only Applescript can still resolve it. (I get the impression the OS or Applescript is just iterating down the mounted volumes finding the file) You'll need to manipulate the path string to get the format you need.
here is an expanded version of markratledge's post
tell application "Finder" to set netlink to URL of (get selection as alias)
tell application "Mail"
launch
set newMessage to make new outgoing message with properties {subject:"network link", content:netlink, visible:true}
-- Add in code for recipient, etc, etc
--send newMessage
end tell
but that still doesn't seem to work lol

Resources