Hi,
I have a apple script that reads the input from text file and it captures webpage using Paparazzi. It is working fine under nder OS X 10.4.x
please suggest what needs to be done ?
thanks
kamaraj.s
Hi,
I have a apple script that reads the input from text file and it captures webpage using Paparazzi. It is working fine under nder OS X 10.4.x
please suggest what needs to be done ?
thanks
kamaraj.s
post the script
I attached the script.
(I heard that Leopard includes a new version of Applescript)
Please help.
thanks
kamaraj.s
global inputFileString, inputFile, localFolder
global myTab
global currentPath, defaultsFile
global theInputData, theHost, theDirectory, lastChar, theUsername, thePassword, theDelay, theTimeout, theJPEGQualityFactor, theScaleFactor
--===================================================
-- Change the delimiters.
on atid(the_delim)
set AppleScript's text item delimiters to the_delim
end atid
--===================================================
--Subroutine to replace "/" with "_".
on remove_chars(theChar, this_text)
my atid(theChar)
set the item_list to every text item of this_text
my atid("_")
set this_text to the item_list as string
my atid("")
return this_text
end remove_chars
-- ========================================
--function to split a string using multiple delimiters
on multi_atid_split(the_string, the_delims)
-- store the originals and set up the marker.
set {OLD_delim, _marker_} to {AppleScript's text item delimiters, "?|?"}
-- process each of the delimiters in the_delims replacing each with the _marker_
repeat with this_delim in the_delims
my atid(this_delim) -- see the handler that follows
set the_string to text items of the_string
my atid(_marker_)
set the_string to text items of the_string as string
end repeat
-- At this point our text looks like this:
-- "This is a string?|? with?|?multiple delimiters."
my atid(_marker_) -- now get the markers out
set the_string to text items of the_string
my atid(OLD_delim) -- rebuild with the originals
return the_string
end multi_atid_split
-- ========================================
on doMainWork()
tell window "theMainWindow"
--Set the parameters
set theInputData to (do shell script "cat " & quoted form of POSIX path of inputFileString)
set theHost to contents of text field "serverField"
set theDirectory to contents of text field "directoryField"
set lastChar to (item (number of characters in theDirectory) of theDirectory)
if (lastChar is not "/") then
set theDirectory to theDirectory & "/"
end if
set theUsername to contents of text field "usernameField"
set thePassword to contents of text field "passwordField"
set theDelay to (contents of text field "intervalField" as integer)
set theTimeout to (contents of text field "timeoutField" as integer)
set theJPEGQualityFactor to (contents of text field "jpegQualityField" as real)
set theScaleFactor to (contents of text field "scaleFactorField" as real)
set theDataArray to multi_atid_split(theInputData, {myTab, return}) of me
repeat
-- get the current time
set oldStartTime to (current date)
-- get and upload the pictures
set gotError to false
tell application "Paparazzi!" to activate
tell application "Paparazzi!"
set itemNumber to 1
repeat (the number of items in theDataArray) / 3 times
set theLoc to (item itemNumber of theDataArray)
set theWidth to (item (itemNumber + 1) of theDataArray) as integer
set theHeight to (item (itemNumber + 2) of theDataArray) as integer
set oldTime to (current date)
capture theLoc crop size {theWidth, theHeight}
repeat until (((current date) > (oldTime + theTimeout)) or not busy)
--do nothing
end repeat
if ((current date) > (oldTime + theTimeout)) then
set gotError to true
tell application "System Events"
tell application "Paparazzi!" to activate
key code 36
end tell
end if
if (gotError is false) then
set theLocFixedChars to remove_chars("/", theLoc) of me
set theLocFixedChars to remove_chars("?", theLocFixedChars) of me
set theOutputFile to localFolder & theLocFixedChars & ".jpg"
save as JPEG in theOutputFile quality theJPEGQualityFactor
tell application "Image Events"
launch
set theImage to open theOutputFile
scale theImage by factor theScaleFactor
save theImage
close theImage
end tell
(*
tell application "Fetch"
store alias theOutputFile host theHost user theUsername password thePassword path (theDirectory & (theLocFixedChars as string) & ".jpg")
end tell --Fetch
*)
end if
set itemNumber to itemNumber + 3
set gotError to false
end repeat --each item
end tell -- Paparazzi
tell application "Paparazzi!" to quit
repeat until ((current date) ³ (oldStartTime + (theDelay * 60)))
-- do nothing while we're waiting
end repeat
end repeat
end tell
end doMainWork
-- ========================================
on awake from nib theObject
set myTab to " "
tell window "theMainWindow"
--Look for the defaults file
tell application "Finder" to get folder of (path to me) as Unicode text
set currentPath to POSIX path of result
try
set fileContents to (do shell script "cat " & currentPath & "/Screencapture_defaults.txt")
on error
set fileContents to ""
end try
--If we found it, then get the parameters
if (fileContents is not "") then
set defaultsFile to currentPath & "/Screencapture_defaults.txt"
set inputFileString to (do shell script "grep inputFile_SC " & defaultsFile & "| awk -F= '{print $2}'")
set contents of text field "inputFileField" to inputFileString
set localFolder to (do shell script "grep local_SC " & defaultsFile & "| awk -F= '{print $2}'")
set contents of text field "localFolderField" to localFolder
set contents of text field "serverField" to (do shell script "grep server_SC " & defaultsFile & "| awk -F= '{print $2}'")
set contents of text field "directoryField" to (do shell script "grep directory_SC " & defaultsFile & "| awk -F= '{print $2}'")
set contents of text field "usernameField" to (do shell script "grep username_SC " & defaultsFile & "| awk -F= '{print $2}'")
set contents of text field "passwordField" to (do shell script "grep password_SC " & defaultsFile & "| awk -F= '{print $2}'")
set contents of text field "intervalField" to (do shell script "grep repeatInterval_SC " & defaultsFile & "| awk -F= '{print $2}'")
set contents of text field "timeoutField" to (do shell script "grep timeout_SC " & defaultsFile & "| awk -F= '{print $2}'")
set contents of text field "jpegQualityField" to (do shell script "grep jpegQuality_SC " & defaultsFile & "| awk -F= '{print $2}'")
set contents of text field "scaleFactorField" to (do shell script "grep jpegScale_SC " & defaultsFile & "| awk -F= '{print $2}'")
doMainWork() of me
end if
end tell
end awake from nib
-- ========================================
on clicked theObject
-- ========================================
if name of theObject is "setInputFileButton" then
tell window of theObject
set inputFileString to (choose file with prompt "Choose the input file:" without invisibles)
set contents of text field "inputFileField" to inputFileString
end tell
-- ========================================
else if name of theObject is "setLocalFolderButton" then
tell window of theObject
set localFolder to choose folder with prompt "Choose the picture folder:" without invisibles
set contents of text field "localFolderField" to localFolder
end tell
-- ========================================
else if name of theObject is "activateButton" then
tell window "theMainWindow"
doMainWork() of me
end tell
-- ========================================
end if
end clicked
can you please explain, what’s going wrong. The more detailed the better.
The script will read the input file and it will take a snapshot of the website.
input file contents:
www.delight.com 800 600
www.ejectit.com 775 515
www.ewoobie.com 850 450
www.fabric.com 950 475
www.firefold.com 800 500
the images capture is working fine in the OS X 10.4.x. But it is not working in OS X 10.5.7