Hello Macscripter forums,
This is my first post here, hopefully it is a fruitful one. After much searching of these forums and the internet I have been unable to figure out exactly how to get this effect right. I’m trying to get a workflow to grab the current volume level, turn the volume to max before making an announcement, then return the volume to it’s original level. I’ve got the first 2 working I just can’t figure out how to do the last part right now. I’m storing the reading of the current volume obviously, and just can’t figure out how to pass it to an applescript to use to set the final volume.
If this is should have gone in the applescript forums I apologize and politely request that it be moved. Hopefully however I picked the correct forum. I thank you all in advance for you time and responses.
Hi happy_wooter,
The following AppleScript code works just fine on my Mac (Mac OS X 10.5.4):
-- getting the current output volume
set oldoutvol to (output volume of (get volume settings))
-- setting the current output volume to maximum
set volume output volume 100
-- announcing something
say "Wow, that sounds like maximum output volume!"
-- restoring old output volume
set volume output volume oldoutvol
Maybe that is already sufficient?
Sweet, that worked like a charm. Turned my 7 automator commands of audio control into 1 applescript.
Now my next hurdle I’ve run into: I want the workflow to open 3 websites in a new safari window. I have it setup to open the new window and open the pages right now. Trick is I would like to be able to have it open the 1st page for sure, but open one of 2 pairs of pages for the other two sites, based on the content of the page. Specifically I’m trying to get it to check the page for a text string and if it comes back with a result open the order page rather than the item display page on woot.com and one of their sister sites. I have the url’s for each site in the pairs I just cannot figure out how to get Automator to search and perform and action on a condition. Sorry if that was at all vague in it’s description, I can try and clarify if it was.
Thanks again for the help. Will post this over at Automator Workflows once it’s finished and link back here.
Hi happy_wooter,
I cannot offer you an Automator, but an AppleScript solution:
-- URL of the website to search for a certain string
set siteurl to "http://www.apple.com"
-- accessing the source of the website
set command to "curl " & siteurl
set sitesource to do shell script command
-- the string to be contained in the website
set searchstring to "iPhone"
-- the website to be opened on success
set newsite to "http://www.apple.com/iphone/"
-- if we find the search string in the website,
-- we open a new one
if searchstring is in sitesource then
set command to "open " & quoted form of newsite
do shell script command
end if
The above code searches the source of a given website for a certain string and opens a new website in the user’s default browser on success. Maybe you can make use of this?
Turns out I couldn’t use it to do exactly what I wanted based on site restrictions but I have managed to turn that last script into something that I could use, thanks again for it. I think the project is pretty much done, just want to do a little more testing on it. Working on a related project as well. Once I’m satisfied with how the final product turns out I’ll be sure to post it.