Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jun 30, 2009, 02:30 AM   #1
uaecasher
macrumors 65816
 
uaecasher's Avatar
 
Join Date: Jan 2009
Location: Stillwater, OK
Send a message via AIM to uaecasher Send a message via MSN to uaecasher Send a message via Yahoo to uaecasher
AppleScript and Automator help

Hello,

I want to make an AppleScript or Automator run to make the following:


take screen shot of window opening, click mouse, wait x seconds , take screen shots etc...
uaecasher is offline   0 Reply With Quote
Old Jun 30, 2009, 06:49 PM   #2
mysterytramp
macrumors 65816
 
mysterytramp's Avatar
 
Join Date: Jul 2008
Location: Maryland
Look here for the screen capture code.

To open the folder and click the mouse, use System Events, something like this:

Code:
tell application "Finder"
	activate
	open folder "Macintosh HD:Applications"
	tell application "System Events"
		click at {100, 100}
	end tell
	delay 3
end tell
Does this help?

mt
__________________
What looks large from a distance, close up ain't never that big.
mysterytramp is offline   0 Reply With Quote
Old Jul 1, 2009, 01:36 AM   #3
uaecasher
Thread Starter
macrumors 65816
 
uaecasher's Avatar
 
Join Date: Jan 2009
Location: Stillwater, OK
Send a message via AIM to uaecasher Send a message via MSN to uaecasher Send a message via Yahoo to uaecasher
Code:
set save_location to  Desktop
  

repeat with shotcount from 1 to 100
  do shell script "screencapture " & 
Desktop/untitled folder  & "screen" & (shotcount as string) & ".pdf"
  delay (5) 
end repeat

tell application "Safari"
	activate
	tell application "System Events"
		click at {100, 100}
	end tell
	delay 5
end tell
I keep getting syntax errors
and how should i know the x and y coordinates of the point i want to click
uaecasher is offline   0 Reply With Quote
Old Jul 1, 2009, 05:07 AM   #4
mysterytramp
macrumors 65816
 
mysterytramp's Avatar
 
Join Date: Jul 2008
Location: Maryland
What specifically is your script?

What specifically are the errors?

What do you want to accomplish with the mouseclick?

What is it you're trying to do?

mt
__________________
What looks large from a distance, close up ain't never that big.
mysterytramp is offline   0 Reply With Quote
Old Jul 1, 2009, 06:59 AM   #5
uaecasher
Thread Starter
macrumors 65816
 
uaecasher's Avatar
 
Join Date: Jan 2009
Location: Stillwater, OK
Send a message via AIM to uaecasher Send a message via MSN to uaecasher Send a message via Yahoo to uaecasher
Quote:
Originally Posted by mysterytramp View Post
What specifically is your script?

What specifically are the errors?

What do you want to accomplish with the mouseclick?

What is it you're trying to do?

mt
1) the code above is my script .

2) Syntax Error: Expected expression but found end of line.

3) well the click is to turn pages in pdf file in safari.

4) taking screen shot of online book
Attached Thumbnails
Click image for larger version

Name:	Screenshot on 2009-07-01 at 3.57.07 PM.png
Views:	10
Size:	77.1 KB
ID:	180343  
uaecasher is offline   0 Reply With Quote
Old Jul 1, 2009, 01:46 PM   #6
LtRammstein
macrumors 6502a
 
Join Date: Jun 2006
Location: Denver, CO
Send a message via AIM to LtRammstein Send a message via MSN to LtRammstein
Code:
repeat with shotcount from 1 to 100
  do shell script "screencapture " & 
Desktop/untitled folder  & "screen" & (shotcount as string) & ".pdf"
  delay (5) 
end repeat
What is "Desktop/untitled folder"? Also, "(shotcount as string)" should probably be "(showcount as string)".
__________________
17" White Intel iMac 1.83GHz, 250 GB HD, 2 GB RAM || iPod Touch 16GB w/ 3.0 || 15" Intel MBP 2.4GHz, 250 GB HD, 4 GB RAM
LtRammstein is offline   0 Reply With Quote
Old Jul 1, 2009, 02:11 PM   #7
uaecasher
Thread Starter
macrumors 65816
 
uaecasher's Avatar
 
Join Date: Jan 2009
Location: Stillwater, OK
Send a message via AIM to uaecasher Send a message via MSN to uaecasher Send a message via Yahoo to uaecasher
"Desktop/untitled folder" is the path where to save the image
uaecasher is offline   0 Reply With Quote
Old Jul 1, 2009, 08:14 PM   #8
mysterytramp
macrumors 65816
 
mysterytramp's Avatar
 
Join Date: Jul 2008
Location: Maryland
Quote:
Originally Posted by uaecasher View Post
"Desktop/untitled folder" is the path where to save the image
The original script called "choose folder" then used that variable in the screencapture script. "Desktop/untitled folder" is not a valid path. Terminal will want a Posix path, something more like:

'/Users/<your user name>/Desktop/untitled folder'

It'll want the single quotes and it will expect that untitled folder already exist.

You'll have to experiment where the turn page icon is. I used {100,100} as an example.

If Safari can open a pdf, can it not save it to your hard disk? It seems like you're pursuing the hardest solution when something easier is available.

mt
__________________
What looks large from a distance, close up ain't never that big.
mysterytramp is offline   0 Reply With Quote
Old Jul 2, 2009, 03:59 AM   #9
uaecasher
Thread Starter
macrumors 65816
 
uaecasher's Avatar
 
Join Date: Jan 2009
Location: Stillwater, OK
Send a message via AIM to uaecasher Send a message via MSN to uaecasher Send a message via Yahoo to uaecasher
well, it's not in pdf format but it's an online book, i found way to find the coordinates i can use the select screen shot (Command shift 4) and it will give me the axes of the point
uaecasher is offline   0 Reply With Quote
Old Jul 2, 2009, 05:58 AM   #10
uaecasher
Thread Starter
macrumors 65816
 
uaecasher's Avatar
 
Join Date: Jan 2009
Location: Stillwater, OK
Send a message via AIM to uaecasher Send a message via MSN to uaecasher Send a message via Yahoo to uaecasher
I get this error 'Expected expression but found unknown token'

and it highlight the single quotes


Code:
set save_location to  '/Users/Fahad/Desktop/untitled folder'
  

repeat with shotcount from 1 to 100
  do shell script "screencapture " & 
'/Users/Fahad/Desktop/untitled folder'  & "screen" & (shotcount as string) & ".pdf"
  delay (5) 
end repeat

tell application "Safari"
	activate
	tell application "System Events"
		click at {100, 100}
	end tell
	delay 5
end tell
uaecasher is offline   0 Reply With Quote
Old Jul 2, 2009, 07:18 PM   #11
mysterytramp
macrumors 65816
 
mysterytramp's Avatar
 
Join Date: Jul 2008
Location: Maryland
Terminal wants the single quotes, but Applescript doesn't understand single quotes.

Try:

Code:
set save_location to  "'/Users/Fahad/Desktop/untitled folder'"
If that doesn't work, use double quotes and then:

Code:
set save_location to quoted form of save_location
It'll do the same thing.

mt
__________________
What looks large from a distance, close up ain't never that big.
mysterytramp is offline   0 Reply With Quote
Old Jul 5, 2009, 09:08 AM   #12
uaecasher
Thread Starter
macrumors 65816
 
uaecasher's Avatar
 
Join Date: Jan 2009
Location: Stillwater, OK
Send a message via AIM to uaecasher Send a message via MSN to uaecasher Send a message via Yahoo to uaecasher
hey, this is UAECASHER my account got stolen so I'm writing from this account,

this is my final code

Code:
set save_location to 
	"'Users/Fahad/Desktop/ss'"

repeat with shotcount from 1 to 2
	do shell script "screencapture " & 
		quoted form of POSIX path of save_location 
		& "screen" & (shotcount as string) & ".jpg"
	delay (10) -- delay 3 second  
	
	
	tell application "System Events"
		click at {1360, 450}
	end tell
	delay 3
	
	
end repeat
it take screen shot but it's saving it at my hard drive root i.e (Macintosh HD)

and it don't click
uaecasher is offline   0 Reply With Quote
Old Jul 5, 2009, 01:00 PM   #13
mysterytramp
macrumors 65816
 
mysterytramp's Avatar
 
Join Date: Jul 2008
Location: Maryland
The reason your screen shots are appearing in the wrong directory is because your variable "save_location" is fine, but then you add "the quoted form of Poxix path of save_location" -- you're gilding the lily and the computer doesn't know what's up.

if "ss" is a folder, save_location should end with a "/". So ...

Code:
set save_location to 
	"'Users/Fahad/Desktop/ss/'" -- assuming ss is a folder

repeat with shotcount from 1 to 2
	do shell script "screencapture " & save_location 
		& "screen" & (shotcount as string) & ".jpg"
	delay (10) -- delay 3 second  
	
	
	tell application "System Events"
		click at {1360, 450}
	end tell
	delay 3
	
	
end repeat
Why click isn't working, you got me. System Events is always a last resort and my guess is a) you're trying to grab pages from the amazon.com web site, and b) their programmers figured somebody might do this and are handling mouseclicks just differently enough to prevent someone from pulling this off.

I realize it's way too analog for the 21st century, but you might try a library.

mt
__________________
What looks large from a distance, close up ain't never that big.
mysterytramp is offline   0 Reply With Quote
Old Jul 14, 2009, 05:23 AM   #14
uaecasher
Thread Starter
macrumors 65816
 
uaecasher's Avatar
 
Join Date: Jan 2009
Location: Stillwater, OK
Send a message via AIM to uaecasher Send a message via MSN to uaecasher Send a message via Yahoo to uaecasher
no it does not click anywhere, like if i try to click on folder. and the location is still wrong even after adding / at the end
uaecasher is offline   0 Reply With Quote
Old Jul 16, 2009, 04:15 PM   #15
uaecasher
Thread Starter
macrumors 65816
 
uaecasher's Avatar
 
Join Date: Jan 2009
Location: Stillwater, OK
Send a message via AIM to uaecasher Send a message via MSN to uaecasher Send a message via Yahoo to uaecasher
any help please?
uaecasher is offline   0 Reply With Quote
Old Jul 16, 2009, 05:04 PM   #16
LtRammstein
macrumors 6502a
 
Join Date: Jun 2006
Location: Denver, CO
Send a message via AIM to LtRammstein Send a message via MSN to LtRammstein
What I recommend, and I do this all the time, is to have the Applescript editor record your clicks. So basically do what you want your script to do once. This way you can see the code generated by the computer and adapt it.
__________________
17" White Intel iMac 1.83GHz, 250 GB HD, 2 GB RAM || iPod Touch 16GB w/ 3.0 || 15" Intel MBP 2.4GHz, 250 GB HD, 4 GB RAM
LtRammstein is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Can't stop an Applescript with Automator Niouky Mac Programming 18 Apr 20, 2014 02:46 AM
AppleScript inside Automator not working alexk403 Mac Programming 1 Jul 21, 2013 10:09 PM
Automator and/or AppleScript Help jbsmithmac Mac Programming 6 May 5, 2013 04:02 PM
Automator and/or Applescript Help downingp Mac Programming 2 Oct 24, 2012 07:35 PM
Applescript and Automator Mix anton1s Mac Programming 0 Oct 20, 2012 07:02 PM

Forum Jump

All times are GMT -5. The time now is 08:28 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC