Skip to content

Instantly share code, notes, and snippets.

@trapier
Created August 7, 2017 18:03
Show Gist options
  • Save trapier/0cb6d2471d9254a8cdb66e29677c57ab to your computer and use it in GitHub Desktop.
Save trapier/0cb6d2471d9254a8cdb66e29677c57ab to your computer and use it in GitHub Desktop.
autokey-gtk script to copy case and account number out of salesforce classic case view in vimium into markdown format
import time
def keyboard_type(keys):
for key in keys:
keyboard.send_keys(key)
time.sleep(0.1)
def copy_next_field():
keyboard_type("vcwv$y")
def copy_next_word():
keyboard_type("vcwvey")
# record current page position
keyboard_type("ma")
# copy case number
keyboard_type("gg/case number")
keyboard.send_keys("<enter>")
copy_next_word()
case_number = clipboard.get_selection()
# copy case url
keyboard_type("yy")
case_url = clipboard.get_selection()
# copy account name
keyboard_type("gg/account name")
keyboard.send_keys("<enter>")
copy_next_field()
account_name = clipboard.get_selection()
# copy account url
keyboard_type("yfp")
account_url = clipboard.get_selection()
# return to previous page position
keyboard_type("'a")
result = "Support Case: [" + case_number + "](" + case_url + ")"
result = result + "\n"
result = result + "Account: [" + account_name + "](" + account_url + ")"
# NOTE: may patching /usr/lib/python2.7/site-packages/autokey/scripting.py
# from: self.selection.set_text(string.encode("utf-8"))
# to: self.selection.set_text(string.encode("utf-8"), len=-1)
clipboard.fill_selection(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment