Back to Blog
Applescript bbautocomplete7/23/2023 ![]() ![]() Now we input this code into our Applescript editor: toinputByName (theName, num, theValue ) tell application "Safari"ĭo JavaScript " document.getElementsByName('" & theName & "').value ='" & theValue & "' " in document 1Īnd we call it in our script with… inputByName("q", 0, "how to peel a bananas") In this case the Name of this element in this form is “q”. Just as above we are going to find the attribute in the code that says “Name”. If you need more instructions on how to use this number please check read the clicking buttons on a web page tutorial. ![]() Trial and error is the least complicated way to figure out what number to place here. On pages with a single form, this will most likely be 0, however if there are several lines in your form you may have to adjust this number. But what is that 0 in the middle? That is how Applescript determines which instance of the Class to put the information into! The last part is the value we want to enter into the form. The first part, the “gsfi” is the Class Name we found in our code. InputB圜lass(“gsfi”, 0, “how to eat a grape”) Now we enter this slightly changed code into our AppleScript editor: toinputB圜lass (theclass, num, theValue ) tell application "Safari"ĭo JavaScript " document.getElementsB圜lassName('" & theclass & "').value ='" & theValue & "' " in document 1Īnd to call the function, we use the following code: This time we are going to look at the Class attribute inside of the tag.Īs you can see we will be using “gsfi” as our class identifier. To call this function, or to use it when we want we use the following code: inputByID("lst-ib", "how to peel a banana") Tell application "Safari" - tells AppleScript to use Safariĭo JavaScript " document.getElementById('" & theId & "').value ='" & theValue & "' " in document 1 - gets the ID that we specified and then inputs the value we specified into the ourformĮnd inputByID -marks the end of the function to inputByID ( theId, theValue ) - creates the function This code is a function that we can call at anytime in our script. Next we enter the following code into our AppleScript editor. We are going to specifically look at the part of the code inside of the tag that says id=”lst-ib”… We want to look inside of the tag to find either something that says “id”, “class”, or “name”. We are going to now look at the highlighted part of the code and search for anything that we can use to identify the form we want to enter our text into. This will split your window into an upper half with the website, and the bottom half that displays the source code. Next we are going to right click on the part of the form that we would like to fill out, and click inspect element… This will be very helpful in understanding what is going on here.įirst thing is first, go to the web page that you need to fill out a form for…in this case we are using while using the Google Chrome browser. Using this information along with what we learned in clicking buttons on a web page , we can perform an automated search or automatically login to a website! For this first example we are going to automate a search in Google.īefore proceeding please read clicking buttons on a web page. In a previous tutorial we covered how to use AppleScript to automate navigating to a web page. Now we are going to learn how to automate putting information into forms. NEW! AppleScript Maker Beta: Hey Everyone, I am working on a new AppleScript tool that is going to BLOW YOUR MIND! After reading this tutorial use this tool to easily build your AppleScripts. ![]()
0 Comments
Read More
Leave a Reply. |