Hi,
I would like to save the screen shot from Safari Browser, in the path “~Desktop/Screenshot_From_Safari”, for that i have developed the below codes, but unfortunately it shows the error while save the path in the below line
set value of text field 1 of sheet 1 of window 1 to theName in [b]targetFolder[/b]
Can any one check and help me to resolve this error? and how do i save the screen shot in thiis path.
tell application "Finder"
set desktopFolder to (path to desktop)
set fldnm to "Screenshot_From_Safari"
set targetFolder to desktopFolder & "Screenshot_From_Safari:" as text
set rslt to my FldrExists(targetFolder)
if rslt is false then
set targetFolder to make new folder at folder desktopFolder with properties {name:fldnm}
else
delete (every item of folder (targetFolder) whose name ends with ".png")
end if
tell application "Safari"
activate
open location "https://www.apple.com"
set bounds of front window to {0, 0, 900, 900}
my screenCapture("Small.png", targetFolder)
delay 0.1
my webIns()
set bounds of front window to {0, 0, 1200, 900}
my screenCapture("Medium.png", targetFolder)
delay 0.1
my webIns()
set bounds of front window to {0, 0, 1400, 900}
my screenCapture("Large.png", targetFolder)
delay 0.1
end tell
end tell
tell application "Safari" to close tab 1 of window 1
on screenCapture(theName as text, targetFolder)
tell application "System Events" to tell application process "Safari"
repeat until (UI element "Reload this page" of group 2 of toolbar 1 of window 1 exists)
delay 0.1
end repeat
--display notification "The webpage is fully loaded now." sound name "Frog"
click menu item "Show Web Inspector" of menu 1 of menu bar item "Develop" of menu bar 1
delay 1
set theSelection to value of attribute "AXFocusedUIElement"
tell theSelection to perform action "AXShowMenu"
delay 1
keystroke "Capture Screenshot" & return
repeat until sheet 1 of window 1 exists
delay 0.01
end repeat
set value of text field 1 of sheet 1 of window 1 to theName in targetFolder
click button "Save" of sheet 1 of window 1
--display alert sheet 1
end tell
end screenCapture
on webIns()
tell application "System Events"
activate
tell application process "Safari"
set frontmost to true
# toggle Safari web inspector panel on or off
keystroke "i" using {option down, command down}
end tell
end tell
end webIns
on FldrExists(theFldr) -- (String) as Boolean
tell application "System Events"
if exists folder theFldr then
return true
else
return false
end if
end tell
end FldrExists
on FileExists(theFle) -- (String) as Boolean
tell application "System Events"
if exists file theFle then
return true
else
return false
end if
end tell
end FileExists
Thanks in Advance
Asuvath
Model: iMac
AppleScript: Applscript 2.7
Browser: Safari 537.36
Operating System: macOS 10.14