Applescript and websites
Hi,
I'm a new Applescript user and I need to write a script that pulls links off of websites that match a certain criteria and send them to MS word. Ideally, Word would be told through Applescript to type some text and the link would be assigned to the text; in the example I'm searching for all HTML's on at www.apple.com that have the word "iphone" in them.
I have a few questions...
1. "www.apple.com" is saved through DEVONagent which has it's own command to save URL links. Surely this can be done by Applescript itself since the same function is available in Automator. Can someone tell me how?
2. Also, I can't get the (If APPLE_links contains "iphone" then) statement to search inside of the html strings that are saved in "APPLE_links". The "if" statement is only followed when there is an exact match--which won't happen in my case of course. Can someone tell me how to make this work?
3. "System Events" is used to type the HTML's into Word that are pulled off of "www.apple.com". Can someone tell me how to control word through Applescript to make this happen?
property target_URL : "http://www.apple.com/"
open location target_URL
delay 4.0
--STORE THE APPLE WEBSITE INTO APPLE_url
tell application "Safari"
set ALL_documents to get every document
if ALL_documents is {} then
set error_message to "Safari has no documents open."
my dsperrormessage(errormessage, "--")
return
else
try
set APPLE_url to URL of document 1
set APPLE_source to source of document 1
length of APPLE_url
length of APPLE_source
on error
set error_message to "Safari has no documents open."
my dsperrormessage(errormessage, "--")
return
end try
end if
end tell
--GET ALL LINKS FROM THE APPLE WEBSITE...
--SURELY APPLESCRIPT CAN DO THIS BY ITSELF, CAN SOMEONE TELL ME HOW?
tell application "DEVONagent"
set APPLE_links to get links of APPLE_source base URL APPLE_url
end tell
--WHEN THIS SEARCH IS DONE, IT DOESN'T LOOK FOR "iphone" INSIDE OF EACH HTML... A POSITIVE RESULT WOULD BE A PERFECT MATCH, HOW CAN I MAKE APPLESCRIPT LOOK INSIDE OF THE HTML'S THAT ARE STORED IN APPLE_links?
if APPLE_links contains "iphone" then
tell application "Microsoft Word"
activate
end tell
--WHAT I REALLY WANT TO DO IS HAVE A WORD LIKE "IPHONE" TYPED AND HAVE THE HTTP ASSIGNED TO THAT TEXT IN MS WORD... HOW IS THIS DONE WITHOUT USING "SYSTEM EVENTS"
repeat with i from 1 to (count items of APPLE_links)
tell application "System Events"
keystroke (item i of APPLE_links)
keystroke return
end tell
end repeat
end if
Go to File > Open Dictionary and choose the application you want to control to see a thorough listing of all the options it offers. Microsoft also has quite a bit of documentation on Word's AppleScript support; it's probably on your installer disc.
Similar Messages
-
IWeb Applescript and Automator - scripts you shouldn't be without
Applescript and automator will automate mundane manual repetative task that seem to take forever. These scripts fill in iWeb's void that makes it hard to implement advance features such one click ftp publishing, code editing, swithching domain site files, etc. Don't miss out on these scripts that will save you ton of time. These are scripts you shouldn't be without.
Work smarter not harder with iWeb applescript, only from MacEzzy.
-- Also check out the free downloadable iWeb templates.
Powerbook G4 Ti Mac OS X (10.4.4)Thank you for your feedback.
-- Article never mentions compressed or uncompressed. Traditionally tiff format is used for buttons and small images on web pages and jpeg is used for higher quality photos exemplified by iWeb.
-- Search engine spiders or crawlers start from top of the page to the bottom of html pages. They craw for topic as well as content. This is exactly what appears from iWeb html pages for meta (meta name="Generator" content="iWeb 1.0.1")
-- I am the first to admit I don't know everything but I don't make up information. I use iWeb on a daily bases and try new things to push the envelope. Things that I find helpful to me I make it available for other iWeb community users so that they don't go through tribulation.
-- I put google ads and paypal donate buttons throughout the pages to test if iWeb is up for commercial challenge. I also tested how well the search and replace script worked. I have exemplified in macezzy website it is possible to use iWeb for business purpose. The script worked extremely well, it would have taken hours to insert google and paypal codes manually. Using the script it only took 10 min. I wanted to share that with other users who might wanted to do similar things. Sorry if that offend you, I will remove them.
-- I never claimed to have created the script except the script that makes the first folder in documents folder. I did change the wording so that it is clear to users that they are switching sites(domain file). I did not create the awesome search and replace script either. I do mention that I have made the iWeb_ftpUpload automator.
I have started macezzy site when iWeb was introduced and there wasn't much information about iWeb. I have and do try many things with iWeb and report to iWeb community users of things that I find helpful. I haven't made a dollar off the site and I have invested lot of my time because I like to see other users succeed.
Powerbook G4 Ti Mac OS X (10.4.4) -
How to take off email and website subscription from 2006 iMac to sell?
I have a desktop Imac that I bought in 2006 and would now like to sell. I also bought a laptop in 2007 that I prefer using. How do I remove the email and website subscription from the desktop model without messing up the laptop info? They seem to be connected at this point and I am not sure how to take off the information from one without damaging the other.
Have you solved this problem? If not, can you be more specific? You can change the email account information using Email preferences. Which website subscription would you like to remove?
-
My macbook pro's screen display has suddenly gone into a strange colour setting where everything appears in a kind of infrared colour palette an I can;t seem to change it back. It's the same for all icon and websites, does anyone know how to restore?
Wow! I think I had this same issue just last night.
I was cleaning my macbook pro retina on the outside. Then I opened it up and was wiping dust off the monitor and I can't pinpoint exactly when, but the colors changed suddenly. It looked super strange, it was like green halo's and it looked worse when looking at it at an angle. Of course I took no pictures!!! I was freaking out that my 2 grand laptop was busted and I somehow removed a protective film or something.
But I digress... The image looked very green and spacey, it was almost a neat effect. After about 5 minutes it started to look a little more digital though. There were straight lines of this halo effect on the edges and top. After about 10 minutes it turned into a predominate issue with the blacks on screen. I could open a web browser and it was unnoticable on a white background. After about 15 minutes, you could only barely see the green cloud effect if you looked at the monitor from an extreme angle. After about 20 minutes, it was completely back to normal, I almost feel paranoid like I see a halo or something strange. But I believe that might be all in my head now.
So yerp, lemme know what you guys figure out. -
Need help with applescript and Xcode 4.3.2
I'm trying to write my first application that will involve a GUI. I can code applescript using script editor with a bit of effort, but I'm want to have users input more than one piece of information in the pop up. So, I download xcode, create my first applescript cocoa project go to MainMenu.xib and add a bunch of labels, text fields and buttons. Looks fairly nice... Go to start it and... nothing (well the window pops up, but it doesn't do anything). Unfortunately, I haven't figured out how to link the window to the applescript... So, how do I...
* Have the applescript prepopulate data in the text fields and pulldowns
* Once the user changes the data in the fields tell the applescript
* Tell the window to close and pass the control back to the applescript once either the cancel or submit button is pressed.
More detailed...
* What's an outlet and how do I use it here? Which of the 18 outlet(s) do i use for this?
* What's a property (referenced on one of the web pages I saw around applescript and cocoa) and do I need them here?
Looking at the documentation with xcode, there isn't a lot about xcode and applescipt. Looking at the web, the top links are a few years old. So, links to good relevent documentation would be very nice as well as direct answers to the questions
Thanks,
ScottI'm not sure why you are closing it, but the NSApplication class is what keeps track of the windows. If you don't want to connect the window to an outlet from the interface editor, you can use something like
set theWindow to current application's NSApplication's sharedApplication's mainWindow()
...and from there you can use whatever NSWindow methods, for example
theWindow's performClose_(me) -
I have studyed html for 3 days and wordpress for 3 days , word , excel for 5 days, and llustrator and photoshop 13 yeas ago for 6 months.
and still now its so hard to understand some how.
but I am in need of understading now with the printed documents from my computer.
and I wonder , so there are many defferent way to communicate with anyone out side of the world, right?
like I know email , fax, facetime,
but there are other way now I think because of the documents I found.
and also with applescript and automator can do anything possible like even the child can click one and start conecting etc..
I have the copy from its ,
does anyone have time to explain me what it is?
It's not that of teenager who doesn't want paretns to know or else,
but I am quite serious for my situations.
Please Help !
Mac OS snow leopard to lion to moutain lion,,,,,
but I don't know when it started yet.Using JavaScript to script System Events wouldn't be any better, since it uses the same Apple Events mechanism (how well it uses it is another topic). To hold down a key you would need to use something that has access to the deeper system APIs, most likely using Xcode.
And yes, your code snippet will press the arrow key 5 times (I am guessing that the missing space in key code is a typo). You can place the cursor in a bunch of text in another application such as TextEdit, and use your script to activate it before performing the key codes to get a better idea of what is happening (trying to reposition the cursor in the Script Editor will reveal a bug with the delay command). -
When printing from a website the date and website line on the printed page is in gibberish
when i print from a website why are the date and website lines at the top and bottom of the page in gibberish?
Adjust the print scale: File > Page Setup > "Format & Options": Scale (deselect: "Shrink to fit page width")
* http://kb.mozillazine.org/Problems_printing_web_pages -
Is this possible in AppleScript and if so how ?
I am trying to make an app that opens AppleScript and types in things. I then want the AppleScript that the other Applescript wrote to save as an application, and rename it. Is this possible and if so, can you give me an example?
If I'm following what you want, the applescript editor is fully scriptable. In fact, there are a bunch of applescript samples in /Library/Scripts/Script Editor Scripts/ that show you how to use applescript to write and compile applescript code into a new window. Just for a quick-and-dumb example:
set the target_string to "X-X-X"
set the script_text to "display dialog \"" & target_string & "\" buttons {\"OK\"} default button 1" & return
set outputPath to POSIX path of (path to desktop folder from user domain) & "test.app"
tell application "AppleScript Editor"
activate
set newDoc to make new document
tell newDoc
set its text to script_text
try
check syntax
compile
end try
save in outputPath as "com.apple.application"
end tell
end tell -
I just returned my new Mac book pro with retinal display after three very disappointing three weeks of trying to use certain websites and other third party programs (Quickbooks, Raintree) that would not function properly. My husband own the previous MacBook Pro version with the built in CD rom and I was able to use those above mentioned websites and problems with the no difficulties. Did I just happen to get a lemon or is this a function of the computer being too new for third party software?
Programs such as Quickbooks pro for Mac, I was able to import my previous data and I was able to enter about 5 new transactions before it stopped being able to save transactions. Other programs ( Raintree ) that I use via VM software as a windows based program I was able to access and use some features but not others. On the web browsers (both safari and Mozilla) I use a website that has an analyzer feature and it would pull up a blank screen in the place where I would enter pertinent information. They tried pulling this website at the apple store today and the same issue happened. All these programs and website I am able to access and run smoothly with no issues on my husbands MacBook Pro , which is why I returned my MacBook. I just wondered if others were experiencing similar issues with their MacBook with retinal display.
-
Monitoring of Disabled Application Pools and Websites
So we have a SCOM 2012 SP1 environment monitoring an IIS server that's Server 2012. The IIS server has all of the App Pools that are not in use disabled as well the Default website is also disabled. SCOM unfortunately still picks up that these
are unavailable and complains ad nauseum.
So the real quest is, is the disabled state going to be picked up eventually? (Now two days later the server objects themselves are Healthy, so I assume I can just close the alerts but ...)Yes, you can disable alerts of this specific object{Disabled application pools and websites}
Please remember, if you see a post that helped you please click "Vote As Helpful" and if it answered your question, please click "Mark As Answer" -
Using Applescript and Automator to manage files and folders
Hi all.
I need to make a simple action via applescript and-or automator to take the file it's been applied to (via the services) create a folder around it with the same name as the file.
So far, I've searched the web, found some solutions but none are really working.
Here's the script I found :
set myFolder to findFolder()
tell application "Finder" to set myFiles to files of myFolder as alias list
repeat with aFile in myFiles
set bName to my baseName(aFile)
tell application "Finder"
set folderExists to exists folder bName of myFolder
if not folderExists then make new folder at myFolder with properties {name:bName}
move aFile to folder bName of myFolder
end tell
end repeat
---------------- HANDLERS ----------------
on baseName(myFile)
tell application "System Events" to set {fileName, fileExt} to {name, name extension} of myFile
return text 1 thru ((get offset of "." & fileExt in fileName) - 1) of fileName
end baseName
on findFolder()
activate application "SystemUIServer"
-- Bug pointed out by Lauri Ranta http://www.openradar.me/9406282
tell application "Finder"
activate
set mySelection to (get selection)
if mySelection ≠ {} then
set mySelection to first item of (get selection)
if mySelection's class = folder then
set currentFolder to mySelection
else if mySelection's class = document file then
set currentFolder to parent of mySelection
else if mySelection's class = alias file then
set currentFolder to original item of mySelection
end if
else
set currentFolder to target of front Finder window
end if
end tell
return (currentFolder as alias)
end findFolder
And here's a page where they explain how to use automator and the Services to do what I <allmost> want, with some adaptation.
But it still doesn't work.
http://hbase.net/2011/08/17/move-selected-files-into-a-new-folder-using-applescr ipt-and-automator/
So if anybody has an idea n how I could do this ?
It It could either be a folder action (I drag and drop the files into a folder and boom, they get their folder around them)that I would set on a folder on a network drive, or locally, it doesn't matter, or a service (right clic on the file and boom folder around it.
So if anyone could help with this I'd be grateful...Hi,
Make an Automator Service (Service receives selected "Files or Folders" in the "Finder.app").
Use this script in the "Run AppleScript" action:
on run {input, parameters}
tell application "Finder"
repeat with aFile in input
if class of (item aFile) is not folder then
set {tName, fileExt} to {name, name extension} of aFile
if fileExt is not missing value and fileExt is not "" then
set tName to text 1 thru -((count fileExt) + 2) of tName
tell (get container of aFile)
if not (exists folder tName) then make new folder at it with properties {name:tName}
move aFile to folder tName
end tell
end if
end if
end repeat
end tell
end run
This script work on files with a name extension. -
Adobe Evangelist Paul Trani shows how to create apps and websites for multiple screens using Design & Web Premium CS6.
http://adobe.ly/Iq676ZI have CS6.5 installed through the Adobe Application Manager, Creative Cloud account. There are no PhoneGap sample pages under Mobile Started, only the ones labelled (Local). Where / how can I get these sample pages?
-
E-mails and websites all down this AM
Hello. I am on vacation and went to update my websites and send some business e-mails home. All of my websites are down. Someone said it might have to do with needing to buy an icloud device but I have no idea what that is -- is this some sort of thing like an ipad or ipod? I hope my computer just did not become unusable. Please advise. I just want my e-mails and websites back up as I have been sending people to view my websites (mostly charity events I organize).
Thanks!My e-mail is also down and it won't recognize the password I have been using since 2008! I have no idea what is going on! Thanks!
-
The phone number and website for my business in iPhone Maps are wrong. How can I change them?
SEARCH !!
http://lmgtfy.com/?q=report+a+problem+in+apple+maps -
Hey all at the moment I am using this script to invoke the ditto command
I use this method because I can at least see the progress
but I would like something a bit better
like a display dialog at least that counts the amount of files and starts from 1 to what ever it is or some sort of percentage.
the bottom script does not open terminal and I would like to use the display dialog in the bottom script. is this possible.
I tried using 3rd party progress bars with no luck.
I am not very smart on coding. I only no a bit of applescript and unix.
Have been playing with xcode and interface builder but can never get the progress indicator to actually work for me.
set source to (choose folder with prompt "Select the Source folder")
set destination to (choose folder with prompt "Select the Destination folder")
set source_unix to quoted form of POSIX path of source
set destination_unix to quoted form of POSIX path of destination
tell application "Terminal"
activate
delay 2
do script ("ditto -V -rsrc " & (source_unix) & space & (destination_unix))
end tell
But.......
I rather use
set source to choose folder
set destination to choose folder
set source_unix to quoted form of POSIX path of source
set destination_unix to quoted form of POSIX path of destination
do shell script "ditto -V -rsrc " & source_unix & space & destination_unix
any help on this would be great
like I said I would like a loading bar but a display dialog giving me some indication on time -- percentage -- or file count would be greatthe bottom script does not open terminal and I would like to use the display dialog in the bottom script. is this possible.
It can be done, but it takes a bit of extra work.
The issue is that when you invoke do shell script, AppleScript hands control over to the script and does not do anything else until that script returns control back to AppleScript. Therefore there's no way to display your progress dialog - AppleScript doesn't get a look-in until the script completes.
That's largely because in most cases you want your script to react to the results of the shell command and you can't do that if the command hasn't finished.
The exception to this rule is that you can tell the shell command to return control immediately to your script. This will let you run other AppleScript commands while the shell command executes in the background.
You do this by appending " > /dev/null 2>&1 &" to the end of the command. This redirects the output of the command to /dev/null and sends it to the background so that AppleScript can continue.
The trick now is in getting AppleScript to know the shell command's status.
For that the typical solution involves outputting the shell command's result to a temporary file (rather than /dev/null) which you can then read in via AppleScript. What you need now is knowing when the shell command is done which relies on another shell trick (hack?) that tells you the PID of the most recently launched command - you can use that to query if the process is still running.
So your command should end up like:
-- do your shell command:
do shell script "ditto -V -rsrc " & source_unix & space & destination_unix & " > /var/tmp/my.log 2>&1 & echo $!"
-- 'echo $!' allows you to capture the PID of that process
set thePID to the result
try
repeat
-- does the PID exist?
do shell script "ps -p" & thePID
-- so show progress
display dialog (do shell script "tail -1 /var/tmp/my.log") giving up after 2
end repeat
on error
-- we're done, so clean up
do shell script "rm /var/tmp/my.log
end try
The revised do shell script command writes ditto's output to /var/tmp/my.log and returns the PID of that process. The repeat loop then repeatedly checks that PID's status (via ps -p). If the process is running that command succeeds so the script progresses to the 'display dialog' command where it shows you the last line of the log file (you can change this to show anything you like).
If the ps -p command fails because the process is no longer running, that trips the on error clause in the try block which cleans up the temp file.
Maybe you are looking for
-
Result shown in Bex Report is different from Infocube
In BI, Flat file loading, I got data correctly into the cube. But when I tried to generate the report its showing all the key figure values divided by 10. Keyfigures are of type Amount. And when I checked for scaling factors, its showing nothing 1 on
-
New iPod Touch won't sync with computer - have latest version of iTunes and Snow Leopard (10.6.8). Computer won't even acknowledge the iPod. Have restarted both, changed ports, etc. What's do I need to do?
-
How to adjust Advance or Payment on Account against an Invoice for Customer
Hi, I have to adjust, the Payment taken from the Customer as Advance or Payment on Account, against a particular invoice. How can i do the same in the system for the particular customer? Please suggest. Thanks in advance. Rachit Rastogi
-
Is the 13inch MBP for $1199 practical for graphic design?
Hi, I'm wondering if someone can please advise... my wife wants to get into graphic design, and I would like to get her a laptop for a gift... I use a macbook pro 2.53 but that's not in my budget... would the macbook pro for $1200 (13inch 2.26 2gb 16
-
$29.99 monthly membership. Sign in screen asking for serial number. Not sure what serial number this refers to