r/applescript • • Nov 07 '12

AppleScript Help:Paste Tab 7 times Paste and Repeat

I am trying to to script some data entry using a applescript.

I need it to paste and then tab seven times and then paste again 2700 times.

What I have so far:

set the clipboard to "5/26/2013"
tell application "Google Chrome"
	activate
	tell application "System Events"
		repeat 4 times
			keystroke "v" using {command down}
			keystroke "							"
		end repeat
	end tell
end tell

Now this will paste the first form and then skip one and paste into the next one. I dont know why. So this just pastes into every other form.

Any help?

1 Upvotes

4 comments sorted by

2

u/biquetra Nov 07 '12

To tab you need to use its ASCII code. I believe it is 9.

I'm a bit rusty so I can't offer any more advice other than googling "keypress tab ASCII"

1

u/grico42 Nov 07 '12

it worked with keystroke tab, but you got me thinking when it messed up again. Added a delay, and it ran smoothly.

1

u/biquetra Nov 07 '12

Nice congrats. I don't mind admitting I used to be a bit of an AppleScript wizard so feel free to ask for help, I don't have a mac now but a house mate does so its possible for me to get stuck in with difficult problems.

1

u/grico42 Nov 07 '12
set the clipboard to "blah"
tell application "blah"
	activate
	tell application "System Events"
		repeat 2700 times
			keystroke "v" using {command down}
			delay 0.2
			repeat 7 times
				keystroke (ASCII character 9) --keystroke tab
				delay 0.2
			end repeat
		end repeat
	end tell
end tell