Skip to content

Instantly share code, notes, and snippets.

@bzinberg
Created January 11, 2020 17:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bzinberg/ed57c723024e44340c3346801d1f2552 to your computer and use it in GitHub Desktop.
Save bzinberg/ed57c723024e44340c3346801d1f2552 to your computer and use it in GitHub Desktop.
Automated keyboard & mouse events to copy Payee Details from web page to spreadsheet
#!/bin/bash
#
# Script to copy various text fields from the Chase Bill Pay "Payee
# Details" page into rows of a spreadsheet. (There is an export tool
# for wire transfer payees, but no export for Bill Pay payees.)
#
# The hard-coded numbers are specific to the web page, browser, font
# sizes, etc. It was easier in this case to do automated mouse and key
# presses in the browser than to write a custom scraper.
set -e
readonly VERTOFFSET=0
focus_sheet() {
xdotool mousemove 2000 10
xdotool click 1
}
triple_click() {
xdotool click --repeat 3 1
}
copy() {
xdotool key ctrl+c
}
paste() {
xdotool key ctrl+v
}
copy_to_sheet() {
triple_click
sleep 0.1
copy
sleep 0.1
focus_sheet
# Don't paste too fast, or else Google Sheets might not be ready to
# receive the paste
sleep 0.3
paste
sleep 0.1
}
right() {
xdotool key Right
sleep 0.1
}
next_line_in_sheet() {
xdotool key Down
sleep 0.1
xdotool key Home
sleep 0.1
}
# Name
xdotool mousemove 850 $((VERTOFFSET + 690))
copy_to_sheet
right
# Nickname
xdotool mousemove 850 $((VERTOFFSET + 750))
copy_to_sheet
right
# Street address
xdotool mousemove 850 $((VERTOFFSET + 920))
copy_to_sheet
right
# City/State/Zip
xdotool mousemove 850 $((VERTOFFSET + 960))
copy_to_sheet
right
# Phone
xdotool mousemove 850 $((VERTOFFSET + 1020))
copy_to_sheet
right
# To next line in the sheet
next_line_in_sheet
# Move mouse back to the list of payees
xdotool mousemove 100 600
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment