Zandy88 Posted June 19, 2022 Share Posted June 19, 2022 Hi, I have a repetitive task that I'd like to automate. I want to type in 4 arguments into alfred and have them populated into a row in a google sheet. What needs to happen is these 4 values go into the columns a,b,c and d and then I have formulas to calculate what I need off the back of them in columns e, f, g. Is this possible and if so how? I'm a relative noob so pleas bare with me. Thanks! Link to comment
vitor Posted June 19, 2022 Share Posted June 19, 2022 Welcome @Zandy88, This depends more on Google or your browser than Alfred. There are three main ways to do it: Use the Google Docs API. May require a lot of set up, be too specific, and is at the whims of Google.Automate the page itself by sending JavaScript to it. Depends on your web browser and the Google docs page itself.Simulate key presses. This is called GUI automation and can be finicky, but might be the most straightforward way in this case. Set up a Keyword to accept your argument. Think of a character to be the delimiter between values (e.g. a comma) so you might type in Alfred something like sheets 11, 8, 12, 8. Connect that to a Split Argument to Variables. Then make creative use of Dispatch Key Combo (to e.g. press ⇥ and go to the next field) and Copy to Clipboard (tick “Automatically paste to front most app” and use the variables you split like {var:split1}, {var:split2}) to input your data. If it runs too fast, add some Delay. Link to comment
Zandy88 Posted June 20, 2022 Author Share Posted June 20, 2022 Thanks @vitor! I've been using the third option for creating some workflows so this would probably be the easiest for me to begin with. To use the GUI to get to the right place in the sheet is there a way I can find the chrome tab with the sheet open (usually when I'll be doing this process the sheet will already be open with multiple other tabs) and automate going to the correct location within the sheet? Link to comment
vitor Posted June 20, 2022 Share Posted June 20, 2022 14 hours ago, Zandy88 said: is there a way I can find the chrome tab with the sheet open (…) and automate going to the correct location within the sheet? Add a Run Script Action with Language set to /usr/bin/osascript (JavaScript) and code: const docsURL = "docs.google.com" const browser = Application("Google Chrome") const docsTab = browser .windows[0] .tabs() .findIndex(tab => tab.url().includes(docsURL)) + 1 browser.windows[0].activeTabIndex = docsTab That will switch Google Chrome to the first tab on the frontmost window whose URL matches docs.google.com (change that in the first line if you need to). Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now