Using A Barcode Scanner Alongside Apple Scripts

Good day,

I am familiar with Apple Scripts and have used it before to automate tasks, but I am trying to emplement it into a more specific task. My plan is to have it open up a Google Form in Safari. And then wait for the user to scan a barcode, then take that input text from the barcode and drop it into a spot on the Google Form. Any help would be appreciative of any help for being able to have the program wait on the barcode input, then continue on with the script! Thank you!

Here is an example Google Form to go along with what the following code will be doing: https://forms.gle/E4SGL7jPqaHsf5Cb9


Code:

--repeat--
tell application "Safari"
	activate
	make new document
end tell

tell application "System Events"
	tell application process "Safari"
		keystroke "https://forms.gle/isxQK1xjkow8xiUq8"
		keystroke return
		delay 2
		keystroke tab

		-- This is where the code would need to be added for inputing the text from the barcode scanner --

		keystroke tab
		keystroke return
	end tell
end tell

tell application "Safari"
	close window 1
end tell
--end repeat--

MacBook Pro 13", macOS 10.14

Posted on May 4, 2019 1:01 PM

Reply
2 replies

May 4, 2019 2:30 PM in response to techguy5000

Hard to say without knowing what barcode software you're using and whether or not it's scriptable. One approach might be to use System Events to copy and paste the text into the web form. This would be the paste:


tell application "System Events"

tell application process "Safari"

keystroke "v" using command down

end tell

end tell


But without more information about how you're acquiring the text, it's not really possible to suggest how to script it.


Cheers,


H


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Using A Barcode Scanner Alongside Apple Scripts

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.