Created
October 9, 2023 19:40
-
-
Save robertripoll/e9b963ce5c40453edc5999c6c16f8424 to your computer and use it in GitHub Desktop.
Print Bike document with Chrome
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Prompt user to choose a file | |
set theFile to choose file with prompt "Select your file:" | |
-- Create a temporary path with .html extension | |
set filePath to POSIX path of theFile | |
set tempFilePath to filePath & ".temp.html" | |
-- Copy the original file to the temporary path | |
do shell script "cp " & quoted form of filePath & " " & quoted form of tempFilePath | |
-- Open the temporary file with Google Chrome | |
do shell script "/Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome " & quoted form of tempFilePath | |
-- Introduce a 0.5-second delay before sending the keystroke | |
delay 0.5 | |
-- Send a simulated Command + P keystroke to the Chrome window | |
tell application "System Events" | |
tell process "Google Chrome" | |
keystroke "p" using command down | |
end tell | |
end tell | |
-- Delete the temporary file | |
do shell script "rm " & quoted form of tempFilePath |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment