Jump to content

Automate a Google Search

This topic is 4597 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I'm looking to accomplish the following, utilizing a script:

1. Copy the contents of a text field to clipboard.

2. Open a Google search page.

3. Paste the copied text into the Google search box

Once I activate the script, FP7 would go to the background and I'm left viewing the Google search results. Once I close the Google search, the Filemaker application would then be back in view.

Is the above possible with FileMaker Pro 8 Advanced with Windows XP OS?

...any help is greatly appreciated.

Edited by Guest
Link to comment
Share on other sites

There are at least three ways to do this. The paste method you asked about requires some rather tricky Winscripting. Two much easier methods are:

Construct a URL in a text field and then use SendEvent. The format is

"http:// www. google.com/ search? hl=en&q=TEXTSTRING&btnG=Search"

where TEXTSTRING is what you want to search for. The PC's browser will open, and you can go back and forth (if need be) using the XP taskbar.

A similar method (in 8.5) is to define a web viewer field inside Filemaker and let it do the same search. The disadvantage to that method is that you don't have some of the browsers standard tools at work for you (ad blocking, for example).

Link to comment
Share on other sites

Try the OpenURL script step. click specify. the calc is:

"http://www.google.com/search?hl=en&q=" & yourtable::TextField

This can be done with or without dialog and you don't even need to write a script. Just create a button the uses this one script step.

Oh and this should work on any OS that you can run filemaker on and wil work in FM8

  • Thanks 1
Link to comment
Share on other sites

Hello aholtzapfel ,

Please walk me through your solution....for some reason the simplicity of it eludes me totally. You state I do need to create a script, yet I will use one?

And K1200,

I wish to copy the contents of a text field to the Google search....please elaborate also?

Dang, I'm nowhere as good with Filemaker as I thought I was. This is embarrassing.

Link to comment
Share on other sites


Create your text field(to hold your search crietea for google).

Put it on a layout.

Create a button.

In the button setup, scroll down, under Miscellaneous is the "Open URL", Choose it. (you can execute any one script step with a button, and we only need one, so no script)

In the options, click specify, twice. and enter

"http://www.google.com/search?hl=en&q=" & TextField

Click, ok,

Preform without dialog

and ok.

Switch to browse mode, enter text into field, and hit the button. :( :P

Link to comment
Share on other sites

I'll assume you mean the technique with the Web Viewer. There are three steps:

1. Define a SearchText field that holds the text you want to search for.

2. Define a CalculatedURL field that constructs the URL in the same manner as the above Open URL method (baseURL & SearchText).

3. Define a Web Viewer field on some target layout and in Web Viewer Setup, select Custom Web Address and specify the calculated field as the Web Address.

Whenever you go to the target layout it will attempt a google search (if that's the URL you specified) for whatever text is currently in the SearchText field.

Link to comment
Share on other sites


Teds Example is it.

As you can see, no WebViewer. Just 1 table, 1 field, on 1 layout, with 1 button. (simplicity is beautiful)

This is similer to what a web viewer does, but Open URL makes an external call to your browser.

(not sure what version open URL was added, think it was in 5, maybe 6, but it has been around awhile)

(edit: just looking at teds file, He replaces the spaces in the text field with +'s, in my experience this is not necessary, the necessary formating changes should happen automaticlly. Spaces will be changed to %20 in the browser. and the call should work fine, even without the "&btnG=Search" string at the end. I can't tell you why this works but it does.

edit2: Ok after a little looking, you might need to do the extra steps, the exception being if your browser is IE.)

Edited by Guest
Link to comment
Share on other sites


The Open URL command goes back to the 5.X days and possibly the 4.X days as well. It did not go back to 3.0 but there was a similar command called Send Message that would work much like Open URL.

On version 3.0 you would simply prepend the browser executable to the beginning of the URL string. Something like this:

"iexplore.exe http://www.google.com/search?hl=..."

All this says is open the application "iexplore.exe" (Internet Explorer) and load the following page.

Edited by Guest
Link to comment
Share on other sites

Send Event (did this used to be called send message) is a great script step. It Provides access to the Command line in the windows OS. Any thing you can do by using the run command in the start menu can be automated with this script step. (If you can find the command line switches associated with commands and applications you can do all sorts of neat things. create folders, copy files, open application is a specific view with specific document,and the list goes on) It is a windows specific script step, Open URL is not.

Link to comment
Share on other sites

You Guys N Gals are beyond fantastic!

NOW I see the light, thanks to you. It all makes sense now....I more than appreciate all your help and guidance.

The solution works fluidly and has helped me greatly. It's best to understand "why" something works as oppossed to merely pluging in the "fix" and now I understand it.

Thank you all again...my hat's off to you.

Link to comment
Share on other sites

  • 4 years later...

Revisiting this, recently, I'm wondering how to add an additional fields contents to the Google search. I'm presently using a company name but wish to also add the company address to the search, as well. I'm sure it's a simple addition but I'm not able to create it properly.

Your example is: "http://www.google.com/search?hl=en&q=" & Substitute ( Software::Terms; " "; "+" ) & "&btnG=Search"

My attempt to add the additional field contents is:

"http://www.google.com/search?hl=en&q=" & Substitute ( Software::Terms; Software::Address;" "; "+" ) & "&btnG=Search"

This gives me an error......what am I not doing correctly, please?

Link to comment
Share on other sites

This topic is 4597 days old. Please don't post here. Open a new topic instead.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.